Getting Roslyn (C# compiler) and Language versions

  • Gérald Barré

When a user reports an error in a Roslyn Analyzer or a Source Generator, you may need to know the version of Roslyn and the language version that are currently being used. The compiler provides everything needed. Indeed, you simply need to add #error version to any source file and check the compiler output:

C#
#error version

// ... rest of the file ...

The error message CS8304 will contain the version of Roslyn, including the commit from the Roslyn repository, and the language version.

Do you have a question or a suggestion about this post? Contact me!

Follow me:
Enjoy this blog?Buy Me A Coffee💖 Sponsor on GitHub