Handle ILLink origins before first sequence point#129869
Open
sbomer wants to merge 2 commits into
Open
Conversation
Avoid throwing while formatting diagnostics whose IL offset precedes the first available PDB sequence point. Fall back to the first sequence point and cover the case with a focused MessageContainer test. Assisted-by: Copilot:gpt-5.5 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/illink |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates ILLink’s diagnostic origin formatting to handle method IL offsets that occur before the first available PDB sequence point, preventing MessageOrigin.ToString() from throwing when generating MSBuild-formatted messages. It also adds a regression test that constructs and round-trips a Cecil-generated assembly + Portable PDB to reproduce the offset shape.
Changes:
- Make
MessageOrigin.ToString()tolerate “origin before first sequence point” by falling back to the first available sequence point instead of throwing. - Add a targeted xUnit regression test that emits a Portable PDB where the only sequence point is after the first IL instruction, then verifies
ToMSBuildString()output.
Show a summary per file
| File | Description |
|---|---|
| src/tools/illink/src/linker/Linker/MessageOrigin.cs | Adjusts sequence point selection logic to avoid Last() throwing when no sequence point exists at/before the IL offset. |
| src/tools/illink/test/Mono.Linker.Tests/Tests/MessageContainerTests.cs | Adds a Cecil-based regression test covering an origin IL offset occurring before the first sequence point. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 1
Keep the existing LINQ-based sequence point lookup but use LastOrDefault so diagnostics whose IL offset precedes the first sequence point fall back to the tool name instead of throwing, matching ILC behavior. Assisted-by: Copilot:gpt-5.5 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Fixes #129562.
MessageOrigin.ToString()assumed that every diagnostic IL offset has at least one PDB sequence point at or before that offset. Rewritten/generated IL can put a warning origin before the first sequence point, which madeLast()throw while ILLink flushed cached warnings.This changes the lookup to tolerate that shape by falling back to the first available sequence point, and adds a focused regression test that round-trips a Cecil-generated assembly/PDB to reproduce the real offset behavior.
This content was created with assistance from AI.