dotnet / dotnet/docs

Little is said about debugging roslyn analyzers.

Open
#23,396 2 comments 5 reactions 0 assignees View on GitHub
:mag: Needs Research dotnet-csharp/svc roslyn-sdk/subsvc
Dominant language
No language data
Stars
4.8k
Forks
6.1k
Avg merge
19h 10m
Merged PRs (30d)
268

Description

There has been some rather active discussion recently on Gitter (this morning for example) related to the problems encountered when a Roslyn novice (me) instinctively tried to debug a rudimentary Roslyn analyzer.

When someone first begins to explore analyzers and follows these introductory articles, its is very natural for them to attempt to debug the analyzer, much as we would have done any extension in the past. This is natural for a developer and lets them see the runtime information that's present, lets them experiment and so on.

But not so these days with Roslyn, several experienced Roslyn developers (@jnm2 @CyrusNajmabadi) pointed out that this is not straightforward because the analyzer is hosted now in a process and not the Visual Studio instance where the analyzer is in use.

Furthermore it seems the motives for that were sound, reliability and robustness etc. It is possible to debug the analyzer of course but this was far from apparent, certainly to a novice with analyzers.

I want to therefore suggest that some mention is made of this, serving as a warning that debugging should not be assumed to work as it used to and that the need for debugging is reduced due to greater emphasis on unit testing. It could also then explain that if you really do want to debug an analyzer there are ways to do this and perhaps explain that with an example.

It seems too, that debugging a CodeLens project has many similarities and would also benefit from some debug related documentation.

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 6e3fc905-7aa1-7f5e-9bfe-fbcef461ad5e
* Version Independent ID: a286e20b-1e43-dc57-e0fb-5a9dee7ec3f6
* Content: [Tutorial: Write your first analyzer and code fix](https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/tutorials/how-to-write-csharp-analyzer-code-fix)
* Content Source: [docs/csharp/roslyn-sdk/tutorials/how-to-write-csharp-analyzer-code-fix.md](https://github.com/dotnet/docs/blob/main/docs/csharp/roslyn-sdk/tutorials/how-to-write-csharp-analyzer-code-fix.md)
* Product: **dotnet-csharp**
* Technology: **csharp-roslyn**
* GitHub Login: @BillWagner
* Microsoft Alias: **wiwagn**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.