CA1508 is now significantly slower to analyze under certain conditions (see below).
Steps to reproduce
Create a file Test.cs as follows:
namespace CA1508Issue
{
public class Test
{
private void TestMethod()
{
var inputs = new Input[]
{
new Input { Prop1 = "abc", Prop2 = "def", Prop3 = "ghi" },
new Input { Prop1 = "abc", Prop2 = "def", Prop3 = "ghi" },
new Input { Prop1 = "abc", Prop2 = "def", Prop3 = "ghi" },
// NB cut and paste this line 1000 times, so that the inputs array contains 1000 elements
};
foreach (var input in inputs)
{
// The follow line may contain any conditional (I believe)
var test = (1 == 2) ? 3 : 4;
}
}
private class Input
{
public string Prop1 { get; set; }
public string Prop2 { get; set; }
public string Prop3 { get; set; }
}
}
}
Run dotnet build. The build executes successfully in a reasonable amount of time (for me, 13 seconds). Various warnings are correctly returned.
In global.json, change the SDK version to 8.0.100.
Run dotnet build. The build has the same output, but executes much more slowly (for me, 1 minute 42 seconds). The same warnings are returned. This is also the case if the .csproj file targets net8.0.
Create a file .editorconfig as follows:
[*.cs]
dotnet_diagnostic.CA1508.severity = none
Run dotnet build. The build executes quickly again (for me, 3 seconds).
Analyzer
Diagnostic ID: CA1508:
Avoid dead conditional code
Analyzer source
SDK: Built-in CA analyzers in .NET 8 SDK
Version: SDK 8.0.100
Describe the bug
CA1508 is now significantly slower to analyze under certain conditions (see below).
Steps to reproduce
Test.cs
as follows:CA1508Issue.csproj
as follows:global.json
as follows:Run
dotnet build
. The build executes successfully in a reasonable amount of time (for me, 13 seconds). Various warnings are correctly returned.In
global.json
, change the SDK version to8.0.100
.Run
dotnet build
. The build has the same output, but executes much more slowly (for me, 1 minute 42 seconds). The same warnings are returned. This is also the case if the .csproj file targets net8.0.Create a file
.editorconfig
as follows:dotnet build
. The build executes quickly again (for me, 3 seconds).