Skip to content

Clean up SkipUnresolved handling in linker test framework.#124972

Merged
sbomer merged 1 commit intodotnet:mainfrom
Unity-Technologies:linker-cleanup-skip-unresolved
Mar 2, 2026
Merged

Clean up SkipUnresolved handling in linker test framework.#124972
sbomer merged 1 commit intodotnet:mainfrom
Unity-Technologies:linker-cleanup-skip-unresolved

Conversation

@mrvoorhe
Copy link
Contributor

  • The default value of SkipUnresolved in the test framework was false. This doesn't align with the default value used by ILLink itself which is true.

  • When SkipUnresolved was false, AddSkipUnresolved would do nothing. This meant that tests that explicitly try to use false wouldn't actually run with SkipUnresolved=False. Instead the linker would run with it's default value of true.

  • Switch SkipUnresolved tests to use the attribute. Using the attribute ensures that we either get the default value or the value the test requested.

* The default value of `SkipUnresolved` in the test framework was false.  This doesn't align with the default value used by ILLink itself which is true.

* When `SkipUnresolved` was false, `AddSkipUnresolved` would do nothing.  This meant that tests that explicitly try to use false wouldn't actually run with SkipUnresolved=False.  Instead the linker would run with it's default value of `true`.

* Switch SkipUnresolved tests to use the attribute.  Using the attribute ensures that we either get the default value or the value the test requested.
@mrvoorhe mrvoorhe requested a review from sbomer as a code owner February 27, 2026 14:43
Copilot AI review requested due to automatic review settings February 27, 2026 14:43
@mrvoorhe
Copy link
Contributor Author

@sbomer please take a look

@github-actions github-actions bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Feb 27, 2026
@dotnet-policy-service dotnet-policy-service bot added linkable-framework Issues associated with delivering a linker friendly framework community-contribution Indicates that the PR has been added by a community member labels Feb 27, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @agocke, @dotnet/illink
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the ILLink linker test framework to make SkipUnresolved handling consistent with ILLink’s own default (true) and ensures tests that request SkipUnresolved=false actually run with that value.

Changes:

  • Change the test framework default for SkipUnresolved to true to match ILLink.
  • Always emit --skip-unresolved <bool> in the generated linker arguments so false is honored.
  • Migrate affected test cases from raw SetupLinkerArgument("--skip-unresolved", ...) usage to the dedicated [SkipUnresolved(...)] attribute.

Reviewed changes

Copilot reviewed 58 out of 58 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TrimmingArgumentBuilder.cs Always emits --skip-unresolved with an explicit boolean value.
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadataProvider.cs Changes default SkipUnresolved option to true.
src/tools/illink/test/Mono.Linker.Tests.Cases/UnreachableBody/LinkedOtherIncludedLibraryNoInstanceCtor.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/UnreachableBody/DoesNotApplyToCopiedAssembly2.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/UnreachableBlock/UninitializedLocals.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/UnreachableBlock/EndScopeOnMethoEnd.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/TypeForwarding/TypeForwardersRewrite.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/TypeForwarding/TypeForwardersModifiers.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/TypeForwarding/SecurityAttributeScope.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/TestFramework/ILVerificationWorks.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/TestFramework/ILVerificationErrorsCanBeIgnored.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/TestFramework/CanCompileILAssembly.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Symbols/ReferencesWithMixedSymbolTypesWithMdbAndSymbolLinkingEnabled.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Symbols/ReferencesWithMixedSymbolTypesAndSymbolLinkingEnabled.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Symbols/ReferencesWithMixedSymbolTypes.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPdbDeleteActionAndSymbolLinkingEnabled.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPdbDeleteAction.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPdbCopyAction.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPdbAndSymbolLinkingEnabledAndNewMvid.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPdbAndSymbolLinkingEnabledAndDeterministicMvid.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPdbAndSymbolLinkingEnabled.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithPdb.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithMdbDeleteActionAndSymbolLinkingEnabled.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithMdbDeleteAction.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithMdbCopyAction.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Symbols/ReferenceWithMdb.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/References/MissingReferenceInUsedCodePath.cs Uses [SkipUnresolved(false)] to ensure the test runs with skipping disabled.
src/tools/illink/test/Mono.Linker.Tests.Cases/References/MissingReferenceInUnusedCodePath.cs Uses [SkipUnresolved(false)] to ensure the test runs with skipping disabled.
src/tools/illink/test/Mono.Linker.Tests.Cases/References/Individual/CanSkipUnresolved.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/PreserveDependencies/PreserveDependencyErrorCases.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/LinkXml/LinkXmlErrorCases.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/LinkAttributes/LinkAttributeErrorCases.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Libraries/LibraryWithUnresolvedInterfaces.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/StaticInterfaceMethods/InstanceMethodsWithOverridesSwept.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/RecursiveInterfaces/OverrideOfRecursiveInterfaceIsRemoved.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/RecursiveInterfaces/InterfaceImplementedRecursively.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/RecursiveInterfaces/GenericInterfaceImplementedRecursively.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/OnReferenceType/NoInstanceCtor/NoInstanceCtorAndTypePreserveNone.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/OnReferenceType/NoInstanceCtor/NoInstanceCtorAndTypePreserveMethodsWithInterfacesMarked.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/OnReferenceType/NoInstanceCtor/NoInstanceCtorAndTypePreserveMethods.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/OnReferenceType/NoInstanceCtor/NoInstanceCtorAndTypePreserveFieldsWithInterfacesMarked.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/OnReferenceType/NoInstanceCtor/NoInstanceCtorAndTypePreserveFields.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/OnReferenceType/NoInstanceCtor/NoInstanceCtorAndTypePreserveAll.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/OnReferenceType/NoInstanceCtor/NoInstanceCtorAndAssemblyPreserveAll.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/InterfaceImplementedThroughBaseInterface.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/DefaultInterfaceMethods/StaticDimProvidedByUnreferencedIfaceInHierarchy.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/DefaultInterfaceMethods/MultipleDimsProvidedByRecursiveInterface.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/DefaultInterfaceMethods/InterfaceWithAttributeOnImplementation.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/DefaultInterfaceMethods/DimProvidedByRecursiveInterface.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/DynamicDependencies/DynamicDependencyMethodInAssembly.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/UnresolvedMembers.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/CppCLI/NonCopyActionWarnOnCppCLI.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/CppCLI/CppCLIAssemblyIsAnalyzed.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/ComponentModel/CustomTypeConvertor.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/UnusedAttributeOnReturnTypeIsRemoved.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/UnusedAttributeOnGenericParameterIsRemoved.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Attributes/IVTUsed.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
src/tools/illink/test/Mono.Linker.Tests.Cases/Attributes/CoreLibraryAssemblyAttributesAreKept.cs Uses [SkipUnresolved(true)] instead of raw linker argument.
Comments suppressed due to low confidence (1)

src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TrimmingArgumentBuilder.cs:126

  • AddSkipUnresolved appends skipUnresolved.ToString() which produces True/False (capitalized). The rest of this builder uses lowercase "true"/"false" strings for boolean options, and downstream consumers may rely on that consistency. Consider emitting lowercase explicitly (e.g., skipUnresolved ? "true" : "false" or ToString().ToLowerInvariant()).

@sbomer sbomer merged commit 2afb4c5 into dotnet:main Mar 2, 2026
92 of 96 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Tools-ILLink .NET linker development as well as trimming analyzers community-contribution Indicates that the PR has been added by a community member linkable-framework Issues associated with delivering a linker friendly framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants