Validate generator diagnostics after incremental updates - #82113
Merged
Conversation
| string parameterName, | ||
| bool initialization = false) | ||
| { | ||
| _output.WriteLine(diagnostic.ToString()); |
Member
Author
There was a problem hiding this comment.
It was useful to see the stacktrace that customers will see even though we don't validate it in the test obviously
CyrusNajmabadi
approved these changes
Jan 22, 2026
Co-authored-by: Cyrus Najmabadi <cyrus.najmabadi@gmail.com>
JoeRobich
approved these changes
Jan 22, 2026
Also should make it work under non-English locales.
Member
Author
|
@dotnet/roslyn-compiler for another review, thanks |
chsienki
approved these changes
Jan 24, 2026
| #endif | ||
| _output.WriteLine(diagnostic.ToString()); | ||
|
|
||
| var expectedMessage = new ArgumentException(message: message, paramName: parameterName).Message; |
Member
|
If this is merged, what would the behavior for the original bug be with the new code? The generator keeps running but there are some yellow bars, generator stops running, etc ...? |
Member
Author
Member
Author
|
@dotnet/roslyn-compiler for another review, thanks (not sure if sign off from Cyrus + Chris counts as two compiler reviews) |
Member
Author
|
@RikkiGibson @dotnet/roslyn-compiler for another review, thanks |
Member
Author
|
@dotnet/roslyn-compiler for another review, thanks |
Member
Author
|
@RikkiGibson @dotnet/roslyn-compiler for another review, thanks |
Member
Author
|
@dotnet/roslyn-compiler for another review, thanks |
RikkiGibson
approved these changes
Feb 25, 2026
This was referenced Feb 25, 2026
ANcpLua
added a commit
to ANcpLua/ANcpLua.Roslyn.Utilities
that referenced
this pull request
Jun 14, 2026
* test: pin diagnostic-location safety across incremental updates Mirrors the bug class fixed by dotnet/roslyn#82113 (issue #82032), from the consumer side. A generator diagnostic whose location was captured against a longer tree must not survive a shrinking incremental edit as an out-of-range span. Our DiagnosticInfo/LocationInfo reconstruct an external-file location (never source-tree-bound), so the driver never range-validates it and a shrink can neither crash the generator nor report a stale span. The test drives CSharpGeneratorDriver across a shrinking ReplaceSyntaxTree edit and asserts the re-reported AL0301 location is external (IsInSource == false) and in range of the new tree, with no generator-failure diagnostic. It fails if LocationInfo.ToLocation() ever regresses to a source-tree-bound location. Bonus: extract a public GeneratorTestHelper.CreateCompilation primitive (reused by RunGenerator) so tests can drive the driver directly for incremental scenarios, and declare the now-direct Microsoft.CodeAnalysis.CSharp dependency on the DU test project. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ci: execute tests in CI so publish is gated on behavior, not just compile The build job compiled the test projects but never ran them, so a runtime regression could pass CI and auto-publish to nuget.org. Add a Test step after Build on both ubuntu + windows. publish `needs: build`, so a failing test now fails the job and blocks the release — closing the gap without touching the fleet-managed branch protection. CrefRegression.Tests stays a compile-only guard covered by Build (it has no test-platform reference). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.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 #82032.