How do I suppress FxCop rule 'DoNotCatchGeneralExceptionTypes' with SupressMessage?

前端 未结 1 350
谎友^
谎友^ 2020-12-09 04:52

I\'ve got code that catches everything and logs it. I don\'t normally do this, but I\'m writing an HTTP handler and want to return an appropriate HTTP code. Anyway, I\'m

相关标签:
1条回答
  • 2020-12-09 05:20
    1. In Solution Explorer, right-click your project and choose Properties.
    2. In the Properties window, choose the Build tab.
    3. In the Conditional compilation symbols text box, enter CODE_ANALYSIS.
    4. In the code where you want to suppress certain messages, add the namespace System.Diagnostics.CodeAnalysis to the using section.
    5. In FxCop, right-click the message you want to suppress and select Copy As -> SuppressMessage.
    6. In your C# code, paste the SuppressMessage attribute in your code.

    Your SupressMessage looks correct, so it could be the missing conditional compilation symbol!

    Hope this helps, at least works on my machine ;) Greetz, Tom.

    Source

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