My Digital Garden

New Project setup - CSharp

New Project setup - CSharp

  • set warnings as errors
  • turn on code analysis

Set warnings as errors

Implement this on all production code projects (optional for test projects).

in Visual Studio:

  • open project properties
  • Build > Errors and warnings
    • Set warning level to as high as possible
    • Set "Treat warnings as errors"
    • repeat for all build configurations

in command line / build scripts use the following flags:

  • -warnaserror
  • -warn latest

Turn on code analysis

  • for all production projects install Nugets:

    • Microsoft.CodeAnalysis.Analyzers
    • Microsoft.CodeAnalysis.CSharp.Workspaces
  • edit project file to include


See also