Search Unity

Modifying Visual Studio 2019 Code Analysis Rules

Discussion in 'Code Editors & IDEs' started by Kybernetik, May 13, 2019.

  1. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    I just installed Visual Studio Community 2019 and it's giving me code analysis suggestions on all my private MonoBehaviour messages (like Awake) saying I should remove the unused member. It gives me two options to suppress it:
    1. Suppress in source using #pragma warning disable.
    2. Suppress in suppression file using an attribute that applies to the whole assembly.
    #1 Would be a poor solution because I would need to put that at the top of every file. #2 would be better, but I would still need to duplicate the file for every assembly (editor and plugins folders and for every assembly definition file).

    Normally I would just open the project properties in VS, go to the code analysis tab, and change the ruleset as necessary. But Unity projects don't allow you to open their properties and even if I edit the text file manually the change just gets reverted next time Unity regenerates the file.

    I have the Solution Error Visualiser extension which shows red/yellow/blue underlines on files in the Solution Explorer if they contain any errors/warnings/suggestions. In VS 2017 I was able to keep everything clean, but now I'm getting blue underlines all over the place which will hide any actually relevant code suggestions.

    So how should I deal with this?