Skip to content

Adjustments to how compiler generated types are ignored.#125183

Merged
sbomer merged 1 commit intodotnet:mainfrom
Unity-Technologies:linker-flexibility-to-deal-with-polyfills
Mar 5, 2026
Merged

Adjustments to how compiler generated types are ignored.#125183
sbomer merged 1 commit intodotnet:mainfrom
Unity-Technologies:linker-flexibility-to-deal-with-polyfills

Conversation

@mrvoorhe
Copy link
Contributor

@mrvoorhe mrvoorhe commented Mar 4, 2026

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.

@mrvoorhe mrvoorhe requested a review from sbomer as a code owner March 4, 2026 18:00
Copilot AI review requested due to automatic review settings March 4, 2026 18:00
@github-actions github-actions bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Mar 4, 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 Mar 4, 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 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 PrepareToVerifyAssembly to adjust verification inputs before assertions run.
  • Adds a helper IgnoreTypeAndItsMembers intended to ignore a type and its members during verification.

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.
Copilot AI review requested due to automatic review settings March 5, 2026 19:17
@mrvoorhe mrvoorhe force-pushed the linker-flexibility-to-deal-with-polyfills branch from 41e3f00 to beeb9c1 Compare March 5, 2026 19:17
@mrvoorhe
Copy link
Contributor Author

mrvoorhe commented Mar 5, 2026

Accidentally included some changes intended for a different PR. Cleaned that up.

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@mrvoorhe
Copy link
Contributor Author

mrvoorhe commented Mar 5, 2026

@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.

@sbomer sbomer enabled auto-merge (squash) March 5, 2026 22:18
Copy link
Member

@sbomer sbomer left a comment

Choose a reason for hiding this comment

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

LGTM! Not for this PR, but did you consider adding a project that builds with the extension points you need? It would help prevent accidental breaks like what you're fixing in #125190.

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