Skip to content

Managed ilasm: apply #line increments and validate sequence points - #136396

Merged
jkoritzinsky merged 16 commits into
dotnet:mainfrom
jkoritzinsky:dev/jkoritzinsky/feature-ilasm-source-mapping
Oct 28, 2026
Merged

jkoritzinsky merged 16 commits into
dotnet:mainfrom
jkoritzinsky:dev/jkoritzinsky/feature-ilasm-source-mapping

Conversation

@jkoritzinsky

Copy link
Copy Markdown
Member

Summary

Addresses items 1, 2 and 3 of #135314.

  • Apply #line increments to both range endpoints using physical source lines, preserving native quote/form-sensitive anchoring, document mappings, include restoration, and hidden markers.
  • Default omitted end columns to 65534 (ushort.MaxValue - 1) for compatibility with existing readers, with a pinned reference to the Roslyn workaround. Explicit columns remain unchanged.
  • Diagnose invalid original/effective spans and unencodable signed line deltas at the source directive. Error-tolerant output keeps instructions while omitting unencodable points.

This branch is independently based on main, not stacked on the SRM correction. Ordinary omitted-column output is readable by the existing SDK; explicit legal maximum-column/high-line boundary coverage was run with the corrected SRM reader.

Validation already run

With the unmodified SDK reader (no custom host):

.\.dotnet\dotnet.exe test src\tools\ilasm\tests\ILAssembler.Tests --no-build --filter 'FullyQualifiedName~OmittedEndColumn_UsesReaderCompatibleMaximumColumn|FullyQualifiedName~AutoIncrementDirective_OtherFormsAnchorTheDirectiveLine|FullyQualifiedName~AutoIncrementDirective_DoubleQuoted'

Result: 9 passed, 0 failed. The four omitted-column cases failed with BadImageFormatException before the compatibility revision.

Full branch build/test using the separately built corrected SRM runtime:

$env:DOTNET_ROLL_FORWARD='LatestMajor'
$env:DOTNET_HOST_PATH='E:\copilot-worktrees\runtime\dev-jkoritzinsky-glowing-meme\artifacts\bin\testhost\net11.0-windows-Debug-x64\dotnet.exe'
.\.dotnet\dotnet.exe test src\tools\ilasm\tests\ILAssembler.Tests -- "RunConfiguration.DotNetHostPath=$env:DOTNET_HOST_PATH"

Result: 5,456 passed, 0 failed, 3 existing skips. The unmodified reader still rejects the retained maximum-line boundary case; this does not affect the new ordinary default. No new test runs were performed for PR publication.

Note

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

jkoritzinsky and others added 5 commits October 23, 2026 15:07
Diagnose invalid Portable PDB source spans at their directives and preserve instructions in error-tolerant mode. Default omitted end columns to 0xffff while retaining hidden coordinates. Add boundary, source-location, and CLI regression coverage.

Co-authored-by: Copilot App <[email protected]>
Advance both sequence-point line endpoints by physical source lines while preserving native quote-sensitive anchoring, document mappings, and hidden markers. Diagnose effective spans before narrowing or encoding them.

Co-authored-by: Copilot App <[email protected]>
Check signed compressed start-line deltas across hidden points and document changes before recording points, retaining directive locations for diagnostics.

Co-authored-by: Copilot App <[email protected]>
Default omitted end columns to 65534, matching the pinned Roslyn SRM compatibility workaround while preserving explicit columns and hidden markers.

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

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 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.

@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.

jkoritzinsky and others added 3 commits October 27, 2026 11:26
Preserve source-mapping validation diagnostics alongside main's entrypoint diagnostics.

Co-authored-by: Copilot App <[email protected]>
Assert exact compressed blob fields for legal maximum columns and lines so boundary regressions remain covered with the unmodified SDK reader used in CI.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

A rejected sequence point incorrectly updates the deduplication state, causing a subsequent method to lose a valid first sequence point when using -debug -error.

1 open issue
What changed in this PR

Improves managed ilasm’s Portable PDB source mapping and validation, addressing items 1–3 of #135314.

Changes:

  • Applies physical-line increments to both #line endpoints while preserving anchoring, include mappings, and hidden points.
  • Defaults omitted end columns to 65534 and diagnoses invalid coordinates or unencodable line deltas.
  • Adds regression coverage and documents mapping rules and error-tolerant behavior.
File Description
src/​tools/​ilasm/​tests/​ILAssembler.Tests/​SequencePointTests.cs Tests mapping, coordinate limits, line deltas, and error recovery.
src/​tools/​ilasm/​tests/​ILAssembler.Tests/​CommandLineSequencePointTests.cs Tests output generation and instruction preservation with error tolerance.
src/​tools/​ilasm/​src/​ILAssembler/​Diagnostic.cs Adds sequence-point validation diagnostics.
src/​tools/​ilasm/​src/​ILAssembler/​CILParser.SemanticValues.MethodBodies.cs Records next-line anchoring for source directives.
src/​tools/​ilasm/​src/​ILAssembler/​Actions/​GrammarActions.Debug.cs Implements increments, column defaults, and sequence-point validation.
src/​tools/​ilasm/​src/​ILAssembler/​Actions/​GrammarActions.BuildImage.cs Corrects a comment about validation without PDB generation.
src/​tools/​ilasm/​README.md Documents source mapping and reader compatibility.
src/​tools/​ilasm/​MANAGED-ILASM-FIXES.md Records deliberate differences from native ilasm.

Review effort: Balanced

jkoritzinsky and others added 2 commits October 27, 2026 13:18
Update the cross-method span cache only after recording succeeds. Suppress repeated rejected attempts within their method and reset them on a new directive, preserving successful cross-method deduplication.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the Portable PDB source-mapping and validation changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@jkoritzinsky
jkoritzinsky enabled auto-merge (squash) October 27, 2026 21:04
@jkoritzinsky
jkoritzinsky requested a review from jkotas October 27, 2026 22:06
@jkoritzinsky
jkoritzinsky merged commit 763dafc into dotnet:main Oct 28, 2026
64 checks passed
@github-project-automation github-project-automation Bot moved this to Done in AppModel Oct 28, 2026
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 29, 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