Disable all Resharper warnings with a comment

后端 未结 6 709
没有蜡笔的小新
没有蜡笔的小新 2020-12-15 16:59

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

6条回答
  •  天命终不由人
    2020-12-15 17:55

    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");
        }
    }
    

提交回复
热议问题