Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack frames are sometimes missing location in source generators #76810

Open
Fresa opened this issue Jan 18, 2025 · 0 comments
Open

Stack frames are sometimes missing location in source generators #76810

Fresa opened this issue Jan 18, 2025 · 0 comments
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@Fresa
Copy link

Fresa commented Jan 18, 2025

Version Used:
Compiler version: '4.12.0-3.24523.10 (16f58fa)'. Language version: 12.0.

I have written a source generator that tries to catch unhandled exceptions when generating code and output it through diagnostics. This works pretty good, disregarding the shortcomings of the Visual Studio Error List and description and messageFormat.

Image

But when compiling again with no changes, the location of the stackframes in the stacktrace of the exception is gone.

Image

If the registered source output changes then the location is reported again on next compilation.

Steps to Reproduce:

  1. Throw an exception here: https://github.com/Fresa/Kafka.Protocol/blob/e8a776639f7b8143fcfb006d01f7a2eef326c5be/Kafka.Protocol.SourceGenerator/ProtocolGenerator.cs#L757
  2. Attach a debugger here: https://github.com/Fresa/Kafka.Protocol/blob/e8a776639f7b8143fcfb006d01f7a2eef326c5be/Kafka.Protocol.SourceGenerator/ProtocolGenerator.cs#L811
  3. Compile once (here's a project using the generator) -> stack frame has location.
  4. Compile again -> stack frame is missing location.
  5. Change anything in the method at 1. and compile again -> stack frame has location again.

I've tested both in Visual Studio (Version 17.12.0) and the dotnet cli (8.0.404) with the same behavior.

Diagnostic Id: N/A

Expected Behavior:
Stack frame location is the same when no code changes.

Actual Behavior:
Stack frame location is missing when running the source generator multiple times with no changes.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

1 participant