Author: kumpera
Date: 2008-01-24 17:16:22 -0500 (Thu, 24 Jan 2008)
New Revision: 93850
Modified:
trunk/mcs/class/corlib/System/ChangeLog
trunk/mcs/class/corlib/System/MonoType.cs
trunk/mcs/class/corlib/Test/System/ChangeLog
trunk/mcs/class/corlib/Test/System/TypeTest.cs
Log:
In System:
2008-01-24 Rodrigo Kumpera <[EMAIL PROTECTED]>
* MonoType.cs (InvokeMember): Check for parameters without default
value which
the supplied argument is Missing.Value. Fixes one of the issues of
#348522.
In Test/System:
2008-01-24 Rodrigo Kumpera <[EMAIL PROTECTED]>
* TypeTest.cs (InvokeMember_WithoutDefaultValue): Added test for bug
#348522.
It call InvokeMember passing as method argument Missing.Value and a
binder that
returns a method that doesn't have a default value for it's parameter.
Modified: trunk/mcs/class/corlib/System/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System/ChangeLog 2008-01-24 22:11:38 UTC (rev
93849)
+++ trunk/mcs/class/corlib/System/ChangeLog 2008-01-24 22:16:22 UTC (rev
93850)
@@ -1,3 +1,8 @@
+2008-01-24 Rodrigo Kumpera <[EMAIL PROTECTED]>
+
+ * MonoType.cs (InvokeMember): Check for parameters without default
value which
+ the supplied argument is Missing.Value. Fixes one of the issues of
#348522.
+
2008-01-21 Sebastien Pouliot <[EMAIL PROTECTED]>
* DateTimeOffset.cs: Avoid NRE on bad cast if null is provided to
Modified: trunk/mcs/class/corlib/System/MonoType.cs
===================================================================
--- trunk/mcs/class/corlib/System/MonoType.cs 2008-01-24 22:11:38 UTC (rev
93849)
+++ trunk/mcs/class/corlib/System/MonoType.cs 2008-01-24 22:16:22 UTC (rev
93850)
@@ -386,6 +386,10 @@
throwMissingMethodDescription =
"Cannot find method " + name + ".";
} else {
ParameterInfo[] parameters =
m.GetParameters();
+ for (int i = 0; i < parameters.Length;
++i) {
+ if
(System.Reflection.Missing.Value == args [i] && (parameters [i].Attributes &
ParameterAttributes.HasDefault) != ParameterAttributes.HasDefault)
+ throw new
ArgumentException (parameters [i].Name);
+ }
bool hasParamArray = parameters.Length
> 0 ? Attribute.IsDefined (parameters [parameters.Length - 1],
typeof (ParamArrayAttribute)) :
false;
if (hasParamArray)
Modified: trunk/mcs/class/corlib/Test/System/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Test/System/ChangeLog 2008-01-24 22:11:38 UTC
(rev 93849)
+++ trunk/mcs/class/corlib/Test/System/ChangeLog 2008-01-24 22:16:22 UTC
(rev 93850)
@@ -1,3 +1,9 @@
+2008-01-24 Rodrigo Kumpera <[EMAIL PROTECTED]>
+
+ * TypeTest.cs (InvokeMember_WithoutDefaultValue): Added test for bug
#348522.
+ It call InvokeMember passing as method argument Missing.Value and a
binder that
+ returns a method that doesn't have a default value for it's parameter.
+
2008-01-21 Gert Driesen <[EMAIL PROTECTED]>
* AppDomainTest.cs: Added DefineDynamicAssembly tests for invalid
Modified: trunk/mcs/class/corlib/Test/System/TypeTest.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System/TypeTest.cs 2008-01-24 22:11:38 UTC
(rev 93849)
+++ trunk/mcs/class/corlib/Test/System/TypeTest.cs 2008-01-24 22:16:22 UTC
(rev 93850)
@@ -180,7 +180,50 @@
{
}
#endif
+ public class Bug348522
+ {
+ public void Test (int __argument)
+ {
+ }
+ }
+ public class FirstMethodBinder : Binder
+ {
+ public override MethodBase BindToMethod (BindingFlags
bindingAttr, MethodBase [] match, ref object [] args,
+ ParameterModifier []
modifiers, CultureInfo culture, string [] names,
+ out object state)
+ {
+ state = null;
+ return match [0];
+ }
+
+ public override object ChangeType (object value, Type type1,
CultureInfo culture)
+ {
+ return value;
+ }
+
+ // The rest is just to please the compiler
+ public override FieldInfo BindToField (BindingFlags a,
FieldInfo[] b, object c, CultureInfo d)
+ {
+ return null;
+ }
+
+ public override void ReorderArgumentArray(ref object[] a,
object b)
+ {
+ }
+
+ public override MethodBase SelectMethod(BindingFlags a,
MethodBase[] b, Type[] c, ParameterModifier[] d)
+ {
+ return null;
+ }
+
+ public override PropertyInfo SelectProperty(BindingFlags a,
PropertyInfo[] b, Type c, Type[] d, ParameterModifier[] e)
+ {
+ return null;
+ }
+ }
+
+
[TestFixture]
public class TypeTest
{
@@ -2044,6 +2087,24 @@
Assert.AreEqual ("#A:1|2,3,4", result, "#B2");
}
+
+ [Test] // bug #348522
+ public void InvokeMember_WithoutDefaultValue ()
+ {
+ BindingFlags flags = BindingFlags.Instance |
BindingFlags.Public | BindingFlags.InvokeMethod;;
+ try {
+ typeof (Bug348522).InvokeMember ("Test", flags,
new FirstMethodBinder (), new Bug348522(),
+ new object [] {Missing.Value}, null,
null, null);
+ Assert.Fail ("#1");
+ } catch (ArgumentException ex) {
+ Assert.AreEqual (typeof (ArgumentException),
ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("__argument", ex.ParamName,
"#6");
+ }
+ }
+
class X
{
public static int Value;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches