Disable all Resharper warnings with a comment

后端 未结 6 697
没有蜡笔的小新
没有蜡笔的小新 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:35

    You can add the file to the list of "Generated Code" in ReSharpers Options Menu:

    Options > CodeInspection > Generated Code
    
    0 讨论(0)
  • 2020-12-15 17:51

    Nial, you can press Ctrl + Shift + Alt + 8 to disable analyses and highligtings in current file.

    0 讨论(0)
  • 2020-12-15 17:51

    The following worked for me.

    • Add "No Resharper" to Generated Code Regions in R# -> Options -> Code Inspection -> Generated Code
    • Use the following to suppress the warnings:

      #region No Resharper
      
      // All R# warnings are suppressed here
      
      #endregion
      
    0 讨论(0)
  • 2020-12-15 17:55

    you have to configure the ReSharper Inspections

    http://www.jetbrains.com/resharper/webhelp/Code_Analysis__Configuring_Warnings.html

    0 讨论(0)
  • 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");
        }
    }
    
    0 讨论(0)
  • 2020-12-15 17:56

    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.

    0 讨论(0)
提交回复
热议问题