http://bugzilla.novell.com/show_bug.cgi?id=567351
http://bugzilla.novell.com/show_bug.cgi?id=567351#c0 Summary: Cannot SetValue of Nullable Property Classification: Mono Product: MonoTouch Version: unspecified Platform: Macintosh OS/Version: Mac OS X 10.5 Status: NEW Severity: Critical Priority: P5 - None Component: Runtime AssignedTo: [email protected] ReportedBy: [email protected] QAContact: [email protected] Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 MonoTouch throws an exeception when trying to set a value of a nullable property via reflection. (NOTE: This issue was reported on the Monotouch list in November 09.) Reproducible: Always Steps to Reproduce: Run the code in "Additional Information." Actual Results: The following exception is thrown for all nullable properties: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ExecutionEngineException: Attempting to JIT compile method '(wrapper runtime-invoke) Expected Results: No exception. // This code illustrates the problem. namespace ShowSetValueNullableBug { public class Application { static Foo foo = new Foo(); static void Main (string[] args) { TrySetValue<string>("String"); TrySetValue<int>("Int"); TrySetValue<bool>("Bool"); TrySetValue<DateTime>("DateTime"); TrySetValue<decimal>("Decimal"); TrySetValue<double>("Double"); TrySetValue<long>("Long"); TrySetValue<byte>("Byte"); TrySetValue<float>("Float"); TrySetValue<char>("Char"); TrySetValue<short>("Short"); TrySetValue<uint>("UInt"); TrySetValue<ulong>("ULong"); TrySetValue<ushort>("UShort"); TrySetValue<MyEnum>("Enum"); TrySetValue<TimeSpan>("TimeSpan"); TrySetValue<int?>("NullableInt"); TrySetValue<bool?>("NullableBool"); TrySetValue<DateTime?>("NullableDateTime"); TrySetValue<decimal?>("NullableDecimal"); TrySetValue<double?>("NullableDouble"); TrySetValue<long?>("NullableLong"); TrySetValue<byte?>("NullableByte"); TrySetValue<char?>("NullableChar"); TrySetValue<short?>("NullableShort"); TrySetValue<uint?>("NullableUInt"); TrySetValue<ulong?>("NullableULong"); TrySetValue<ushort?>("NullableUShort"); TrySetValue<TimeSpan?>("NullableTimeSpan"); TrySetValue<MyEnum>("NullableEnum"); UIApplication.Main (args); } private static void TrySetValue<T>(string propertyName) { var propertyInfo = typeof(Foo).GetProperty(propertyName); try { propertyInfo.SetValue(foo, default(T), null); Console.WriteLine(string.Format("Set value of {0} succeeds!", propertyName)); } catch (Exception ex) { Console.WriteLine(string.Format("Set value of {0} FAILS!", propertyName)); } } } public class Foo { public string String { get; set; } public int Int { get; set; } public bool Bool { get; set; } public DateTime DateTime { get; set; } public decimal Decimal { get; set; } public double Double { get; set; } public long Long { get; set; } public byte Byte { get; set; } public float Float { get; set; } public char Char { get; set; } public short Short { get; set; } public uint UInt { get; set; } public ulong ULong { get; set; } public ushort UShort { get; set; } public MyEnum Enum { get; set; } public TimeSpan TimeSpan { get; set; } public int? NullableInt { get; set; } public bool? NullableBool { get; set; } public DateTime? NullableDateTime { get; set; } public decimal? NullableDecimal { get; set; } public double? NullableDouble { get; set; } public long? NullableLong { get; set; } public byte? NullableByte { get; set; } public float? NullableFloat { get; set; } public char? NullableChar { get; set; } public short? NullableShort { get; set; } public uint? NullableUInt { get; set; } public ulong? NullableULong { get; set; } public ushort? NullableUShort { get; set; } public TimeSpan? NullableTimeSpan { get; set; } public MyEnum? NullableEnum { get; set; } } public enum MyEnum { One } public partial class AppDelegate : UIApplicationDelegate { public override bool FinishedLaunching (UIApplication app, NSDictionary options) { window.MakeKeyAndVisible (); return true; } public override void OnActivated (UIApplication application) { } } } -- Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
