'How to remove Visual Studio 'IDE' warnings for a Unity project?

I've been trying to get rid off IDE warnings for a Unity project:

While csc.rsp works for CS warnings, it doesn't for IDE warnings:

-nowarn:CS0649,IDE0063,IDE0071

Question:

How to remove IDE warnings for a Unity project?



Solution 1:[1]

Here's the simplest and most straightforward approach:

(for suppressing warnings solution-wide)

  • no need to use CodeAnalysisRuleSet
  • no need to use AssetPostprocessor nor ProjectFilesGenerator
    • both being error-prone and unfriendly as one can be

Instead,

.editorconfig

Visual Studio 2019 is smart enough to pick it up and apply it to all projects:

[*.{cs,vb}]

# IDE0051 Private member is unused.
dotnet_diagnostic.IDE0051.severity = none

If you need more granularity, add specific .editorconfig files at projects that needs different rules.

Of course you lose the GUI editing aspect but it isn't really a stopper in my case.

Solution 2:[2]

You can mark these Unity functions as used by the engine by Regenerate project file in Unity Preferences:

Edit Preferences => External Tools => Regenerate project files

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 PhĂșc Anh