Roslyn-analyzers: FxCopAnalyzers v2.9.3 - Unable to disable rule enforcement with ruleset file

Created on 7 Jun 2019  路  7Comments  路  Source: dotnet/roslyn-analyzers

Analyzer package

Microsoft.CodeAnalysis.FxCopAnalyzers

Package Version

v2.9.3

Diagnostic ID

CA1062
CA1303

Repro steps

  1. Update from v.2.9.2

Expected behavior

No errors - or if new ones found due to version update enforcing new rules, I should be able to turn off with settings in a ruleset file

Actual behavior

Lots of CA1062 and some CA1303 errors reported. As I dont want these rules enforced in my code base at this time I turned them off in my ruleset file (as I have turned off others in the past). They are still being reported as errors. Changing them to warning has no effect either. Only way to get a successful build (short of fixing the "errors" :) ) is to revert back to v2.9.2

Most helpful comment

Please consider documenting these modifications on the release page or somewhere else.

Thanks, this is good feedback. We will ensure the release page mentions new rules shipped with each release.

All 7 comments

Similar thing here. My code base clearly violates both CA1062 and CA1303, but these were not reported with analyzers <=2.9.2 (using default rule settings). Version 2.9.3 reports these violations. I have not yet checked if I'm not able to disable them as the OP says.

Is it possible that 2.9.3 (at least NuGet version) inadvertently enabled these rules by default, whereas they had been disabled earlier?

Same here.
Additionally the rule CA2000 is reported since version 2.9.3 but not with <=2.9.2

Couple of things:

  1. The CA rules mentioned here are newly implemented rules, so it is expected to see the violations from these rules by default in 2.9.3 package. @ArturDorochowicz @zplan Note that it is expected that every analyzer package (not just the ones from this repo) will enable new rules by default with every new package version - this is the key to improved discoverability of new analyses in the package. The end user has complete control over turning off the new rules if they feel they are not ready to fix/baseline the violations at the time of upgrade.
  2. @slubowsky Suppression/disabling of diagnostics is not controlled by the analyzer package, but by the compiler and the IDE diagnostic service for build and live diagnostics respectively, that execute these analyzers. We have recently had bugs in the IDE where updating the ruleset file does not immediately update the state in the IDE, and user has to close and re-open solution for the changes to take effect. All these known issues have been fixed, so the latest VS2019 drop from https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes should have them. What version of VS are you on? Can you please try the latest VS version?

I was on 16.2.0 Preview 1.0 and reopening the solution after editing the ruleset file did fix the problem. Thanks!

Note that it is expected that every analyzer package (not just the ones from this repo) will enable new rules by default with every new package version

@mavasani While I appreciate that each version of an analyzer package can have different default configuration, let me suggest that in this particular case it was surprising, given the fact that it was just a _patch_ update and there's no mention of this on the release page. Please consider documenting these modifications on the release page or somewhere else.

Please consider documenting these modifications on the release page or somewhere else.

Thanks, this is good feedback. We will ensure the release page mentions new rules shipped with each release.

We will ensure the release page mentions new rules shipped with each release.

Thanks, I was also not expecting new rules for a minor version update/patch and no info in the release notes.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paulomorgado picture paulomorgado  路  3Comments

paulomorgado picture paulomorgado  路  3Comments

onyxmaster picture onyxmaster  路  3Comments

Youssef1313 picture Youssef1313  路  4Comments

KrisVandermotten picture KrisVandermotten  路  3Comments