From 911eab97b75b48eb4e490a9c7fcdd4e54a9c0038 Mon Sep 17 00:00:00 2001 From: Alex Soto Date: Wed, 14 Jun 2017 14:42:07 -0500 Subject: [PATCH] [registrar] BindAs uses Nullable types so allow them to be registered as NSObjects BindAsAttribute allows to bind NSValue and NSNumber into more accurate C# types lyke bool?, int? etc. so we must teach registrar about this. --- src/ObjCRuntime/Registrar.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ObjCRuntime/Registrar.cs b/src/ObjCRuntime/Registrar.cs index 274b121ca7..8c5cd62a2f 100644 --- a/src/ObjCRuntime/Registrar.cs +++ b/src/ObjCRuntime/Registrar.cs @@ -2130,7 +2130,9 @@ namespace XamCore.Registrar { { bool isNativeEnum; - switch (GetTypeFullName (type)) { + var typeFullName = GetTypeFullName (type); + + switch (typeFullName) { case "System.IntPtr": return "^v"; case "System.SByte": return "c"; case "System.Byte": return "C"; @@ -2163,6 +2165,10 @@ namespace XamCore.Registrar { throw CreateException (4102, member, "The registrar found an invalid type `{0}` in signature for method `{2}`. Use `{1}` instead.", "System.DateTime", IsDualBuild ? "Foundation.NSDate" : CompatNamespace + ".Foundation.NSDate", member.FullName); } + // We use BindAsAttribute to wrap NSNumber/NSValue into more accurate Nullable types + if (typeFullName != null && typeFullName.Contains ("Nullable")) + return "@"; + if (Is (type, ObjCRuntime, "Selector")) return ":";