Skip to content

Commit 7e25565

Browse files
rolfbjarneCopilot
andcommitted
[tests] Only assert NSSet<T> is trimmed when the dynamic registrar is removed.
The trimmable-static registrar only tells the trimmer to remove the [ProtocolMember] attributes (which reference generic types like NSSet<T> in optional protocol members) when the dynamic registrar has been removed - it reads these attributes via reflection at runtime, so they're kept when it's present. When the attributes aren't trimmed, NSSet<T> stays too, so the LinkedAwayGenericTypeAsOptionalMemberInProtocol test has nothing to verify. Ignore the test in that case (e.g. the prepare-assemblies|coreclr|trimmable- static-registrar variation on macOS, where DynamicRegistrationSupported is true), instead of failing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 592d722 commit 7e25565

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎tests/linker/link all/LinkAllTest.cs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,12 @@ public void LinkedAwayGenericTypeAsOptionalMemberInProtocol ()
508508
if (!global::XamarinTests.ObjCRuntime.Registrar.IsTrimmableStaticRegistrar)
509509
Assert.Ignore ("This test only applies to the trimmable static registrar.");
510510

511+
// The [ProtocolMember] attributes (which reference NSSet<T>) are only trimmed away when the dynamic
512+
// registrar has been removed - it reads these attributes via reflection at runtime, so they're kept
513+
// when it's present. Without trimming the attributes, NSSet<T> stays too, so there's nothing to verify.
514+
if (global::ObjCRuntime.Runtime.DynamicRegistrationSupported)
515+
Assert.Ignore ("This test only applies when the dynamic registrar has been removed.");
516+
511517
// https://github.com/dotnet/macios/issues/3523
512518
// 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.
513519
string prefix = NamespacePrefix;

0 commit comments

Comments
 (0)