When developing a Roslyn Source Generator, it's important to verify that it works as intended. There are several approaches to testing: you can compare the generated code output (for example, with snapshot testing), or you can go further and ensure that the generated code behaves correctly when executed. In this post, I'll show example for both ways. Note that I strongly recommend to use the second… [read more]