diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets index d437ace87292..956ace954fcc 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.targets @@ -554,6 +554,9 @@ - NativeAOT supported platforms in all configurations - ios/tvos device builds in all configurations - macOS/MacCatalyst builds in release configuration + (On .NET 11+ NativeAOT defaults to 'trimmable-static' instead - that's set earlier, at + evaluation time, in Xamarin.Shared.Sdk.props. The trimmable-static registrar is only smaller + under NativeAOT, so the other runtimes keep managed-static.) - Set 'partial-static' for: - when no assemblies are trimmed and when MarshalManagedExceptionMode is default (or not set) - Otherwise set 'dynamic' @@ -601,6 +604,21 @@ + + + + - @@ -1214,6 +1223,14 @@ $(_StrippedAssemblyDirectory)\%(ResolvedFileToPublish.OriginalRelativePath) + + <_AssembliesToBeStripped Condition="'%(_AssembliesToBeStripped.OriginalRelativePath)' == ''"> + $(_StrippedAssemblyDirectory)\%(Filename)%(Extension) + + diff --git a/tests/linker/link all/LinkAllTest.cs b/tests/linker/link all/LinkAllTest.cs index 2a36636ef7d6..e70abcec6855 100644 --- a/tests/linker/link all/LinkAllTest.cs +++ b/tests/linker/link all/LinkAllTest.cs @@ -508,6 +508,12 @@ public void LinkedAwayGenericTypeAsOptionalMemberInProtocol () if (!global::XamarinTests.ObjCRuntime.Registrar.IsTrimmableStaticRegistrar) Assert.Ignore ("This test only applies to the trimmable static registrar."); + // The [ProtocolMember] attributes (which reference NSSet) are only trimmed away when the dynamic + // registrar has been removed - it reads these attributes via reflection at runtime, so they're kept + // when it's present. Without trimming the attributes, NSSet stays too, so there's nothing to verify. + if (global::ObjCRuntime.Runtime.DynamicRegistrationSupported) + Assert.Ignore ("This test only applies when the dynamic registrar has been removed."); + // https://github.com/dotnet/macios/issues/3523 // Don't use constants here, because the linker can see what we're trying to do and keeps the type we're verifying has been removed. string prefix = NamespacePrefix;