Is there a way to disable all Resharper warnings for a file or section of code with a single comment? I\'m trying to create some coding exercises for interviewing potential
You can add the file to the list of "Generated Code" in ReSharpers Options Menu:
Options > CodeInspection > Generated Code
Nial, you can press Ctrl + Shift + Alt + 8 to disable analyses and highligtings in current file.
The following worked for me.
Use the following to suppress the warnings:
#region No Resharper
// All R# warnings are suppressed here
#endregion
you have to configure the ReSharper Inspections
http://www.jetbrains.com/resharper/webhelp/Code_Analysis__Configuring_Warnings.html
You could also use the SuppressMessageAttribute with ReSharper as the category and All as the checkId on the method or the class as shown below. This is more granular than disabling everything in the file if you need the fine grained control.
Tested with Visual Studio 2015 Update 3 and ReSharper Ultimate 10.0.2
[SuppressMessage("ReSharper", "All")]
private void MethodWithMultipleIssues()
{
TestClass instance = null;
// You would get an "Expression is always true" message
if (instance == null)
{
Debug.WriteLine("Handle null");
}
else
{
// You would get an "Code is unreachable" message
Debug.WriteLine("Handle instance");
}
}
According to this blog post on the JetBrains blog, in ReSharper 8 there will be a single comment that can disable resharper in a file.
It will be
// ReSharper disable All
Note: The "All" is case-sensitive, the rest is not.