Skip to content

Render source snippet on location#291

Merged
SimonCropp merged 1 commit intoVerifyTests:mainfrom
RReverser:squiggly-lines
Sep 18, 2024
Merged

Render source snippet on location#291
SimonCropp merged 1 commit intoVerifyTests:mainfrom
RReverser:squiggly-lines

Conversation

@RReverser
Copy link
Copy Markdown
Contributor

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.

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.
@SimonCropp SimonCropp added this to the 2.5.0 milestone Sep 18, 2024
@SimonCropp
Copy link
Copy Markdown
Member

LGTM. thanks

@SimonCropp SimonCropp merged commit d39a929 into VerifyTests:main Sep 18, 2024
@RReverser RReverser deleted the squiggly-lines branch September 18, 2024 11:20
@RReverser
Copy link
Copy Markdown
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 (WriteComment) contents according to the current surrounding indentation in Argon, so it always ends up aligned to the left.

If you have any ideas on how to fix this, that could provide a nicer output when location is stored in nested contexts.

@RReverser
Copy link
Copy Markdown
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 :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants