-
Notifications
You must be signed in to change notification settings - Fork 468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] Easiest way to configure Microsoft.CodeAnalysis.FxCopAnalyzers to apply classical rulesets #943
Comments
This is one of the primary tasks that we need to do prior to releasing 1.2.0 bits of this package. Currently, there is no non-trivial way to do this. |
FYI @srivatsn |
Do we have rulset support in version 2.0? |
@jinujoseph There have been multiple requests for this now. I will spend some time on this tomorrow to see if I can come up with a quick solution so our cibuild also generates:
I think we need this for a good compat story anyways. |
+1 |
1 similar comment
+1 |
We now generate the following set of ruleset files for each analyzer package: 1. AllRulesEnabled.ruleset 2. AllRulesDefault.ruleset 3. AllRulesDisabled.ruleset For every unique rule category within the pacakge, say security, performance, design, etc., we generate 2 ruleset files per category. For example, for Security, we generate: 1. SecurityRulesEnabled.ruleset (all security rules enabled, including the ones with IsEnabledByDefault = false. All rules from other categories are disabled) 2. SecurityRulesDefault.ruleset (all security rules have default severity and IsEnabledByDefault is honored. All rules from other categories are disabled) For the core FxCopAnalyzers package, we also package all the legacy FxCop rulesets, which have been edited to include AllRulesDisabled.ruleset upfront to match legacy FxCop configuration. Fixes dotnet#943
I have a PR out to package classical and auxiliary rulesets along with each analyzer package: #1718 Kindly, take a look at the description and screenshots in the PR to confirm this satisfies everyone's ask. |
We now generate the following set of ruleset files for each analyzer package: 1. AllRulesEnabled.ruleset 2. AllRulesDefault.ruleset 3. AllRulesDisabled.ruleset For every unique rule category within the pacakge, say security, performance, design, etc., we generate 2 ruleset files per category. For example, for Security, we generate: 1. SecurityRulesEnabled.ruleset (all security rules enabled, including the ones with IsEnabledByDefault = false. All rules from other categories are disabled) 2. SecurityRulesDefault.ruleset (all security rules have default severity and IsEnabledByDefault is honored. All rules from other categories are disabled) For the core FxCopAnalyzers package, we also package all the legacy FxCop rulesets, which have been edited to include AllRulesDisabled.ruleset upfront to match legacy FxCop configuration. Fixes #943
Published on NuGet: https://www.nuget.org/packages/Microsoft.CodeAnalysis.FxCopAnalyzers/2.6.2-beta1 |
Also tagging @gewarren. We probably want to document #1718 (comment) and #1718 (comment) on docs.microsoft.com, so customers who wants to migrate from legacy FxCop to FxCop analyzers without altering their existing rule configuration can use the new rulesets that we package with the analyzer packages. |
@mavasani will do, thanks. |
Looks good. Thanks 👍 |
Can you please describe how those rulesets can be used in a project? I tried adding |
@zivillian Relative paths will not work as the ruleset location is relative to the NuGet package root. You either need to explicitly define/reference NuGet package root and package version in your absolute path OR copy over the required ruleset files to your project directory. |
For the classical static code analysis you could use predefined Microsoft rule sets like Managed Recommended Rules.
Is there an easy way to configure FxCopAnalyzers to only apply rules that are within a certain rule set? The workflow we are currently using is the following:
This is somehow tedious, so I wonder if there is a better way to do this?
The text was updated successfully, but these errors were encountered: