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 currently in use. The compiler provides everything you need. Simply add #error version to any source file and check the compiler output:

C#
#error version

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

The CS8304 error message includes the Roslyn version (with the commit hash 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?