Make ilverify respect IgnoresAccessChecksToAttribute#130978
Draft
JulieLeeMSFT with Copilot wants to merge 3 commits into
Draft
Make ilverify respect IgnoresAccessChecksToAttribute#130978JulieLeeMSFT with Copilot wants to merge 3 commits into
JulieLeeMSFT with Copilot wants to merge 3 commits into
Conversation
|
Azure Pipelines: 15 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: JulieLeeMSFT <63486087+JulieLeeMSFT@users.noreply.github.com>
Co-authored-by: JulieLeeMSFT <63486087+JulieLeeMSFT@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix ilverify to respect IgnoreAccessChecksTo
Make ilverify respect IgnoresAccessChecksToAttribute
Jul 17, 2026
Contributor
|
The test can be in C# but using separate ref and impl assemblies differing by member accessibility, it might be cleaner that way. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @dotnet/jit-contrib |
jkotas
reviewed
Jul 18, 2026
| var currentTypeDef = (MetadataType)currentClass.GetTypeDefinition(); | ||
| var targetTypeDef = (EcmaType)targetClass.GetTypeDefinition(); | ||
|
|
||
| // The accessing assembly can waive all access checks to the target assembly via [IgnoresAccessChecksTo]. |
Member
There was a problem hiding this comment.
This is very rare case - check of last resort, and it is somewhat expensive due to custom attribute lookup and parsing. It should be done last when all other ways to prove accessibility failed.
Contributor
There was a problem hiding this comment.
Does ILVerify performance matter to this extent? I'd have assumed the overhead to be fine enough for it.
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.
ilverifyonly honoredInternalsVisibleToAttributefor cross-assembly access checks, so IL that legitimately accesses another assembly's internal/private members via[assembly: IgnoresAccessChecksTo("...")]was incorrectly reported as invalid. This alignsilverifywith CoreCLR runtime behavior, where an assembly declaringIgnoresAccessChecksTomay bypass all access checks (private, family, assembly) to the named target — stronger thanInternalsVisibleTo.Changes
AccessVerificationHelpers.csIgnoresAccessChecksTo(this ModuleDesc accessing, ModuleDesc accessed)which decodesSystem.Runtime.CompilerServices.IgnoresAccessChecksToAttributeon the accessing assembly and matches the accessed assembly by simple name — mirroring the runtime'sFriendAssemblyDescriptor::IsAssemblyOnList/RefMatchesDef(name-only match when the declared name omits a public key token).CanAccess(after the generic-instantiation checks, so third-assembly instantiation arguments are still validated) and inCanAccessMember, covering type, method, and field access.Tests — new
AccessTestsIgnoreChecks.il/.ilprojtest assembly declaring[IgnoresAccessChecksTo("AccessTests")](defining the attribute type itself, as real consumers likeIgnoresAccessChecksToGeneratordo), with 11 cases exercising private/family/assembly classes, nested types, methods, and fields. Confirmed the cases fail without the fix and pass with it.