[Mono-bugs] [Bug 490932] New: Nullable ByRef types do not work correctly via reflection
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Tue Mar 31 19:47:16 EDT 2009
https://bugzilla.novell.com/show_bug.cgi?id=490932
Summary: Nullable ByRef types do not work correctly via
reflection
Classification: Mono
Product: Mono: Class Libraries
Version: 2.4.x
Platform: x86
OS/Version: Windows XP
Status: NEW
Severity: Normal
Priority: P5 - None
Component: CORLIB
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: joe at mistachkin.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.20)
Gecko/20081217 Firefox/2.0.0.20 (.NET CLR 3.5.30729)
using System;
using System.Reflection;
namespace BugDemo
{
class Program
{
static void Main(string[] args)
{
object[] margs = new object[1];
int? x = null;
int? y = 0;
Console.WriteLine("x: \"{0}\", y: \"{1}\"", x, y);
BindingFlags flags = BindingFlags.Public | BindingFlags.Static |
BindingFlags.InvokeMethod;
MethodInfo method = typeof(Program).GetMethod(
"TestByRefNullableValueTypeMethod", flags);
margs[0] = x;
method.Invoke(null, margs);
x = margs[0] as int?;
margs[0] = y;
method.Invoke(null, margs);
y = margs[0] as int?;
Console.WriteLine("x: \"{0}\", y: \"{1}\"", x, y);
margs[0] = x;
typeof(Program).InvokeMember(
"TestByRefNullableValueTypeMethod",
flags, null, null, margs);
x = margs[0] as int?;
margs[0] = y;
typeof(Program).InvokeMember(
"TestByRefNullableValueTypeMethod",
flags, null, null, margs);
y = margs[0] as int?;
Console.WriteLine("x: \"{0}\", y: \"{1}\"", x, y);
Console.ReadKey();
}
public static void TestByRefNullableValueTypeMethod(ref int? x)
{
if (x != null) x++;
else x = 0;
}
}
}
Reproducible: Always
Steps to Reproduce:
Run the code listed above.
Actual Results:
x: "", y: "0"
x: "", y: "0"
Unhandled Exception: System.MissingMethodException: The best match for method
TestByRefNullableValueTypeMethod has some invalid parameter.
at System.MonoType.InvokeMember (System.String name, BindingFlags invokeAttr,
System.Reflection.Binder binder, System.Object target, System.Object[] args,
System.Reflection.ParameterModifier[] modifiers,
System.Globalization.CultureInfo culture, System.String[] namedParameters)
[0x00000]
at System.Type.InvokeMember (System.String name, BindingFlags invokeAttr,
System.Reflection.Binder binder, System.Object target, System.Object[] args)
[0x00000]
at BugDemo.Program.Main (System.String[] args) [0x00000]
Expected Results:
x: "", y: "0"
x: "0", y: "1"
x: "1", y: "2"
The binary used was compiled with Visual Studio 2008 SP1.
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list