TheMagnificent11
TheMagnificent11

Reputation: 1456

Visual Studio 2015 - Turn off "'private' modifier is redundant" IntelliSense warning (RECS014)

Is it possible to turn off the "'private' modifier is redundant" (RECS014) IntelliSense warning?

Upvotes: 14

Views: 2259

Answers (3)

Brett
Brett

Reputation: 437

  1. Install the Refactoring Essentials extension.
  2. Inside VS, expand the 'References' node in Solution Explorer and right click on 'Analyzers' and select 'Open Active Rule Set'
  3. Expand the 'RefactoringEssentials' node and change RECS0145 from Warning to None
  4. Repeat for all other projects or copy and paste the .ruleset file into other projects and manually change the name and description (the file is simply XML)

https://github.com/icsharpcode/RefactoringEssentials/wiki/Custom-Rule-Sets-for-Analyzers

Upvotes: 20

igorushi
igorushi

Reputation: 1995

Refactoring Essentials Plugin, proposes multiple fixes for this warning.

  1. Using #pragma directive as Gianpiero has mentioned

  2. In addition there is a project level fix : place following line in GlobalSuppressions.cs project file:
    [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Redundancies in Code", "RECS0145:Removes 'private' modifiers that are not required")]

Upvotes: 1

Gianpiero
Gianpiero

Reputation: 3547

No google solution found, so I tried for a while finding the solution.

If you want to suppress only a specific private entry, use something like:

#pragma warning disable RECS0145
    private int myvar;
#pragma warning restore RECS0145

If you want to suppress all these warnings into a whole file, use the #pragma at the beginning of the file:

#pragma warning disable RECS0145

If you want to disable the warning in the whole project, use a compiler directive: open the project's properties, go in the "Build" tab and add the comma-separated list of codes you wish to suppress in the "Suppress warning" textbox.

enter image description here

Upvotes: 1

Related Questions