Render source snippet on location#291
Merged
SimonCropp merged 1 commit intoVerifyTests:mainfrom Sep 18, 2024
Merged
Conversation
This is something I implemented in my project's test implementation and found very helpful on large source generator samples - rendering the actual source snippet as an output comment, with squiggly lines underlining the problematic section, similar to what you get when compiling in the console. Unfortunately, only one test in this repo uses locations from actual source trees, so it might be harder to see the benefits, but even this modified example should give an idea of what it looks like.
Member
|
LGTM. thanks |
Contributor
Author
|
Thanks! FWIW the only thing that bothered me in the output is that I couldn't find a way to indent the comment ( If you have any ideas on how to fix this, that could provide a nicer output when location is stored in nested contexts. |
Contributor
Author
|
Example of what I'm talking about: {
Location: /*
internal static readonly SpacetimeDB.BSATN.IReadWrite<System.DateTime> UnsupportedSpecialTime = new();
internal static readonly SpacetimeDB.BSATN.IReadWrite<System.Exception> UnsupportedSystemType = new();
^^^^^
internal static readonly SpacetimeDB.BSATN.IReadWrite<UnresolvedType> UnresolvedType = new();
*/
SpacetimeDB.BSATN.Codegen\SpacetimeDB.Codegen.Type\TestUnsupportedType.cs: (20,96)-(20,101),
Message: Cannot create an instance of the abstract type or interface 'IReadWrite<Exception>',
Severity: Error,
Descriptor: {That looks kinda unpleasant due to lack of indentation, but I'm not sure how to fix it :( |
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.
This is something I implemented in my project's test implementation and found very helpful on large source generator samples - rendering the actual source snippet as an output comment, with squiggly lines underlining the problematic section, similar to what you get when compiling in the console.
Unfortunately, only one test in this repo uses locations from actual source trees, so it might be harder to see the benefits, but even this modified example should give an idea of what it looks like.