From 43243a11582b946286df59a314cf360655c798f8 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 8 Apr 2019 07:50:10 +0200 Subject: [PATCH 01/11] [registrar] Use Selector.GetName instead of creating a new Selector instance just to get the name. (#5859) Saves a tiny bit of memory (one managed Selector instance for each time these methods are called). --- src/ObjCRuntime/DynamicRegistrar.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ObjCRuntime/DynamicRegistrar.cs b/src/ObjCRuntime/DynamicRegistrar.cs index 578d1fe40c..aaf34bf4a3 100644 --- a/src/ObjCRuntime/DynamicRegistrar.cs +++ b/src/ObjCRuntime/DynamicRegistrar.cs @@ -898,10 +898,10 @@ namespace Registrar { public void GetMethodDescriptionAndObject (Type type, IntPtr selector, bool is_static, IntPtr obj, ref IntPtr mthis, IntPtr desc) { - var sel = new Selector (selector); - var res = GetMethodNoThrow (type, type, sel.Name, is_static); + var sel = Selector.GetName (selector); + var res = GetMethodNoThrow (type, type, sel, is_static); if (res == null) - throw ErrorHelper.CreateError (8006, "Failed to find the selector '{0}' on the type '{1}'", sel.Name, type.FullName); + throw ErrorHelper.CreateError (8006, "Failed to find the selector '{0}' on the type '{1}'", sel, type.FullName); if (res.IsInstanceCategory) { mthis = IntPtr.Zero; @@ -919,10 +919,10 @@ namespace Registrar { public void GetMethodDescription (Type type, IntPtr selector, bool is_static, IntPtr desc) { - var sel = new Selector (selector); - var res = GetMethodNoThrow (type, type, sel.Name, is_static); + var sel = Selector.GetName (selector); + var res = GetMethodNoThrow (type, type, sel, is_static); if (res == null) - throw ErrorHelper.CreateError (8006, "Failed to find the selector '{0}' on the type '{1}'", sel.Name, type.FullName); + throw ErrorHelper.CreateError (8006, "Failed to find the selector '{0}' on the type '{1}'", sel, type.FullName); if (type.IsGenericType && res.Method is ConstructorInfo) throw ErrorHelper.CreateError (4133, "Cannot construct an instance of the type '{0}' from Objective-C because the type is generic.", type.FullName); From a9dc0c9120d3db59528b17464380706f55891d7b Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 8 Apr 2019 16:50:04 +0200 Subject: [PATCH 02/11] [src] Ask mono-cil-strip to be quiet. (#5864) --- src/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Makefile b/src/Makefile index bd66bb7471..1ea3099734 100644 --- a/src/Makefile +++ b/src/Makefile @@ -168,7 +168,7 @@ $(IOS_BUILD_DIR)/reference/System.Drawing.dll: $(IOS_SYSTEM_DRAWING_SOURCES) mon $(IOS_SYSTEM_DRAWING_SOURCES) $(IOS_BUILD_DIR)/reference/Xamarin.iOS.dll: $(IOS_BUILD_DIR)/native-64/Xamarin.iOS.dll | $(IOS_BUILD_DIR)/reference - $(Q_GEN) mono-cil-strip $< $@ + $(Q_STRIP) mono-cil-strip -q $< $@ $(IOS_BUILD_DIR)/reference/Xamarin.iOS.pdb: $(IOS_BUILD_DIR)/native-64/Xamarin.iOS.pdb | $(IOS_BUILD_DIR)/reference $(Q) $(CP) $< $@ @@ -750,7 +750,7 @@ $(WATCH_BUILD_DIR)/watch-32/Xamarin.WatchOS%dll $(WATCH_BUILD_DIR)/watch-32/Xama $(WATCHOS_SOURCES) @$(WATCH_BUILD_DIR)/watch/generated_sources $(WATCH_BUILD_DIR)/reference/Xamarin.WatchOS.dll: $(WATCH_BUILD_DIR)/watch-32/Xamarin.WatchOS.dll | $(WATCH_BUILD_DIR)/reference - $(Q_GEN) mono-cil-strip $< $@ + $(Q_STRIP) mono-cil-strip -q $< $@ $(WATCH_BUILD_DIR)/reference/Xamarin.WatchOS.pdb: $(WATCH_BUILD_DIR)/watch-32/Xamarin.WatchOS.pdb | $(WATCH_BUILD_DIR)/reference $(Q) $(CP) $< $@ @@ -958,7 +958,7 @@ $(TVOS_BUILD_DIR)/tvos-64/Xamarin.TVOS%dll $(TVOS_BUILD_DIR)/tvos-64/Xamarin.TVO $(TVOS_SOURCES) @$(TVOS_BUILD_DIR)/tvos/generated_sources $(TVOS_BUILD_DIR)/reference/Xamarin.TVOS.dll: $(TVOS_BUILD_DIR)/tvos-64/Xamarin.TVOS.dll | $(TVOS_BUILD_DIR)/reference - $(Q_GEN) mono-cil-strip $< $@ + $(Q_STRIP) mono-cil-strip -q $< $@ $(TVOS_BUILD_DIR)/reference/Xamarin.TVOS.pdb: $(TVOS_BUILD_DIR)/tvos-64/Xamarin.TVOS.pdb | $(TVOS_BUILD_DIR)/reference $(Q) $(CP) $< $@ From d98c22e39f847e46770643bc6dd7cba40db0daca Mon Sep 17 00:00:00 2001 From: Chris Hamons Date: Mon, 8 Apr 2019 10:26:23 -0500 Subject: [PATCH 03/11] [mmp] Don't apply libintl hack when you explicitly ask for that file (#5855) - A long while ago, this hack was added to mmp: // Shutup the warning until we decide on bug: 36478 if (shortendName.ToLowerInvariant () == "intl" && IsUnifiedFullXamMacFramework) - This breaks use cases were we explicitly ask for that file, so let's fix that for now until we can fix the root cause for real --- tests/mmptest/src/NativeReferencesTests.cs | 15 +++++++++++++++ tools/mmp/driver.cs | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/mmptest/src/NativeReferencesTests.cs b/tests/mmptest/src/NativeReferencesTests.cs index 93099ecb61..6d8a3c1e48 100644 --- a/tests/mmptest/src/NativeReferencesTests.cs +++ b/tests/mmptest/src/NativeReferencesTests.cs @@ -210,5 +210,20 @@ namespace Xamarin.MMP.Tests NativeReferenceTestCore (tmpDir, test, "MultipleNativeReferences_OnlyInvokeMMPOneTime_AndCopyEverythingIn", null, true); }); } + + + [Test] + public void ReferenceNativeRefNoCodeUsage_ShouldStillCopy () + { + MMPTests.RunMMPTest (tmpDir => { + TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) { + XM45 = true, + ItemGroup = CreateSingleNativeRef ("/Library/Frameworks/Mono.framework/Libraries/libintl.dylib", "Dynamic") + }; + var log = TI.TestUnifiedExecutable (test); + Console.WriteLine (log.BuildOutput); + Assert.True (File.Exists (Path.Combine (tmpDir, "bin/Debug/XM45Example.app/Contents/MonoBundle/libintl.dylib"))); + }); + } } } diff --git a/tools/mmp/driver.cs b/tools/mmp/driver.cs index c73d0f0452..79d096c113 100644 --- a/tools/mmp/driver.cs +++ b/tools/mmp/driver.cs @@ -1616,7 +1616,7 @@ namespace Xamarin.Bundler { return true; } // Shutup the warning until we decide on bug: 36478 - if (shortendName.ToLowerInvariant () == "intl" && IsUnifiedFullXamMacFramework) + if (shortendName.ToLowerInvariant () == "intl" && !native_references.Any (x => x.Contains ("libintl.dylib")) && IsUnifiedFullXamMacFramework) return true; return false; } From af9645410f4576d5d7a156e724f029a2002552b4 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 8 Apr 2019 17:27:54 +0200 Subject: [PATCH 04/11] [ObjCRuntime] Add helper functions for resolving type/method tokens. (#5865) This reduces code duplication a little bit. --- src/ObjCRuntime/Blocks.cs | 2 +- src/ObjCRuntime/Class.cs | 30 ++++++++++++++++++++++++------ src/ObjCRuntime/Runtime.cs | 19 +++++-------------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/ObjCRuntime/Blocks.cs b/src/ObjCRuntime/Blocks.cs index 59e4480fce..206cc4eea4 100644 --- a/src/ObjCRuntime/Blocks.cs +++ b/src/ObjCRuntime/Blocks.cs @@ -259,7 +259,7 @@ namespace ObjCRuntime { baseMethod = null; if (token_ref != Runtime.INVALID_TOKEN_REF) - return (Type) Class.ResolveTokenReference (token_ref, 0x02000000 /* TypeDef */); + return Class.ResolveTypeTokenReference (token_ref); baseMethod = minfo.GetBaseDefinition (); var delegateProxies = baseMethod.ReturnTypeCustomAttributes.GetCustomAttributes (typeof (DelegateProxyAttribute), false); diff --git a/src/ObjCRuntime/Class.cs b/src/ObjCRuntime/Class.cs index 749a805a7a..1167ec46bc 100644 --- a/src/ObjCRuntime/Class.cs +++ b/src/ObjCRuntime/Class.cs @@ -347,11 +347,7 @@ namespace ObjCRuntime { // Resolve the map entry we found to a managed type var type_reference = map->map [mapIndex].type_reference; - var member = ResolveTokenReference (type_reference, 0x02000000); - type = member as Type; - - if (type == null && member != null) - throw ErrorHelper.CreateError (8022, $"Expected the token reference 0x{type_reference:X} to be a type, but it's a {member.GetType ().Name}. Please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new."); + type = ResolveTypeTokenReference (type_reference); #if LOG_TYPELOAD Console.WriteLine ($"FindType (0x{@class:X} = {Marshal.PtrToStringAuto (class_getName (@class))}) => {type.FullName}; is custom: {is_custom_type} (token reference: 0x{type_reference:X})."); @@ -379,7 +375,29 @@ namespace ObjCRuntime { return ResolveToken (module, token); } - internal unsafe static MemberInfo ResolveTokenReference (uint token_reference, uint implicit_token_type) + internal static Type ResolveTypeTokenReference (uint token_reference) + { + var member = ResolveTokenReference (token_reference, 0x02000000 /* TypeDef */); + if (member == null) + return null; + if (member is Type type) + return type; + + throw ErrorHelper.CreateError (8022, $"Expected the token reference 0x{token_reference:X} to be a type, but it's a {member.GetType ().Name}. Please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new."); + } + + internal static MethodBase ResolveMethodTokenReference (uint token_reference) + { + var member = ResolveTokenReference (token_reference, 0x06000000 /* Method */); + if (member == null) + return null; + if (member is MethodBase method) + return method; + + throw ErrorHelper.CreateError (8022, $"Expected the token reference 0x{token_reference:X} to be a method, but it's a {member.GetType ().Name}. Please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new."); + } + + unsafe static MemberInfo ResolveTokenReference (uint token_reference, uint implicit_token_type) { var map = Runtime.options->RegistrationMap; diff --git a/src/ObjCRuntime/Runtime.cs b/src/ObjCRuntime/Runtime.cs index 12c3f6308d..4398c712d7 100644 --- a/src/ObjCRuntime/Runtime.cs +++ b/src/ObjCRuntime/Runtime.cs @@ -657,12 +657,7 @@ namespace ObjCRuntime { static unsafe IntPtr GetMethodFromToken (uint token_ref) { - var method = Class.ResolveTokenReference (token_ref, 0x06000000); - - var mb = method as MethodBase; - if (method != null && mb == null) - throw ErrorHelper.CreateError (8022, $"Expected the token reference 0x{token_ref:X} to be a method, but it's a {method.GetType ().Name}. Please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new."); - + var method = Class.ResolveMethodTokenReference (token_ref); if (method != null) return ObjectWrapper.Convert (method); @@ -671,19 +666,15 @@ namespace ObjCRuntime { static unsafe IntPtr GetGenericMethodFromToken (IntPtr obj, uint token_ref) { - var method = Class.ResolveTokenReference (token_ref, 0x06000000); + var method = Class.ResolveMethodTokenReference (token_ref); if (method == null) return IntPtr.Zero; - var mb = method as MethodBase; - if (mb == null) - throw ErrorHelper.CreateError (8022, $"Expected the token reference 0x{token_ref:X} to be a method, but it's a {method.GetType ().Name}. Please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new."); - var nsobj = ObjectWrapper.Convert (obj) as NSObject; if (nsobj == null) - throw ErrorHelper.CreateError (8023, $"An instance object is required to construct a closed generic method for the open generic method: {mb.DeclaringType.FullName}.{mb.Name} (token reference: 0x{token_ref:X}). Please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new."); + throw ErrorHelper.CreateError (8023, $"An instance object is required to construct a closed generic method for the open generic method: {method.DeclaringType.FullName}.{method.Name} (token reference: 0x{token_ref:X}). Please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new."); - return ObjectWrapper.Convert (FindClosedMethod (nsobj.GetType (), mb)); + return ObjectWrapper.Convert (FindClosedMethod (nsobj.GetType (), method)); } static IntPtr TryGetOrConstructNSObjectWrapped (IntPtr ptr) @@ -1480,7 +1471,7 @@ namespace ObjCRuntime { if (token != INVALID_TOKEN_REF) { var wrapper_token = xamarin_find_protocol_wrapper_type (token); if (wrapper_token != INVALID_TOKEN_REF) - return (Type)Class.ResolveTokenReference (wrapper_token, 0x02000000 /* TypeDef */); + return Class.ResolveTypeTokenReference (wrapper_token); } } } From c9b834ddaaf5b4b7e65fd4fdee6a7b63e4a555bf Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Mon, 8 Apr 2019 19:22:22 +0200 Subject: [PATCH 05/11] [XHarness] Use better names for BCL watchOS tests. (#5867) Ensure we do not use the target dir because that does not represent the name of the test because it is shared by all of them. Fixes https://github.com/xamarin/xamarin-macios/issues/5157 --- tests/xharness/WatchOSTarget.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/xharness/WatchOSTarget.cs b/tests/xharness/WatchOSTarget.cs index 8e6a7e033b..5f29b40de0 100644 --- a/tests/xharness/WatchOSTarget.cs +++ b/tests/xharness/WatchOSTarget.cs @@ -209,7 +209,10 @@ namespace xharness protected override void CalculateName () { - base.CalculateName (); + if (TargetDirectory.Contains ("BCLTests")) + Name = TestProject.Name; + else + base.CalculateName (); if (MonoNativeInfo != null) Name = Name + MonoNativeInfo.FlavorSuffix; } From 6e2eddd328b8029adee2c556a88ce07a9273bcd6 Mon Sep 17 00:00:00 2001 From: Alex Soto Date: Tue, 9 Apr 2019 05:35:08 -0400 Subject: [PATCH 06/11] [devops] Add azure devops build support (#5873) --- tools/devops/azure-pipelines.yml | 93 ++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 tools/devops/azure-pipelines.yml diff --git a/tools/devops/azure-pipelines.yml b/tools/devops/azure-pipelines.yml new file mode 100644 index 0000000000..fdbb7ccde6 --- /dev/null +++ b/tools/devops/azure-pipelines.yml @@ -0,0 +1,93 @@ +trigger: + - master + +jobs: +- job: macOS + displayName: xamarin macios + timeoutInMinutes: 120 + + pool: + name: "Hosted Mac Internal Mojave" + + steps: + - task: InstallSSHKey@0 + inputs: + hostName: $(github-hostname) + sshPublicKey: $(github-pubkey) + sshPassphrase: $(github-sec) + sshKeySecureFile: $(github-file) + + - bash: | + echo "Setting up maccore..." + ./configure --enable-xamarin + make reset-maccore + displayName: "Setting up maccore..." + + - bash: | + echo "Setting up prerequisites from brew..." + brew install libtool autoconf automake bison flex + displayName: "Setting up prerequisites from brew..." + + - task: xamops.azdevex.provisionator-task.provisionator@1 + displayName: Provisionate external-deps.csx + inputs: + provisioning_script: $(System.DefaultWorkingDirectory)/../maccore/tools/devops/external-deps.csx + provisioning_extra_args: '-vvvv' + + - bash: | + echo "Setting up build system dependencies..." + ./system-dependencies.sh --provision-all + displayName: "Setting up build system dependencies..." + + - bash: | + echo "Build the World..." + ln -sf $SYSTEM_DEFAULTWORKINGDIRECTORY $SYSTEM_DEFAULTWORKINGDIRECTORY/../xamarin-macios + make world + displayName: "Build the World..." + + - bash: | + echo "Create Packages..." + rm -Rf ../package + make package + cp ../package/*.* $BUILD_ARTIFACTSTAGINGDIRECTORY + displayName: "Create Packages..." + + - task: PublishBuildArtifacts@1 + inputs: + artifactName: "macios-packages" + + - task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0 + displayName: "Component Detection" + +# CredScan is Windows Only +- job: Windows + displayName: "CredScan - No Build" + + pool: + vmImage: "vs2017-win2016" + + steps: + - task: InstallSSHKey@0 + inputs: + hostName: $(github-hostname) + sshPublicKey: $(github-pubkey) + sshPassphrase: $(github-sec) + sshKeySecureFile: $(github-file) + + - bash: | + echo "Setting up maccore..." + repo=$(grep -m 1 "MACCORE_MODULE" "$SYSTEM_DEFAULTWORKINGDIRECTORY/mk/xamarin.mk" | cut -d'=' -f2 | awk '{$1=$1};1') + branch=$(grep "NEEDED_MACCORE_BRANCH" "$SYSTEM_DEFAULTWORKINGDIRECTORY/mk/xamarin.mk" | cut -d'=' -f2 | awk '{$1=$1};1') + git clone -b $branch $repo $SYSTEM_DEFAULTWORKINGDIRECTORY/../maccore + displayName: "Setting up maccore..." + + - task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2 + displayName: "Run CredScan" + inputs: + suppressionsFile: "$(System.DefaultWorkingDirectory)/../maccore/tools/devops/CredScanSuppressions.json" + debugMode: false + + - task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@1 + displayName: 'Post Analysis' + inputs: + CredScan: true From dc697dd5ef4cbb216b2ed9f87453aadbda6f44c4 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Tue, 9 Apr 2019 12:57:27 +0200 Subject: [PATCH 07/11] [XHarness] Ignore monotouch_Microsoft.CSharp_xunit-test.dll until issue 5868 is fixed. (#5869) If not ignored, we will have an issue building the test app on device resulting on a failure. --- .../bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs index a1e8bcd06e..83e92973ea 100644 --- a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs +++ b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs @@ -135,6 +135,7 @@ namespace BCLTestImporter { "monotouch_Mono.CodeContracts_test.dll", // not supported by xamarin "monotouch_Novell.Directory.Ldap_test.dll", // not supported by xamarin "monotouch_Mono.Profiler.Log_xunit-test.dll", // special tests that need an extra app to connect as a profiler + "monotouch_Microsoft.CSharp_xunit-test.dll", // mono-cil-strip fails due to an exception from cecil, issue https://github.com/xamarin/xamarin-macios/issues/5868 }; // list of assemblies that are going to be ignored, any project with an assemblies that is ignored will From 1d4e434eb5a14ff42ac01dbbbf6b5572476cfc0d Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 9 Apr 2019 14:34:51 +0200 Subject: [PATCH 08/11] [tests][test-libraries] Fix struct declarations to not create symbols everywhere. (#5876) This fixes a build problem with the interdependent-binding-projects test: clang : error : linker command failed with exit code 1 (use -v to see invocation) [.../tests/xharness/tmp-test-dir/interdependent-binding-projects2601/interdependent-binding-projects-tvos.csproj] MTOUCH : error MT5212: Native linking failed, duplicate symbol: '_Sssss'. [.../tests/xharness/tmp-test-dir/interdependent-binding-projects2601/interdependent-binding-projects-tvos.csproj] MTOUCH : error MT5212: Native linking failed, duplicate symbol: '_Ssss'. [.../tests/xharness/tmp-test-dir/interdependent-binding-projects2601/interdependent-binding-projects-tvos.csproj] MTOUCH : error MT5212: Native linking failed, duplicate symbol: '_Sss'. [.../tests/xharness/tmp-test-dir/interdependent-binding-projects2601/interdependent-binding-projects-tvos.csproj] --- tests/test-libraries/testgenerator.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test-libraries/testgenerator.cs b/tests/test-libraries/testgenerator.cs index 7cc8312b34..a896f0966b 100644 --- a/tests/test-libraries/testgenerator.cs +++ b/tests/test-libraries/testgenerator.cs @@ -156,7 +156,8 @@ static class C { for (int i = 0; i < s.Length; i++) { w.Append (GetNativeName (s [i])).Append (" x").Append (i).Append ("; "); } - w.AppendLine ($"}} S{s};"); + w.AppendLine ($"}};"); + w.AppendLine ($"typedef struct S{s} S{s};"); } File.WriteAllText ("libtest.structs.h", w.ToString ()); From 8792992b79473501ad4bcd33855c9d062ece67f4 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 9 Apr 2019 16:47:33 +0200 Subject: [PATCH 09/11] [registrar] Make Runtime.GetINativeObject_Static take token references instead of type names. (#5879) Saves some space in the executable by using 32-bit sized integers instead of much longer strings. --- runtime/delegates.t4 | 4 ++-- src/ObjCRuntime/Runtime.cs | 6 +++--- tools/common/StaticRegistrar.cs | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/runtime/delegates.t4 b/runtime/delegates.t4 index 464b0ba1af..fb82c3f9b0 100644 --- a/runtime/delegates.t4 +++ b/runtime/delegates.t4 @@ -170,8 +170,8 @@ new XDelegate ("MonoObject *", "IntPtr", "xamarin_get_inative_object_static", "id", "IntPtr", "obj", "bool", "bool", "owns", - "const char *", "string", "type_name", - "const char *", "string", "iface_name" + "unsigned int", "uint", "iface_token_ref", + "unsigned int", "uint", "implementation_token_ref" ) { WrappedManagedFunction = "GetINativeObject_Static", OnlyDynamicUsage = false, diff --git a/src/ObjCRuntime/Runtime.cs b/src/ObjCRuntime/Runtime.cs index 4398c712d7..63edc7def0 100644 --- a/src/ObjCRuntime/Runtime.cs +++ b/src/ObjCRuntime/Runtime.cs @@ -692,14 +692,14 @@ namespace ObjCRuntime { return ObjectWrapper.Convert (GetINativeObject (ptr, owns, type)); } - static IntPtr GetINativeObject_Static (IntPtr ptr, bool owns, string typename, string ifacename) + static IntPtr GetINativeObject_Static (IntPtr ptr, bool owns, uint iface_token, uint implementation_token) { /* * This method is called from generated code from the static registrar. */ - var iface = Type.GetType (ifacename, true); - var type = Type.GetType (typename, true); + var iface = Class.ResolveTypeTokenReference (iface_token); + var type = Class.ResolveTypeTokenReference (implementation_token); return ObjectWrapper.Convert (GetINativeObject (ptr, owns, iface, type)); } diff --git a/tools/common/StaticRegistrar.cs b/tools/common/StaticRegistrar.cs index 68f7a4ff87..2799b4d1f5 100644 --- a/tools/common/StaticRegistrar.cs +++ b/tools/common/StaticRegistrar.cs @@ -3569,7 +3569,8 @@ namespace Registrar { if (nativeObjType.IsInterface) { - setup_call_stack.AppendLine ("mobj{0} = xamarin_get_inative_object_static (nobj, false, \"{1}\", \"{2}\");", i, GetAssemblyQualifiedName (nativeObjType), GetAssemblyQualifiedName (elementType)); + setup_call_stack.AppendLine ("mobj{0} = xamarin_get_inative_object_static (nobj, false, 0x{1:X} /* {2} */, 0x{3:X} /* {4} */, &exception_gchandle);", i, CreateTokenReference (elementType, TokenType.TypeDef), elementType.FullName, CreateTokenReference (nativeObjType, TokenType.TypeDef), nativeObjType.FullName); + setup_call_stack.AppendLine ("if (exception_gchandle != 0) goto exception_handling;"); } else { // find the MonoClass for this parameter setup_call_stack.AppendLine ("MonoType *type{0};", i); @@ -3675,7 +3676,7 @@ namespace Registrar { if (isOut) { setup_call_stack.AppendLine ("inobj{0} = NULL;", i); } else if (td.IsInterface) { - setup_call_stack.AppendLine ("inobj{0} = xamarin_get_inative_object_static (*p{0}, false, \"{1}\", \"{2}\", &exception_gchandle);", i, GetAssemblyQualifiedName (nativeObjType), GetAssemblyQualifiedName (td)); + setup_call_stack.AppendLine ("inobj{0} = xamarin_get_inative_object_static (*p{0}, false, 0x{1:X} /* {2} */, 0x{3:X} /* {4} */, &exception_gchandle);", i, CreateTokenReference (td, TokenType.TypeDef), td.FullName, CreateTokenReference (nativeObjType, TokenType.TypeDef), nativeObjType.FullName); setup_call_stack.AppendLine ("if (exception_gchandle != 0) goto exception_handling;"); } else { setup_call_stack.AppendLine ("inobj{0} = xamarin_get_inative_object_dynamic (*p{0}, false, mono_type_get_object (mono_domain_get (), type{0}), &exception_gchandle);", i); @@ -3689,7 +3690,7 @@ namespace Registrar { copyback.AppendLine ("*p{0} = (id) handle{0};", i); } else { if (td.IsInterface) { - setup_call_stack.AppendLine ("arg_ptrs [{0}] = xamarin_get_inative_object_static (p{0}, false, \"{1}\", \"{2}\", &exception_gchandle);", i, GetAssemblyQualifiedName (nativeObjType), GetAssemblyQualifiedName (td)); + setup_call_stack.AppendLine ("arg_ptrs [{0}] = xamarin_get_inative_object_static (p{0}, false, 0x{1:X} /* {2} */, 0x{3:X} /* {4} */, &exception_gchandle);", i, CreateTokenReference (td, TokenType.TypeDef), td.FullName, CreateTokenReference (nativeObjType, TokenType.TypeDef), nativeObjType.FullName); } else { setup_call_stack.AppendLine ("arg_ptrs [{0}] = xamarin_get_inative_object_dynamic (p{0}, false, mono_type_get_object (mono_domain_get (), type{0}), &exception_gchandle);", i); } From 0e8423e2ddbf433333789a9c356ae328f7252373 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 9 Apr 2019 16:48:18 +0200 Subject: [PATCH 10/11] [TVMLKit] Work around Apple breaking API for enum values in TVElementUpdateType. (#5849) * [TVMLKit] Work around Apple breaking API for enum values in TVElementUpdateType. Reference: https://trello.com/c/Eyox7vlH/118-41123682-tvelementupdatetype-enum-values-changed Reference: rdar://41123682 (closed as by design) * Use this workaround even after XAMCORE_4_0. Apple's breaking changes don't disappear in XAMCORE_4_0. * Fix compiler warnings and Export attribute location. --- src/TVMLKit/TVViewElement.cs | 34 ++++++++++++++++++++++++++++++++++ src/tvmlkit.cs | 10 +++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/TVMLKit/TVViewElement.cs b/src/TVMLKit/TVViewElement.cs index e49dbd2f93..bc0015d5c4 100644 --- a/src/TVMLKit/TVViewElement.cs +++ b/src/TVMLKit/TVViewElement.cs @@ -1,6 +1,7 @@ using System; using Foundation; using ObjCRuntime; +using UIKit; namespace TVMLKit { @@ -16,6 +17,39 @@ namespace TVMLKit { public bool IsDispatched { get; set; } public bool IsCancelled { get; set; } +#endif + } + + public partial class TVViewElement { +#if !COREBUILD + public virtual TVElementUpdateType UpdateType { + [Export ("updateType")] + get { + var value = _UpdateType; + switch ((long) value) { + case 2: + if (UIDevice.CurrentDevice.CheckSystemVersion (12, 0)) { + return TVElementUpdateType.Styles; + } else { + return TVElementUpdateType.Children; + } + case 3: + if (UIDevice.CurrentDevice.CheckSystemVersion (12, 0)) { + return TVElementUpdateType.Children; + } else { + return TVElementUpdateType.Self; + } + case 4: + if (UIDevice.CurrentDevice.CheckSystemVersion (12, 0)) { + return TVElementUpdateType.Self; + } else { + return TVElementUpdateType.Styles; + } + default: + return value; + } + } + } #endif } } diff --git a/src/tvmlkit.cs b/src/tvmlkit.cs index ea1fc27745..75427de9f6 100644 --- a/src/tvmlkit.cs +++ b/src/tvmlkit.cs @@ -86,10 +86,17 @@ namespace TVMLKit { public enum TVElementUpdateType : long { None, Subtree, +#if XAMCORE_4_0 + [TV (10,0)] + Styles, + Children, + Self, +#else Children, Self, [TV (10,0)] Styles, +#endif } [TV (9,0)] @@ -819,8 +826,9 @@ namespace TVMLKit { set; } + [Internal][Sealed] [Export ("updateType")] - TVElementUpdateType UpdateType { get; } + TVElementUpdateType _UpdateType { get; } [Export ("resetProperty:")] void Reset (TVElementResettableProperty resettableProperty); From da007e5781f12deb56dfb2d7d4ad0d330d12ecd9 Mon Sep 17 00:00:00 2001 From: Vincent Dondain Date: Tue, 9 Apr 2019 12:56:24 -0400 Subject: [PATCH 11/11] Bump maccore to improve beta device testing (#5874) --- mk/xamarin.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/xamarin.mk b/mk/xamarin.mk index 2122b5e0fa..5515de582a 100644 --- a/mk/xamarin.mk +++ b/mk/xamarin.mk @@ -1,5 +1,5 @@ ifdef ENABLE_XAMARIN -NEEDED_MACCORE_VERSION := b1322257641d4059e0eb5ae9f17ebfa0d2232b80 +NEEDED_MACCORE_VERSION := 9eef60828aa36655aeae220143e8d088e0f073ce NEEDED_MACCORE_BRANCH := master MACCORE_DIRECTORY := maccore