Search code examples
c#visual-studioroslyn-code-analysis

Code analysis warnings in generated code (like migrations) - Visual Studio (C#)


Most of the warnings that currently I have at my project comes from code that was autogenerated. In most cases, it is (CA1062: Validate arguments of public methods). I noticed that even console hello word app generated by Visual Studio display warning (S1118: Utility classes should not have public constructors).

How I can disable warnings for autogenerated code? (migrations mostly)


Solution

  • You can just add this comment to the top of the file:

    // <auto-generated/>