Stylecopanalyzers: VS2019 and C# 8.0

Created on 2 Apr 2019  路  4Comments  路  Source: DotNetAnalyzers/StyleCopAnalyzers

Plans for accommodating C# 8.0 language features and VS2019?

c# 8

Most helpful comment

Ofcourse馃槈 StyleCop.Analyzers should be compatible with VS2019, but any issues found with VS2019 will be resolved as quickly as possible. Support for new C# 8.0 features will be a bit further away, as we need to do some analysis / discussion on how to incorporate those features.

All 4 comments

Ofcourse馃槈 StyleCop.Analyzers should be compatible with VS2019, but any issues found with VS2019 will be resolved as quickly as possible. Support for new C# 8.0 features will be a bit further away, as we need to do some analysis / discussion on how to incorporate those features.

@vweijsters that's great, thanks for the update - not sure if this is a VS2019 specific issue but when I modify the the priority for a rule (e.g. "None"), regardless of whether it's via the right-click option on the analyzer under the project or directly via the .ruleset file, - it doesn't actually seem to take effect and the rule keeps getting flagged in the editor and Error List... any ideas?

In general I would say that the .ruleset file is not properly referenced in the .csproj file. You should find (multiple instances of) the <CodeAnalysisRuleSet> </CodeAnalysisRuleSet> tags and in between should be a reference. Alternatively you can try right clicking the .ruleset and selecting the set as active ruleset option.

Hey thanks again @vweijsters - very strange I had the following setup in a Xamarin Forms project:

Directory.Build.props:

<Project>

  <PropertyGroup>
    <CodeAnalysisRuleSet>..\..\StyleCop.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

</Project>

StyleCop.ruleset:

<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="New Rule Set" Description=" " ToolsVersion="16.0">
  <Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
    <Rule Id="SA1200" Action="None" />
    <Rule Id="SA1101" Action="None" />
    <Rule Id="SA1516" Action="None" />
  </Rules>
</RuleSet>

It worked fully for the .NET Standard class lib but for the platform projects (iOS and Android) it only managed to get the nuget in and not the reference to the ruleset - very bizarre... perhaps has something to do with those .csproj not being Sdk style... anyway just had to manually paste in the property group into those csprojs instead of relying on Directory.Build.props for them and it was fine... sorry for the rant.

Thanks again.

Was this page helpful?
0 / 5 - 0 ratings