Repository navigation
Preserve assembly key-token identity in ILAsm attribute type names - #137096
Merged
jkoritzinsky merged 2 commits intoNov 7, 2026
Merged
jkoritzinsky merged 2 commits into
jkoritzinsky merged 2 commits into
Conversation
Honor AssemblyFlags.PublicKey rather than treating every key-or-token blob as a full public key. Preserve malformed byref fixed-buffer fields while allowing importers to resolve their serialized element types. Regression tests fail before the correction, including after the explicit-valuetype prerequisite, and pass afterward. Windows tools.ilasm: 5802 passed, 3 skipped. Standalone SDK C# consumer reports CS0021 with unfixed output and CS0570 with both native and corrected output. 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 |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the assembly identity serialization change.
No open issues 🎉
What changed in this PR
Fixes managed ILAsm’s assembly identity serialization for structured custom attribute type arguments, preserving the distinction between public keys and public key tokens needed for type resolution.
Changes:
- Uses
AssemblyFlags.PublicKeyto select the correct assembly identity format. - Extends attribute tests to cover unsigned, public-key-token, and full-public-key assembly references.
- Adds fixed-buffer regression coverage for value and byref fields while preserving their signatures.
| File | Description |
|---|---|
src/tools/ilasm/tests/ILAssembler.Tests/FieldTests.cs |
Tests fixed-buffer element type identity and value/byref field signatures. |
src/tools/ilasm/tests/ILAssembler.Tests/CustomAttributeTests.cs |
Covers assembly-qualified type names across three key configurations. |
src/tools/ilasm/src/ILAssembler/EntityRegistry.cs |
Honors assembly flags when serializing public keys or tokens. |
Review effort: Balanced
jkotas
approved these changes
Nov 6, 2026
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.
Fix managed ILAsm's serialization of assembly identities in structured custom attribute type arguments. The existing code treats every public-key-or-token blob as a full public key, so
.publickeytokenis serialized asPublicKey=rather thanPublicKeyToken=.This prevents the C# metadata importer from resolving the
System.Int32element type inFixedBufferAttribute. TheRefFieldTests.FixedField_02fixture consequently produces CS0021 instead of the expected CS0570. HonorAssemblyFlags.PublicKeywhen constructing the serialized identity; retain the intentionally malformed byref field signature without changing compiler expectations.Regression coverage includes value and byref fixed-buffer fields, and unsigned, public-key-token, and full-public-key assembly references. This PR contains only the key-token fix and its tests; the independent explicit-valuetype change is not required and is excluded.
Validation:
.\build.cmd tools.ilasm -test: passed on Windows x64, 5,790 passed, 3 skipped, 0 failed, with no explicit-valuetype prerequisite.Note
This pull request description and code changes were generated with GitHub Copilot.