Stack frames are sometimes missing location in source generators
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with ProtocolGenerator.cs at lines 757 and 811, and the consuming Kafka.Protocol.csproj at line 42. Reproduce with Visual Studio 17.12.0 or the .NET CLI 8.0.404 by compiling twice without changes, then once after changing the generator. Done means stack-frame locations remain present on repeated unchanged compilations.
Written by the indexing model from the issue text.
Description
Version Used:
Compiler version: '4.12.0-3.24523.10 (16f58fa3)'. 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.
But when compiling again with no changes, the location of the stackframes in the stacktrace of the exception is gone.
If the registered source output changes then the location is reported again on next compilation.
Steps to Reproduce:
- Throw an exception here: https://github.com/Fresa/Kafka.Protocol/blob/e8a776639f7b8143fcfb006d01f7a2eef326c5be/Kafka.Protocol.SourceGenerator/ProtocolGenerator.cs#L757
- Attach a debugger here: https://github.com/Fresa/Kafka.Protocol/blob/e8a776639f7b8143fcfb006d01f7a2eef326c5be/Kafka.Protocol.SourceGenerator/ProtocolGenerator.cs#L811
- Compile once (here's a project using the generator) -> stack frame has location.
- Compile again -> stack frame is missing location.
- 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.
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/runtime
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
area-System.Reflection blocking-clean-ci-optional Known Build Error os-mac-os-x untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
area-CodeGen-coreclr untriaged
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
agentic-workflows untriaged
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
area-VM-meta-mono untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
Create parent directories only after the containment check in InstallHelper.TryExtractToDirectory Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
PowerShell/PSResourceGet#2056 ·