2008-06-02 Ivan N. Zlatev <contact@i-nz.net>
authorIvan Zlatev <ivan@ivanz.com>
Mon, 2 Jun 2008 17:29:12 +0000 (17:29 -0000)
committerIvan Zlatev <ivan@ivanz.com>
Mon, 2 Jun 2008 17:29:12 +0000 (17:29 -0000)
* MonoType.cs, Binder.cs, MonoGenericClass.cs: For property reflection
we should strictly match the return type if available.
* TypeTest.cs: Add tests to verify strict return type matching of
property reflection.

svn path=/trunk/mcs/; revision=104695

mcs/class/corlib/System.Reflection/Binder.cs
mcs/class/corlib/System.Reflection/ChangeLog
mcs/class/corlib/System.Reflection/MonoGenericClass.cs
mcs/class/corlib/System/ChangeLog
mcs/class/corlib/System/MonoType.cs
mcs/class/corlib/Test/System/ChangeLog
mcs/class/corlib/Test/System/TypeTest.cs

index 549cf4d7158b6b8df93094b0253cf4bef49c3cc6..898d4ad38489227329ceb132e21f1772fef0f7aa 100644 (file)
@@ -515,7 +515,7 @@ namespace System.Reflection
                                        if (idxlen >= 0 && idxlen != args.Length)
                                                continue;
 
-                                       if (haveRet && !check_type (p.PropertyType, returnType))
+                                       if (haveRet && p.PropertyType != returnType)
                                                continue;
 
                                        int score = Int32.MaxValue - 1;
index 1d93ca6df1e49b165581bbe3cb2a074573a68ec6..05b21cdc860cce0f93116df53e23fa29d8b54764 100644 (file)
@@ -1,3 +1,8 @@
+2008-06-02  Ivan N. Zlatev  <contact@i-nz.net>
+
+       * Binder.cs, MonoGenericClass.cs: For property reflection we should 
+       strictly match the return type if available.
+
 2008-05-16  Zoltan Varga  <vargaz@gmail.com>
 
        * MonoGenericClass.cs (GetConstructor): Remove some old code, as the new code
index 708ef9352ee7c26a2eb70480b565d11209c4efdd..bf2e4ab2bd14137cdf5a0b8751a51190effa2749 100644 (file)
@@ -496,7 +496,8 @@ namespace System.Reflection
                        
                        int count = props.Length;
                        
-                       if (count == 1 && (types == null || types.Length == 0)) 
+                       if (count == 1 && (types == null || types.Length == 0) &&
+                           (returnType == null || returnType == props[0].PropertyType))
                                return props [0];
 
                        if (binder == null)
index bd2ea28cec3747023df3a9e1ac271a8d0598d5b9..64cf4bb075ecd76ccc7fe8dc076f5d8ef07d0b4f 100644 (file)
@@ -1,3 +1,8 @@
+2008-06-02  Ivan N. Zlatev  <contact@i-nz.net>
+
+       * MonoType.cs: For property reflection we should strictly match the return 
+       type if available.
+
 2008-06-01  Juraj Skripsky  <js@hotfeet.ch>
 
        * String.cs (Substring): Blocking bug #395904 has been fixed,
index 1a2ae351c30427f3e809a4c29e92bb91e1b03f8f..59b99e053190fcc05197cea67701accc03c68de4 100644 (file)
@@ -270,7 +270,8 @@ namespace System
                        if (count == 0)
                                return null;
                        
-                       if (count == 1 && (types == null || types.Length == 0)) 
+                       if (count == 1 && (types == null || types.Length == 0) && 
+                           (returnType == null || returnType == props[0].PropertyType))
                                return props [0];
 
                        if (binder == null)
index d08106c40caedf6ef660380c09c5845cff9547bf..2e48f0a82ef60bb459f1deff2a413f23c4c6a96a 100644 (file)
@@ -1,3 +1,8 @@
+2008-06-02  Ivan N. Zlatev  <contact@i-nz.net>
+
+       * TypeTest.cs: Add tests to verify strict return type matching of 
+       property reflection.
+
 2008-06-01  Juraj Skripsky  <js@hotfeet.ch>
 
        * StringTest.cs (Substring2): Blocking bug #395904 has been fixed,
index 07f9b6d49e28584f415632734fee4a879e9de522..841aaa0649c3025297bc38bab95495d815c24fd6 100644 (file)
@@ -1538,6 +1538,16 @@ namespace MonoTests.System
                        }
                }
 
+               [Test]
+               public void GetProperty8_PropertyType ()
+               {
+                       Type type = typeof (Bar);
+                       Assert.IsNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance,
+                                                        null, typeof (int), Type.EmptyTypes, null), "#1");
+                       Assert.IsNotNull (type.GetProperty ("PubInst", BindingFlags.Public | BindingFlags.Instance, null, 
+                                                           typeof (long), new Type[0], null), "#2");
+               }
+
 #if !TARGET_JVM // StructLayout not supported for TARGET_JVM
                [StructLayout(LayoutKind.Explicit, Pack = 4, Size = 64)]
                public class Class1