Adjustments to how compiler generated types are ignored.#125183
Merged
sbomer merged 1 commit intodotnet:mainfrom Mar 5, 2026
Merged
Conversation
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/illink |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the ILLink test AssemblyChecker to make compiler-generated/polyfill artifacts easier to ignore during verification, primarily to support Unity’s older linker scenarios and tests that root types in test.exe.
Changes:
- Removes hardcoded workaround entries for specific compiler-injected attributes.
- Adds a new overridable hook
PrepareToVerifyAssemblyto adjust verification inputs before assertions run. - Adds a helper
IgnoreTypeAndItsMembersintended to ignore a type and its members during verification.
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs
Show resolved
Hide resolved
This was referenced Mar 4, 2026
sbomer
reviewed
Mar 4, 2026
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs
Show resolved
Hide resolved
4bbc155 to
41e3f00
Compare
3 tasks
Unity is still verifying the ILLink tests mostly pass when ran through an old version of UnityLinker that still supports .NET Framework. We also have tests that will root types in `test.exe`. Both of these scenarios lead to compiler generated polyfills that survive and mess up asserting. `AssemblyChecker` had some logic to deal with compiler generated attributes. These specific attributes no longer appear to require special handling during the illink tests so I've removed them. In order to help Unity deal with it's tests I've exposed a new method `PrepareToVerifyAssembly` that we can hook into and do the same sort of thing that was happening for attributes such as `EmbeddedAttribute` but also do it for other types such as `NullableAttribute`. I've exposed a helper method `IgnoreTypeAndItsMembers` that makes it easier to ignore a type and it's members.
41e3f00 to
beeb9c1
Compare
Contributor
Author
|
Accidentally included some changes intended for a different PR. Cleaned that up. |
Contributor
Author
|
@sbomer These changes are ready to merge. If you want something different let me know. If you don't want the changes I can hack something on our end using UnsafeAccessor. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unity is still verifying the ILLink tests mostly pass when ran through an old version of UnityLinker that still supports .NET Framework. We also have tests that will root types in
test.exe. Both of these scenarios lead to compiler generated polyfills that survive and mess up asserting.AssemblyCheckerhad some logic to deal with compiler generated attributes. These specific attributes no longer appear to require special handling during the illink tests so I've removed them.In order to help Unity deal with it's tests I've exposed a new method
PrepareToVerifyAssemblythat we can hook into and do the same sort of thing that was happening for attributes such asEmbeddedAttributebut also do it for other types such asNullableAttribute.I've exposed a helper method
IgnoreTypeAndItsMembersthat makes it easier to ignore a type and it's members.