Fredrik Ljung

Lead Developer and Architect at Datema Retail

Analyze this: Raise your code quality and follow code standards with the Roslyn analyzers

If you are a developer using Visual Studio, chances are you have noticed squiggly underlines in your code that show up when you have written code the compiler cannot interpret. They are only a small part of the surprisingly extensive Roslyn analyzers tool kit.

Starting with .NET 5 a few analyzers are activated by default, but with some simple configuration, these and hundreds more can be enabled not just for .NET 5+ but previous versions of .NET such as .NET Core and .NET Framework. There are analyzers to help you improve your code quality and analyzers to help you maintain your coding standards. Using .editorconfig files you can configure these analyzers across your entire code base and control which analyzers should be active for different parts of your code base.

In this session, we will dive into how the Roslyn analyzers are activated and configured to display suggestions, warnings, or errors. I will look at strategies on how to add Roslyn analyzers to an existing code base without being swamped in warnings, and show how to validate the rules during a command-line build. Once enabled the Roslyn analyzers help ensure your code is easier to read and safer to run.

Fredrik Ljung

Fredrik Ljung has been a professional developer since 2007, after spending nearly as long digitizing building drawings, installing building automation systems, and delivering snail mail. He has spent the past 12 years on the .NET platform, developing anything from embedded systems for handhelds to cloud-based services and APIs.

Today he works as a Lead Developer and Architect at Datema Retail, where he fights code entropy with his head in the clouds. After 15 years of reading and writing code, he has found an appreciation for code that has a clear structure and is easy to understand.