fix: improve source generator diagnostic locations#4921
Merged
Conversation
c776d34 to
600a85e
Compare
Contributor
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. The changes are well-scoped and targeted. A few highlights:
The PR correctly identifies that these are error-path-only changes (inside |
600a85e to
b84bc2d
Compare
…Location.None - TestMetadataGenerator: use MethodSymbol.Locations to point errors at the test method declaration - HookMetadataGenerator: include FilePath and LineNumber in the error message so users can navigate to the hook method manually - AotConverterGenerator: improve error messages with exception type/message details and conversion type context - AotConverterGenerator: add broader catch(Exception) handler in ScanTestParameters to wrap unexpected errors with context Closes #4865
b84bc2d to
f423f61
Compare
This was referenced Feb 22, 2026
Open
This was referenced Feb 23, 2026
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.
Summary
Location.Nonewith the actual method symbol location so users can click the error and navigate directly to the failing test method declaration.FilePathandLineNumberin the diagnostic message so users can find the hook method manually (theHookModelis a primitive model without Roslyn symbols, so aLocationobject cannot be constructed, but the file/line info is available).catch (Exception)handler (excludingOperationCanceledException) inScanTestParametersto wrap unexpected errors with context, preserving the original exception asInnerException.Test plan
dotnet build TUnit.Core.SourceGenerator/TUnit.Core.SourceGenerator.csprojpasses with 0 warnings and 0 errorsTestMetadataGenerator, the IDE error list shows the correct file/line locationHookMetadataGeneratorerrors now include file path and line number in the message textAotConverterGeneratorerrors include actionable type informationCloses #4865