Handle property with default values. Fix part of #13336.
authorRodrigo Kumpera <kumpera@gmail.com>
Sun, 21 Jul 2013 22:22:57 +0000 (18:22 -0400)
committerRodrigo Kumpera <kumpera@gmail.com>
Sun, 21 Jul 2013 22:22:57 +0000 (18:22 -0400)
mcs/class/corlib/System.Reflection/ParameterInfo.cs
mcs/class/corlib/Test/System.Reflection/PropertyInfoTest.cs

index 471a9a25b62fae2bad941fd47a6f52f448cec10d..cbefc3ac27710d380be4edce0c1a5710f3676a8d 100644 (file)
@@ -97,6 +97,7 @@ namespace System.Reflection
                        this.NameImpl = pinfo.Name;
                        this.PositionImpl = pinfo.Position;
                        this.AttrsImpl = pinfo.Attributes;
+                       this.DefaultValueImpl = pinfo.DefaultValueImpl;
                        //this.parent = pinfo;
                }
 
index 3bee7e8c55fadcca660a076085fd52fe1f53bab7..67da2d7b5c864238748b83fe2fad23328acbc57e 100644 (file)
@@ -528,5 +528,23 @@ namespace MonoTests.System.Reflection
                                Assert.IsTrue (ex.InnerException is ObjectDisposedException);
                        }
                }
+
+               public class DefaultValueTest
+               {
+                       public string this[int val, string param = "test"]
+                       {
+                               get{ return val + param; }
+                       }
+               }
+
+
+               [Test]
+               public void PropertyWithDefaultValue ()
+               {
+                       var parameters = typeof (DefaultValueTest).GetProperty ("Item").GetIndexParameters ();
+                       var defaultParam = parameters[parameters.Length - 1];
+                       Assert.AreEqual ("param", defaultParam.Name, "#1");
+                       Assert.AreEqual ("test", defaultParam.DefaultValue, "#2");
+               }
        }
 }