I'm using Visual Studio 2022 (17.4.4), and when I create a new empty .NET 6 project, Code Analysis doesn't work.
According to MSDN, Roslyn Code Analyzers are automatically enabled for every new .NET 6 project:
Starting in Visual Studio 2019 16.8 and .NET 5.0, these analyzers are included with the .NET SDK. Analysis is enabled, by default, for projects that target .NET 5.0 or later.
Here's the steps I followed:
How can I get Code Analysis to work here?
Console.WriteLine("asdf".IndexOf("/")); // expecting CA1307 or CA1310 here
Console.WriteLine("Hello, World!");
Since 5.0 CA1307
is Disabled
and CA13010
is Hidden
you can have a complete view of Roslyn rules here