0

I thought I'd delve into writing a custom code analyzer, so that I can enforce a rule and and allow code fixes to be applied. Upon opening VS after installing the required workload I see the following available templates:

enter image description here

  • Code Refactoring
  • Analyzer with Code Fix
  • Standalone Code analysis Tool

What are the differences? How would i know what to pick?

sommmen
  • 6,570
  • 2
  • 30
  • 51
  • The following tutorial is about 'Analyzer with Code Fix' : [Tutorial: Write your first analyzer and code fix](https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/tutorials/how-to-write-csharp-analyzer-code-fix) – Xingyu Zhao Dec 14 '20 at 06:24

1 Answers1

2
  • The "Code Refactoring" template gives you a VSIX extension with a separate project for the refactorings. The extension shows a new entry in the "Quick Actions" menu when the cursor is on matching code. This way, you can provide a quick code fix without having to define an additional analyzer ID and showing the user an entry in the error list.

  • The "Analyzer with Code Fix" template gives you a VSIX extension and a separate project for the analyzer which can also be deployed via NuGet. The analyzer can be used to show a squiggly line below matching code, showing an entry in the error list, which can be configured to be a message, warning or even an error - providing a code fix is optional.

  • The "Standalone Code Analysis Tool" template gives you a console project, that will open a solution workspace. This way, you can analyze your projects without having to install any VSIX extensions or NuGet packages to the project or the IDE - it is supposed to be called from a command line, which makes most sense when used on a build server. The template does not include any analyzers or refactorings.

Stefan El
  • 56
  • 1
  • 8