Roslyn Analyzers

With Visual Studio 2015 Preview out, .NET being open-sourced and Roslyn being available, the community is actively developing many analyzers.

The integration of analyzers is one of the coolest features of the Roslyn (alias .NET compiler platform) project. It basically allows developers to extend the inspection scope of the compiler by custom rules. That way DSLs, usage of frameworks or extended parsing (e.g. regular expressions - which are just string literals) is possible. This makes code more robust, best practice driven and readable.

The following gallery contains screenshots of some analyzers, that people started creating. Most of these analyzers have been written in a very little amount of time. Nevertheless, even though some may be not so serious or useful for general projects, others could be highly useful depending on your projects or programming style.

We see analyzers, e.g., to detect (and fix) usages of int, byte etc., with their respective (real) types such as Int32, Byte and so on. Of course this is a pure style question, which is why this is only an analyzer (optional as all analyzers).

There are also analyzers that follow the rules of FxCop. The Roslyn team has published a quite complete solution as a NuGet package. This one will detect most probable issues.

Finally there is a lot of movement going on in the community. First of all a lot of interesting open-source projects have been initialized. It is safe to say that a single location for collecting useful (general-purpose) analyzers seems like a good idea. Some (companies?) are also trying to create general purpose analyzers on their own.

AngleSharp will also offer an analyzer. This one won't be in any of the general purpose repositories, as it is bound (and only used with) AngleSharp. The analyzer will pre-check some library usages, help with configuration and do pre-compilation analysis of literals. Therefore problems and mistakes in string literals do not end up (unrecognized) in published binaries.

I am really curious how the analyzer community will develop. Let's hope for some awesome general-purpose analyzers and even better specialized analyzers for popular frameworks and libraries.

Created . Last updated .

References

Sharing is caring!