Reputation: 1456
Is it possible to turn off the "'private' modifier is redundant" (RECS014) IntelliSense warning?
Upvotes: 14
Views: 2259
Reputation: 437
RECS0145
from Warning
to None
.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
Reputation: 1995
Refactoring Essentials Plugin, proposes multiple fixes for this warning.
Using #pragma
directive as Gianpiero has mentioned
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
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.
Upvotes: 1