[System.Drawing] NS1.6 compatibility: Use GetTypeInfo () where required (#4861)
authorFrederik Carlier <frederik.carlier@quamotion.mobi>
Mon, 15 May 2017 00:23:43 +0000 (02:23 +0200)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 15 May 2017 00:23:43 +0000 (02:23 +0200)
* netstandard1.6 compatibility: Use GetTypeInfo () where required

A lot of methods have moved from Type to TypeInfo in netstandard1.6, add calls to GetTypeInfo ()
where required to support compiling System.Drawing on netstandard1.6

* Add missing using statement

mcs/class/System.Drawing/System.Drawing.Printing/MarginsConverter.cs
mcs/class/System.Drawing/System.Drawing/ColorConverter.cs
mcs/class/System.Drawing/System.Drawing/ComIStreamMarshaler.cs
mcs/class/System.Drawing/System.Drawing/FontConverter.cs
mcs/class/System.Drawing/System.Drawing/ImageFormatConverter.cs
mcs/class/System.Drawing/System.Drawing/ToolboxBitmapAttribute.cs
mcs/class/System.Drawing/System.Drawing/macFunctions.cs

index 32f21b8bea48805baead65a386d3070b6feb358f..99f194354f6ad23f80dae12dd3d372d67830f369 100644 (file)
@@ -103,7 +103,7 @@ namespace System.Drawing.Printing {
                        }
                        if (destinationType == typeof (InstanceDescriptor) && value is Margins) {
                                Margins c = (Margins) value;
-                               ConstructorInfo ctor = typeof(Margins).GetConstructor (new Type[] {typeof(int), typeof(int), typeof(int), typeof(int)} );
+                               ConstructorInfo ctor = typeof(Margins).GetTypeInfo ().GetConstructor (new Type[] {typeof(int), typeof(int), typeof(int), typeof(int)} );
                                return new InstanceDescriptor (ctor, new object[] {c.Left, c.Right, c.Top, c.Bottom});
                        }
 
index 2a49f6f945bcefdf116a46760938597450620a05..e729a035286833480690f8268f8112976620fb50 100644 (file)
@@ -205,13 +205,13 @@ namespace System.Drawing
                                        return sb.ToString ();
                                } else if (destinationType == typeof (InstanceDescriptor)) {
                                        if (color.IsEmpty) {
-                                               return new InstanceDescriptor (typeof (Color).GetField ("Empty"), null);
+                                               return new InstanceDescriptor (typeof (Color).GetTypeInfo ().GetField ("Empty"), null);
                                        } else if (color.IsSystemColor) {
-                                               return new InstanceDescriptor (typeof (SystemColors).GetProperty (color.Name), null);
+                                               return new InstanceDescriptor (typeof (SystemColors).GetTypeInfo ().GetProperty (color.Name), null);
                                        } else if (color.IsKnownColor){
-                                               return new InstanceDescriptor (typeof (Color).GetProperty (color.Name), null);
+                                               return new InstanceDescriptor (typeof (Color).GetTypeInfo ().GetProperty (color.Name), null);
                                        } else {
-                                               MethodInfo met = typeof(Color).GetMethod ("FromArgb", new Type[] { typeof(int), typeof(int), typeof(int), typeof(int) } );
+                                               MethodInfo met = typeof(Color).GetTypeInfo ().GetMethod ("FromArgb", new Type[] { typeof(int), typeof(int), typeof(int), typeof(int) } );
                                                return new InstanceDescriptor (met, new object[] {color.A, color.R, color.G, color.B });
                                        }
                                }
index 5064cae15d46d1309660181a87aa652941653ef0..c12a852f04ba58f6fd4e8b1698f466d69bd5dc5b 100644 (file)
@@ -105,7 +105,7 @@ namespace System.Drawing
 
                        private static readonly Guid IID_IUnknown = new Guid("00000000-0000-0000-C000-000000000046");
                        private static readonly Guid IID_IStream = new Guid("0000000C-0000-0000-C000-000000000046");
-                       private static readonly MethodInfo exceptionGetHResult = typeof(Exception).GetProperty("HResult", BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.ExactBinding, null, typeof(int), new Type[] {}, null).GetGetMethod(true);
+                       private static readonly MethodInfo exceptionGetHResult = typeof(Exception).GetTypeInfo ().GetProperty("HResult", BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.ExactBinding, null, typeof(int), new Type[] {}, null).GetGetMethod(true);
                        // Keeps delegates alive while they are marshaled
                        private static readonly IStreamVtbl managedVtable;
                        private static IntPtr comVtable;
index 383dee47d52ec23e41000182fccb0f95bce718a6..13f05dd5bc6a22e565042bde697dba87af9da894 100644 (file)
@@ -114,7 +114,7 @@ namespace System.Drawing
 
                        if ((destinationType == typeof (InstanceDescriptor)) && (value is Font)) {
                                Font font = (Font) value;
-                               ConstructorInfo met = typeof(Font).GetConstructor (new Type[] {typeof(string), typeof(float), typeof(FontStyle), typeof(GraphicsUnit)});
+                               ConstructorInfo met = typeof(Font).GetTypeInfo ().GetConstructor (new Type[] {typeof(string), typeof(float), typeof(FontStyle), typeof(GraphicsUnit)});
                                object[] args = new object[4];
                                args [0] = font.Name;
                                args [1] = font.Size;
index 89f9e2fa0b0d478e31ba04a193533e3438aa6b83..a6195011da3e29447c99f20de7353528739de664 100644 (file)
@@ -154,9 +154,9 @@ namespace System.Drawing
                                        return prop != null ? prop : c.ToString ();
                                } else if (destinationType == typeof (InstanceDescriptor)) {
                                        if (prop != null){
-                                               return new InstanceDescriptor (typeof (ImageFormat).GetProperty (prop), null);
+                                               return new InstanceDescriptor (typeof (ImageFormat).GetTypeInfo ().GetProperty (prop), null);
                                        } else {
-                                               ConstructorInfo ctor = typeof(ImageFormat).GetConstructor (new Type[] {typeof(Guid)} );
+                                               ConstructorInfo ctor = typeof(ImageFormat).GetTypeInfo ().GetConstructor (new Type[] {typeof(Guid)} );
                                                return new InstanceDescriptor (ctor, new object[] {c.Guid});
                                        }
                                }
index 9737b48e1dcceb1825189a0dc9ef489eee389ac3..6352155fb964172c079b94682d4f27d23ae28a88 100644 (file)
@@ -33,6 +33,7 @@
 //
 
 using System;
+using System.Reflection;
 
 namespace System.Drawing
 {
@@ -116,7 +117,7 @@ namespace System.Drawing
                                imageName = t.Name + ".bmp";
 
                        try {
-                               using (System.IO.Stream s = t.Assembly.GetManifestResourceStream (t.Namespace + "." + imageName)){
+                               using (System.IO.Stream s = t.GetTypeInfo ().Assembly.GetManifestResourceStream (t.Namespace + "." + imageName)){
                                        if (s == null) {
                                                return null;
                                        } else {
index 7fe2e704a8fbaae7e6730dcf8e799f36ea5add44..157a8cb398f91f7b674bad505bfbc70798fe47f9 100644 (file)
@@ -52,7 +52,7 @@ namespace System.Drawing {
                                if (String.Equals (asm.GetName ().Name, "System.Windows.Forms")) {
                                        Type driver_type = asm.GetType ("System.Windows.Forms.XplatUICarbon");
                                        if (driver_type != null) {
-                                               hwnd_delegate = (Delegate) driver_type.GetField ("HwndDelegate", BindingFlags.NonPublic | BindingFlags.Static).GetValue (null);
+                                               hwnd_delegate = (Delegate) driver_type.GetTypeInfo() .GetField ("HwndDelegate", BindingFlags.NonPublic | BindingFlags.Static).GetValue (null);
                                        }
                                }
                        }