Skip to content

Preserve unsealed System.Enum in managed ilasm core libraries - #136884

Merged
jkoritzinsky merged 3 commits into
dotnet:mainfrom
jkoritzinsky:dev/jkoritzinsky/fix-enum-sealing-behavior
Nov 3, 2026
Merged

jkoritzinsky merged 3 commits into
dotnet:mainfrom
jkoritzinsky:dev/jkoritzinsky/fix-enum-sealing-behavior

Conversation

@jkoritzinsky

Copy link
Copy Markdown
Member

Managed ilasm rejects the abstract System.Enum definition in source-built reference assemblies with ILA0002 and implicitly seals it. This breaks the offline source build of the .NET 7, 9, and 10 reference packs in build 1660358.

Match native ilasm's exception: System.Enum is a reference type despite extending System.ValueType, so its top-level core-library definition must not trigger value-type sealing. Recognize .mscorlib and .assembly mscorlib for this check, while preserving diagnostics for ordinary value types and lookalikes. Ordinary user-defined enum sealed flags are unchanged.

Validation

  • .\build.cmd tools.ilasm - passed before the product change.
  • .\dotnet.cmd test src\tools\ilasm\tests\ILAssembler.Tests\ILAssembler.Tests.csproj --no-build --no-restore --filter FullyQualifiedName~TypeDefinitionTests - before the fix, the four new System.Enum regression cases failed with ILA0002; the other 67 cases passed.
  • .\dotnet.cmd build src\tools\ilasm\src\ILAssembler\gen -t:Rebuild --no-restore - passed; regenerated the parser.
  • .\build.cmd tools.ilasm -test - passed after the fix: 5,746 passed, 0 failed, 3 existing skips.
  • Reproduced the exact ILA0002 diagnostic using the .NET 10 reference IL from the failing source-build-assets revision. All three original .NET 7/9/10 inputs now assemble successfully, and metadata inspection confirms System.Enum remains abstract and unsealed.
  • Confirmed the rule against native ilasm source and the installed Windows native ilasm using focused IL inputs.

Note

This pull request description and code changes were generated with GitHub Copilot.

Match native ilasm's core-library exception to value-type sealing, recognizing .mscorlib and assembly mscorlib. Cover System.Enum, lookalikes, and ordinary enum/value-type behavior.

Co-authored-by: Copilot App <[email protected]>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
10 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Comment thread src/tools/ilasm/README.md Resolved
jkoritzinsky and others added 2 commits November 2, 2026 15:38
Reuse the core-library name helper for assembly definitions and match assembly lookup's case-insensitive comparison. Expand regression coverage and remove implementation details from the README.

Co-authored-by: Copilot App <[email protected]>
Remove implicit sealing while retaining the unsealed value-type diagnostic. Update diagnostic text and cover strict rejection, tolerant emission, explicit sealing, and legacy raw flags.

Co-authored-by: Copilot App <[email protected]>
@jkoritzinsky
jkoritzinsky enabled auto-merge (squash) November 3, 2026 03:57
@jkoritzinsky
jkoritzinsky merged commit ed0fb46 into dotnet:main Nov 3, 2026
61 checks passed
@github-project-automation github-project-automation Bot moved this to Done in AppModel Nov 3, 2026
@jkoritzinsky
jkoritzinsky deleted the dev/jkoritzinsky/fix-enum-sealing-behavior branch November 3, 2026 17:04
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants