Visual Studio 2015 - What does the "Analyzers" reference mean?

20,695

Solution 1

Live Code Analyzers are used to add custom error messages and warnings that appear live as you're typing, along with automatic code fixes to help you clean them up. They are available as NuGet packages that you add to your projects in Visual Studio 2015.

It is one of the best and helpful key new features of Visual Studio 2015 that lets a NuGet package enable custom warnings and errors in the editor live as you type the code, with automatic code fixes that can clean up those issues for us.

Packages can even be bundled together as a “code-aware library” that pulls in both an API and the domain-specific analyzers to make sure that you stay on course when using it.

We'll have a targeted guidance from the moment we download the NuGet package. And because these analyzers are part of our project, everyone on your team gets to see the same warnings.

Edit 1 :

Analyzers have rules attached to them like below :

enter image description here

These rules focus on the most critical problems in your code, including potential security holes, application crashes, and other important logic and design errors. You should include this rule set in any custom rule set you create for your projects.

Solution 2

Currently there are a number of good Analyzers available – Microsoft.AnalyzerPowerPack, Code Cracker, CSharp Essentials, SonarLint etc

Each of these analyzers have their own rule set, so we can decide which analyzer to add, based on our requirements. Once installed via Nuget, the light bulbs and quick actions in VS2015 will pick up the associated rule set and provide the developers with coding assistance on the fly.

Share:
20,695
citykid
Author by

citykid

Versatile software craftsman. Focus on software engineering and human computer interaction (design). Vanilla code writer. preferred tools dotnet core runtime on all platforms, typescript or c++ or rust.

Updated on September 14, 2020

Comments

  • citykid
    citykid about 2 years

    Creating a plain C# Console App in Visual Studio 2015 Preview, we get a pseudo reference named "Analyzers":


    Expanded Solution Explorer project "References" showing "Analyzers" entry

    What does the "Analyzers" reference just above mean?

    The project file has nothing inside and the properties window shows nothing (completely blank) about this entry (though, in contrast to "reference properties" it says "folder properties" in the header, but that does not say much).

    I would expect this to be related to Roslyn, but I have no idea. I have ReSharper installed, but I don't assume it has anything to do with it.

    Edit 6.8.2016

    The accepted answer explains the tooling provided by analyzers, but leaves open why a development tool becomes a (runtime?) reference. Actually it is not a runtime reference, unlike the other references. So the answer to this miracle is Hans Passants comment below:

    They picked a clumsy place to add the code analyzers feature, they just couldn't find a better place without drastically overhauling the solution explorer and nuget. – Hans Passant May 26 '15 at 8:59

  • citykid
    citykid over 7 years
    i appreciate for your input, but the question is still open: why the reference (assembly?). we have code analysis since 10 years and there was never a reference. read also my question above: why a reference even if I did not download any nuget package?
  • Tharif
    Tharif over 7 years
    @citykid ..If you notice carefully while right click the analyzer you can see the Manage NuGet packages ,but eventhough we have not installed NuGet packages why does that appear ?.. thanks
  • citykid
    citykid over 7 years
    It becomes clearer, so the Analyers node is a folder for analyzers. I do not see anything with NuGet, the entries in the context menu are "add analyzer" and "Open active ruleset". Upon Add analyzers, I can browse assemblies.