Repository navigation
Fix core-library type resolution in managed ilasm - #136935
Merged
jkoritzinsky merged 2 commits intoNov 4, 2026
Merged
jkoritzinsky merged 2 commits into
jkoritzinsky merged 2 commits into
Conversation
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
|
Azure Pipelines: Successfully started running 4 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @dotnet/jit-contrib |
jkotas
approved these changes
Nov 3, 2026
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the core-library type-resolution changes.
No open issues 🎉
What changed in this PR
This PR corrects core-library type resolution in managed ilasm so generated reference assemblies can be recognized by the C# compiler without unintended mscorlib dependencies.
Changes:
- Keeps core-library
System.Objectbaseless, including explicit and repeated declarations. - Resolves implicit bases, unqualified well-known types, and generated debug attributes locally in core-library mode while preserving explicit external references.
- Adds regression coverage for root bases, local metadata handles, assembly-reference boundaries, and debug attributes.
| File | Description |
|---|---|
src/tools/ilasm/tests/ILAssembler.Tests/TypeReferenceTests.cs |
Tests local resolution, debug attributes, and preservation of explicit external references. |
src/tools/ilasm/tests/ILAssembler.Tests/TypeDefinitionTests.cs |
Tests baseless root objects and local versus external implicit bases. |
src/tools/ilasm/src/ILAssembler/EntityRegistry.cs |
Centralizes core-library state and adds local type and scope resolution. |
src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Types.References.cs |
Avoids external well-known-type lookup in core-library mode. |
src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Types.Headers.cs |
Enforces the root-object rule during initial and repeated declarations. |
src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.Assembly.cs |
Records core-library detection in the entity registry. |
src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Declarations.Actions.cs |
Routes the .mscorlib directive to shared registry state. |
src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Conversions.cs |
Removes the former grammar-local core-library flag. |
src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.BuildImage.cs |
Uses the appropriate core-library scope for generated debug attributes. |
Review effort: Balanced
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.
Managed ilasm can emit a base on a core library's
System.Objectand introduce an unwantedmscorlibreference. This prevents Roslyn from recognizing the generated netstandard reference assembly as a core library, resulting in CS0518 errors for predefined types.Follow native ilasm's root-object rule by leaving the recognized core-library
System.Objectwithout a base, including explicit and repeated declarations. Use local resolution for implicit bases, unqualified well-known types, and generated debug attributes in core-library mode. Preserve ordinary assemblies' external core-library lookup and explicitly authored assembly references.Regression coverage checks nil root bases, zero implicit AssemblyRefs, local base and signature handles, debug attributes, value-type validation, and external-reference boundaries.
Validation:
.\build.cmd tools.ilasm -test: passed, 5,786 passed / 3 skipped / 0 failed.System.Object.BaseTypeis nil and the AssemblyRef table is empty.csc.dll /noconfig /nostdlib /target:library, referencing only the reassembled netstandard: passed. The same consumer against the nil-base-only intermediate assembly failed with CS0518.The original source-build pipeline was not rerun.
Note
This pull request description and code changes were generated with GitHub Copilot.