Skip to content

Implement label validation and typedef resolution in C# ilasm#123002

Merged
jkoritzinsky merged 8 commits intodotnet:mainfrom
am11:feature/managed-ilasm
Jan 28, 2026
Merged

Implement label validation and typedef resolution in C# ilasm#123002
jkoritzinsky merged 8 commits intodotnet:mainfrom
am11:feature/managed-ilasm

Conversation

@am11
Copy link
Copy Markdown
Member

@am11 am11 commented Jan 8, 2026

  • Consolidate instruction tokens into main grammar to establish proper lexer precedence over DOTTEDNAME and ID; reorder methodDecl alternatives to match instructions first; add custom attribute handling in method bodies

  • Implement visitor stubs for debug/symbol directives: VisitLanguageDecl, VisitEsHead, VisitExportHead, VisitExtSourceSpec, VisitFieldInit

  • Add typedef resolution in ResolveTypeDef for type aliases

  • Implement label validation: track declared vs referenced labels, report errors for undefined labels at method end

  • Allow recoverable errors in method bodies to still emit assembly

  • Add tests for label validation, typedef resolution, and error handling

- Consolidate instruction tokens into main grammar to establish proper lexer
  precedence over DOTTEDNAME and ID; reorder methodDecl alternatives to
  match instructions first; add custom attribute handling in method bodies

- Implement visitor stubs for debug/symbol directives: VisitLanguageDecl,
  VisitEsHead, VisitExportHead, VisitExtSourceSpec, VisitFieldInit

- Add typedef resolution in ResolveTypeDef for type aliases

- Implement label validation: track declared vs referenced labels, report
  errors for undefined labels at method end

- Allow recoverable errors in method bodies to still emit assembly

- Add tests for label validation, typedef resolution, and error handling
@github-actions github-actions Bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 8, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jan 8, 2026
@am11 am11 added area-ILTools-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Jan 8, 2026
@am11 am11 requested a review from jkoritzinsky January 8, 2026 08:07
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

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

Comment thread src/tools/ilasm/src/ILAssembler/EntityRegistry.cs Outdated
Comment thread src/tools/ilasm/src/ILAssembler/EntityRegistry.cs Outdated
Comment thread src/tools/ilasm/src/ILAssembler/CIL.g4 Outdated
Comment thread src/tools/ilasm/tests/ILAssembler.Tests/DocumentCompilerTests.cs Outdated
Comment thread src/tools/ilasm/tests/ILAssembler.Tests/DocumentCompilerTests.cs Outdated
Comment thread src/tools/ilasm/src/ILAssembler/GrammarVisitor.cs
Comment thread src/tools/ilasm/src/ILAssembler/GrammarVisitor.cs Outdated
Comment thread src/tools/ilasm/src/ILAssembler/GrammarVisitor.cs Outdated
Comment thread src/tools/ilasm/src/ILAssembler/GrammarVisitor.cs Outdated
Comment thread src/tools/ilasm/src/ILAssembler/GrammarVisitor.cs Outdated
@agocke
Copy link
Copy Markdown
Member

agocke commented Jan 12, 2026

Can we gather test coverage for ilasm/this change? Test coverage for ilasm should be pretty easy to measure and ideally we would never regress coverage percent.

Comment thread src/tools/ilasm/src/ILAssembler/CIL.g4 Outdated
Comment thread src/tools/ilasm/src/ILAssembler/GrammarVisitor.cs
Copy link
Copy Markdown
Member

@jkoritzinsky jkoritzinsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking much better! Just a few more comments.

Also, if you can get the code-coverage info that @agocke mentioned, I think that would be a great idea

@am11
Copy link
Copy Markdown
Member Author

am11 commented Jan 28, 2026

Coverage baseline is not too impressive, but it is what it is rn 😅
image

@jkoritzinsky jkoritzinsky merged commit dc33319 into dotnet:main Jan 28, 2026
59 of 61 checks passed
@am11 am11 deleted the feature/managed-ilasm branch January 28, 2026 22:12
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-ILTools-coreclr community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants