Improving the developer experience
Working with the Roslyn compiler can be hard. After all, it’s running inside the context of the compiler. One way to ease the pain is to do unit testing and actually test all your code from tests, something we will look into more in Chapter 17, Static Code Analysis.
Debugging
However, sometimes, you just simply need to see things with your bare eyes through the debugger. The technique I use for this is to add the following code into my Roslyn extension code:
while (!System.Diagnostics.Debugger.IsAttached) Thread.Sleep(10);
Then, I can put breakpoints for the places at which I want to break and then attach the debugger. You want to attach it to the compiler and it typically shows up like the following:
Figure 16.2 – Compiler process to attach to caching
Another thing that can be painful is if you’re doing changes in the extension and these are not reflected. There are a couple of reasons...