Search code examples
visual-studio-mac

Visual Studio for MAC - support of roslyn analyzers


Does Visual Studio for Mac support roslyn analyzers, especially Microsoft.CodeAnalysis.FxCopAnalyzers?


Solution

  • The analyzer nuget packages can be added to a project in XamarinStudio/VS2017 for mac but you need to manually edit the project files to add the ItemGroup.Analyser project items linking to the dlls. These do not install on a mac as the installers are provided as custom PowerShell install scripts in the nuget packages. Note you will need to maintain the sections manually when updating the analyzer packages or removing them.

    Ex: I needed to add the following to the project file, to install the Microsoft.CodeQuality.Analyzers 2.6.0 and also reload the project file.

    <ItemGroup>
      <Analyzer Include="..\..\packages\Microsoft.CodeQuality.Analyzers.2.6.0\analyzers\dotnet\cs\Microsoft.CodeQuality.Analyzers.dll" />
      <Analyzer Include="..\..\packages\Microsoft.CodeQuality.Analyzers.2.6.0\analyzers\dotnet\cs\Microsoft.CodeQuality.CSharp.Analyzers.dll" />
    </ItemGroup>
    

    Once added and the project is re-build I received the CA warnings from the project, and they were displayed in the standard errors pane.