Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederik Carlier <frederik.carlier@quamotion.mobi>2017-03-18 01:30:35 +0300
committerMarek Safar <marek.safar@gmail.com>2017-03-18 01:30:35 +0300
commit1540749175796f1763ba47d1a56e79007cd4a3bf (patch)
tree3213f64b3c4b72820a1773b5d1046458af99c46a /mcs/class/System.Drawing
parent463cf3b5c1590df58fef43577b9a3273d5eece3d (diff)
Make System.Drawing code compatible with .NET Core (#4548)
Diffstat (limited to 'mcs/class/System.Drawing')
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/InvalidPrinterException.cs2
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Bitmap.cs7
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Font.cs8
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Icon.cs13
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Image.cs2
5 files changed, 20 insertions, 12 deletions
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/InvalidPrinterException.cs b/mcs/class/System.Drawing/System.Drawing.Printing/InvalidPrinterException.cs
index 02a3f27c9a5..22573086370 100644
--- a/mcs/class/System.Drawing/System.Drawing.Printing/InvalidPrinterException.cs
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/InvalidPrinterException.cs
@@ -56,7 +56,7 @@ namespace System.Drawing.Printing {
base.GetObjectData (info, context);
}
-
+
private static string GetMessage(PrinterSettings settings)
{
if (settings.PrinterName == null || settings.PrinterName == String.Empty)
diff --git a/mcs/class/System.Drawing/System.Drawing/Bitmap.cs b/mcs/class/System.Drawing/System.Drawing/Bitmap.cs
index ffa825c5f27..7a7d8c68952 100644
--- a/mcs/class/System.Drawing/System.Drawing/Bitmap.cs
+++ b/mcs/class/System.Drawing/System.Drawing/Bitmap.cs
@@ -37,6 +37,7 @@
using System.IO;
using System.Drawing.Imaging;
+using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
using System.ComponentModel;
@@ -132,7 +133,11 @@ namespace System.Drawing
if (resource == null)
throw new ArgumentException ("resource");
- Stream s = type.Assembly.GetManifestResourceStream (type, resource);
+ // For compatibility with the .NET Framework
+ if (type == null)
+ throw new NullReferenceException();
+
+ Stream s = type.GetTypeInfo ().Assembly.GetManifestResourceStream (type, resource);
if (s == null) {
string msg = Locale.GetText ("Resource '{0}' was not found.", resource);
throw new FileNotFoundException (msg);
diff --git a/mcs/class/System.Drawing/System.Drawing/Font.cs b/mcs/class/System.Drawing/System.Drawing/Font.cs
index 34117a2e193..31861d51238 100644
--- a/mcs/class/System.Drawing/System.Drawing/Font.cs
+++ b/mcs/class/System.Drawing/System.Drawing/Font.cs
@@ -31,6 +31,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
using System.ComponentModel;
@@ -427,10 +428,7 @@ namespace System.Drawing
[Browsable(false)]
public bool IsSystemFont {
get {
- if (systemFontName == null)
- return false;
-
- return StringComparer.InvariantCulture.Compare (systemFontName, string.Empty) != 0;
+ return !string.IsNullOrEmpty (systemFontName);
}
}
@@ -624,7 +622,7 @@ namespace System.Drawing
}
Type st = logFont.GetType ();
- if (!st.IsLayoutSequential)
+ if (!st.GetTypeInfo ().IsLayoutSequential)
throw new ArgumentException ("logFont", Locale.GetText ("Layout must be sequential."));
// note: there is no exception if 'logFont' isn't big enough
diff --git a/mcs/class/System.Drawing/System.Drawing/Icon.cs b/mcs/class/System.Drawing/System.Drawing/Icon.cs
index 8352f15c670..6fe88d5a2e0 100644
--- a/mcs/class/System.Drawing/System.Drawing/Icon.cs
+++ b/mcs/class/System.Drawing/System.Drawing/Icon.cs
@@ -36,6 +36,7 @@ using System.Collections;
using System.ComponentModel;
using System.Drawing.Imaging;
using System.IO;
+using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
@@ -229,7 +230,11 @@ namespace System.Drawing
if (resource == null)
throw new ArgumentException ("resource");
- using (Stream s = type.Assembly.GetManifestResourceStream (type, resource)) {
+ // For compatibility with the .NET Framework
+ if (type == null)
+ throw new NullReferenceException();
+
+ using (Stream s = type.GetTypeInfo ().Assembly.GetManifestResourceStream (type, resource)) {
if (s == null) {
string msg = Locale.GetText ("Resource '{0}' was not found.", resource);
throw new FileNotFoundException (msg);
@@ -261,7 +266,7 @@ namespace System.Drawing
internal Icon (string resourceName, bool undisposable)
{
- using (Stream s = typeof (Icon).Assembly.GetManifestResourceStream (resourceName)) {
+ using (Stream s = typeof (Icon).GetTypeInfo ().Assembly.GetManifestResourceStream (resourceName)) {
if (s == null) {
string msg = Locale.GetText ("Resource '{0}' was not found.", resourceName);
throw new FileNotFoundException (msg);
@@ -859,10 +864,10 @@ Console.WriteLine ("\tbih.biClrImportant: {0}", bih.biClrImportant);
}
imageData [j] = iidata;
- bihReader.Close();
+ bihReader.Dispose ();
}
- reader.Close();
+ reader.Dispose ();
}
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing/Image.cs b/mcs/class/System.Drawing/System.Drawing/Image.cs
index c5af3c18e1b..6bd89918dd6 100644
--- a/mcs/class/System.Drawing/System.Drawing/Image.cs
+++ b/mcs/class/System.Drawing/System.Drawing/Image.cs
@@ -794,7 +794,7 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
Status status = GDIPlus.GdipDisposeImage (nativeObject);
// dispose the stream (set under Win32 only if SD owns the stream) and ...
if (stream != null) {
- stream.Close ();
+ stream.Dispose ();
stream = null;
}
// ... set nativeObject to null before (possibly) throwing an exception