Skip to content

Add [IgnoreILFailure] support to ILLink test framework.#124012

Merged
sbomer merged 1 commit intodotnet:mainfrom
Unity-Technologies:linker-ilverify-improvements
Feb 6, 2026
Merged

Add [IgnoreILFailure] support to ILLink test framework.#124012
sbomer merged 1 commit intodotnet:mainfrom
Unity-Technologies:linker-ilverify-improvements

Conversation

@mrvoorhe
Copy link
Copy Markdown
Contributor

@mrvoorhe mrvoorhe commented Feb 4, 2026

At Unity we have a few tests where we are modifying IL in System.Private.CoreLib and it throws off the diff'ing due to shifted offsets. The only solution today is to disable il verification for all of the assembly. This is not ideal as it means we could let other bugs slip in in the future. This PR adds a way to filter out a given il verification error so that you don't have to disable il verification for the whole assembly. It's a fairly crude mechanism but I think it should be good enough for the limited number of places we want to use it.

Also while I'm here, I added DebuggerDisplay to ILVerifierResult. It's helpful when trying to debug il verification related issues

At Unity we have a few tests where we are modifying IL in System.Private.CoreLib and it throws off the diff'ing due to shifted offsets.  The only solution today is to disable il verification for all of the assembly.  This is not ideal as it means we could let other bugs slip in in the future.  This PR adds a way to filter out a given il verification error so that you don't have to disable il verification for the whole assembly.  It's a fairly crude mechanism but I think it should be good enough for the limited number of places we want to use it.

Also while I'm here, I added `DebuggerDisplay` to `ILVerifierResult`.  It's helpful when trying to debug il verification related issues
@mrvoorhe mrvoorhe requested a review from sbomer as a code owner February 4, 2026 19:06
Copilot AI review requested due to automatic review settings February 4, 2026 19:06
@github-actions github-actions Bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Feb 4, 2026
@mrvoorhe
Copy link
Copy Markdown
Contributor Author

mrvoorhe commented Feb 4, 2026

@sbomer please take a look

Copy link
Copy Markdown
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 adds functionality to the ILLink test framework that allows selectively ignoring specific IL verification errors through a new [IgnoreILFailure] attribute, rather than disabling IL verification for entire assemblies. This is particularly useful when modifying IL in System.Private.CoreLib where offset shifts can cause verification diffs.

Changes:

  • Introduces [IgnoreILFailure] attribute to filter specific IL verification errors based on message content
  • Adds [DebuggerDisplay] attribute to ILVerifierResult for improved debugging experience
  • Includes a test case demonstrating the new ignore functionality

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

File Description
ILVerifierResult.cs Adds DebuggerDisplay attribute and System.Diagnostics import for easier debugging
ILChecker.cs Implements filtering logic for ignored IL verification errors using the new attribute
ILVerificationErrorsCanBeIgnored.cs Test case demonstrating the [IgnoreILFailure] attribute usage
IgnoreILFailureAttribute.cs New attribute definition for marking specific IL failures to ignore

@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 4, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
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, thank you!

@mrvoorhe
Copy link
Copy Markdown
Contributor Author

mrvoorhe commented Feb 6, 2026

@sbomer Can you merge the PR?

@sbomer sbomer merged commit 1594c84 into dotnet:main Feb 6, 2026
87 checks passed
lewing pushed a commit to lewing/runtime that referenced this pull request Feb 9, 2026
)

At Unity we have a few tests where we are modifying IL in
System.Private.CoreLib and it throws off the diff'ing due to shifted
offsets. The only solution today is to disable il verification for all
of the assembly. This is not ideal as it means we could let other bugs
slip in in the future. This PR adds a way to filter out a given il
verification error so that you don't have to disable il verification for
the whole assembly. It's a fairly crude mechanism but I think it should
be good enough for the limited number of places we want to use it.

Also while I'm here, I added `DebuggerDisplay` to `ILVerifierResult`.
It's helpful when trying to debug il verification related issues
iremyux pushed a commit to iremyux/dotnet-runtime that referenced this pull request Mar 2, 2026
)

At Unity we have a few tests where we are modifying IL in
System.Private.CoreLib and it throws off the diff'ing due to shifted
offsets. The only solution today is to disable il verification for all
of the assembly. This is not ideal as it means we could let other bugs
slip in in the future. This PR adds a way to filter out a given il
verification error so that you don't have to disable il verification for
the whole assembly. It's a fairly crude mechanism but I think it should
be good enough for the limited number of places we want to use it.

Also while I'm here, I added `DebuggerDisplay` to `ILVerifierResult`.
It's helpful when trying to debug il verification related issues
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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