Repository navigation
Fix managed ILAsm DeclSecurity blob serialization - #137484
Merged
jkoritzinsky merged 3 commits intoNov 18, 2026
Merged
jkoritzinsky merged 3 commits into
jkoritzinsky merged 3 commits into
Conversation
Co-authored-by: Copilot App <[email protected]>
jkoritzinsky
requested review from
MichalStrehovsky,
akoeplinger and
jkotas
and
a balanced review from Copilot
November 13, 2026 07:09
|
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 block the declarative-security serialization changes.
No open issues 🎉
What changed in this PR
This PR corrects managed ILAsm’s declarative-security blob serialization to match native ILAsm while preserving the existing custom-attribute layout.
Changes:
- Write compressed payload lengths and named-argument counts for binary permission-set attributes, sharing individual argument serialization.
- Emit string permission sets as unterminated UTF-16, stopping at embedded nulls.
- Update blob expectations and add coverage for compression boundaries, consecutive attributes, string variants, and unsupported
.permissionforms.
| File | Description |
|---|---|
src/tools/ilasm/tests/ILAssembler.Tests/SecurityTests.cs |
Corrects expected blobs and expands security-declaration regression coverage. |
src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Security.cs |
Fixes binary and string permission-set encoding. |
src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.CustomAttributes.Actions.cs |
Extracts shared named-argument serialization without changing custom-attribute encoding. |
Review effort: Balanced
jkotas
reviewed
Nov 14, 2026
Co-authored-by: Copilot App <[email protected]>
jkotas
reviewed
Nov 17, 2026
jkotas
reviewed
Nov 17, 2026
Co-authored-by: Copilot App <[email protected]>
jkotas
approved these changes
Nov 17, 2026
3 tasks
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.

Summary
EncodeSecAttr. Share individual named-argument serialization without changing the custom-attribute layout.BinStrToUnicodedoes.BlobReader(also emitted by its permission-set encoder).The report's
.permissionobservation differs between native implementations: locally built CoreCLR native ILAsm rejects it becauseRegMeta::DefineSecurityAttributeSetreturnsE_NOTIMPL; installed .NET Framework ILAsm accepts it. Preserve the existing managed diagnostic for CoreCLR parity, with coverage for all three grammar forms.Validation
$env:NuGetAudit='false'; .\build.cmd clr+libs -rc release— passed, clean prerequisite build..\dotnet.cmd test src\tools\ilasm\tests\ILAssembler.Tests\ILAssembler.Tests.csproj -p:NuGetAudit=false --filter FullyQualifiedName~SecurityTests --logger trx --results-directory artifacts\tmp\security-beforebefore the fix — reproduced 11 failures and 24 passes on each of net10.0 and net12.0..\dotnet.cmd test src\tools\ilasm\tests\ILAssembler.Tests\ILAssembler.Tests.csproj -p:NuGetAudit=false --logger trx --results-directory artifacts\tmp\security-after— passed all 5,322 tests on each framework..\build.cmd tools+tools.ilasm -test— passed, including net472 and NativeAOT production builds, both assembler library suites, and 563 CLI tests with 3 existing skips.GenericAssert.il/more_tailcalls.ilfixtures). Cecil successfully decoded the binary permission sets..\dotnet.cmd build src\tools\illink\test\Mono.Linker.Tests\Mono.Linker.Tests.csproj -p:CoreCLRConfiguration=Release -p:NuGetAudit=false— passed.Mono.Linker.Tests.ILToolsDirto useartifacts\bin\coreclr\windows.x64.Debug\managed-ilasm, then ran.\dotnet.cmd vstest artifacts\bin\Mono.Linker.Tests\Debug\net12.0\Mono.Linker.Tests.dll '--TestCaseFilter:FullyQualifiedName~TypeForwarding.TypeForwardingTests' '--logger:trx;LogFileName=typeforwarding-consumer.trx' '--ResultsDirectory:artifacts\tmp\linker-security'— passed all 45 tests, includingSecurityAttributeScope. Restored the generated runtimeconfig afterward.The runtime fixtures were assembled and inspected, not executed.
Resolves #137480
Note
This pull request was generated with GitHub Copilot.