How do you get breakpoints to work in a code analyzer project?

Eric Woodruff 121 Reputation points
2022-09-07T20:57:02.033+00:00

I created a code analyzer solution using the Analyzer with Code Fix (.NET Standard) template in VS 2022. I set the VSIX project as the startup project and run it. Using the basic example code unchanged, I can run it and see that the analyzer is working and the code fix is working. If I set breakpoints in the code fix project methods and do something in the editor to invoke the code fix, the breakpoints do get hit and it stops on them as expected. However, if I set breakpoints in the code analyzer methods, they are never hit even though they are showing as active. So, the question is how do I get the breakpoints to work in the code analyzer project so that I can step through and debug the code I write for the analyzer?

Developer technologies | Visual Studio | Debugging
0 comments No comments
{count} votes

Accepted answer
  1. Anna Xiu-MSFT 31,056 Reputation points Microsoft External Staff
    2022-09-08T03:31:49.307+00:00

    Hi @Eric Woodruff ,

    Welcome to Microsoft Q&A!

    Please go to Tools > Options > Text Editor > C# > Advanced > Uncheck 'Run code analysis in separate process (requires restart)'.
    You can refer to the similar issue:
    https://github.com/dotnet/roslyn-sdk/issues/889

    Sincerely,
    Anna
    *
    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    2 people found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.