Skip to content
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

Missing rule ID entries in Ruleset Editor when opening ruleset added to new SDK style project #3573

Open
mavasani opened this issue May 24, 2018 · 6 comments
Labels
Bug This is a functional issue in already written code. Parity-Legacy-API Missing or behavior differences in APIs from the legacy project system. Parity-Legacy-Feature Missing features from the legacy project system. Triage-Investigate Reviewed and investigation needed by dev team
Projects
Milestone

Comments

@mavasani
Copy link
Member

I am using the latest internal VS dogfood build, but this repros on 15.7 as well.

Repro Steps (Repro 1):

  1. Create a new .NET framework class library project (old project system)
  2. Create an empty ruleset file named MyRules.ruleset at the root of project with following contents:
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="My Rules" Description="" ToolsVersion="15.0">
</RuleSet>
  1. Add the following property to the project file to add ruleset to the project: <CodeAnalysisRuleSet>MyRules.ruleset</CodeAnalysisRuleSet>

  2. Add a NuGet package reference to latest stable FxCopAnalyzers package

  3. Open MyRules.ruleset in the ruleset editor by executing Solution Explorer -> Project Node -> References -> Analyzers -> Open Active Ruleset

  4. Search CA1034 in the search box in the ruleset editor and confirm you get 2 entries, one for Managed Binary Analysis and one for Microsoft.CodeQuality.Analyzers:
    image

  5. Repeat the above steps for a new SDK style project .NET standard class library project.

Expected
Searching CA1034 shows same 2 entries for SDK style project, that were seen in step 6 for old style project.

Actual
No matching entries
image

@mavasani mavasani added the Bug This is a functional issue in already written code. label May 24, 2018
@mavasani
Copy link
Member Author

mavasani commented May 24, 2018

Repro Steps (Repro 2):

  1. Create a new solution with one SDK style .NET standard class library project and one old style .NET framework class library project
  2. Create MyRules.ruleset (with same contents as in Repro 1) at the root of the solution and add it as an existing Solution item to this solution.
  3. Add the following property to both the project files to add same ruleset to the projects: <CodeAnalysisRuleSet>..\MyRules.ruleset</CodeAnalysisRuleSet>
  4. Add a NuGet package reference to latest stable FxCopAnalyzers package to both the projects
  5. Double click on the MyRules.ruleset in the solution items to open it in the ruleset editor
  6. Search CA1034 in the search box in the ruleset editor:

Expected
Searching CA1034 shows same 2 entries as were seen in step 6 for Repro 1.

Actual
Only one matching entry, which is for Managed Binary Analysis (old FxCop), with value None.
image

User feels CA1034 analyzer in FxCopAnalyzers package is suppressed, but actually it is still running and you will see CA1034 diagnostics reported by the analyzer in the error list. Checking/Un-checking the CA1034 checkbox for Managed Binary Analysis has no effect on the FxCop analyzer. The only workaround for the user is to manually edit the ruleset file to add the following entry to suppress this rule from the analyzer package:

<Rules AnalyzerId="Microsoft.CodeQuality.Analyzers" RuleNamespace="Microsoft.CodeQuality.Analyzers">
    <Rule Id="CA1034" Action="None" />
</Rules>

@Pilchie
Copy link
Member

Pilchie commented May 24, 2018

@mavasani - any idea what's going wrong in the new project system to trigger this?

@mavasani
Copy link
Member Author

I recall @tmeschter fixed a bunch of stuff to get this to even work for the new project system. The API tying up the ruleset editor to Roslyn to get the correct entries is this one: http://source.roslyn.io/#Microsoft.VisualStudio.LanguageServices/Implementation/Diagnostics/IVisualStudioDiagnosticAnalyzerService.cs,20. Probably run it through the debugger to see why we are not receiving the supported analyzer rule IDs.

@davkean davkean added Parity-Legacy-Feature Missing features from the legacy project system. Parity-Legacy-API Missing or behavior differences in APIs from the legacy project system. labels May 25, 2018
@curia-damiano
Copy link

+1

@jnm2
Copy link

jnm2 commented Feb 10, 2019

If you don't have a legacy csproj in your solution, is there a way to get any PackageReference analyzers to show up, or projects to show up in the 'Project:' dropdown?

@jjmew jjmew modified the milestones: 16.0, 16.X Feb 13, 2019
@panopticoncentral panopticoncentral added Parity-Legacy-Feature Missing features from the legacy project system. and removed Parity-Legacy-Feature Missing features from the legacy project system. labels Feb 14, 2019
@mzhukovs
Copy link

I'm still seeing this issue in VS2019.... my .ruleset file sets Action to None for rules I don't care for and they still get flagged in Error list regardless. E.g.

Is there an ETA for a fix?

@davkean davkean added this to the Backlog milestone Feb 7, 2020
@davkean davkean added the Triage-Investigate Reviewed and investigation needed by dev team label Feb 7, 2020
@kvenkatrajan kvenkatrajan added this to Needs triage in Triage Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is a functional issue in already written code. Parity-Legacy-API Missing or behavior differences in APIs from the legacy project system. Parity-Legacy-Feature Missing features from the legacy project system. Triage-Investigate Reviewed and investigation needed by dev team
Projects
No open projects
Triage
Needs triage
Development

No branches or pull requests

9 participants