Refactor code structure and optimize performance across multiple modules

This commit is contained in:
StellaOps Bot
2025-12-26 20:03:22 +02:00
parent c786faae84
commit f10d83c444
1385 changed files with 69732 additions and 10280 deletions

View File

@@ -18,7 +18,8 @@ namespace StellaOps.AirGap.Policy.Analyzers.Tests;
public sealed class HttpClientUsageAnalyzerTests
{
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task ReportsDiagnostic_ForNewHttpClient()
{
const string source = """
@@ -39,7 +40,8 @@ public sealed class HttpClientUsageAnalyzerTests
Assert.Contains(diagnostics, d => d.Id == HttpClientUsageAnalyzer.DiagnosticId);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task DoesNotReportDiagnostic_InsidePolicyAssembly()
{
const string source = """
@@ -57,7 +59,8 @@ public sealed class HttpClientUsageAnalyzerTests
Assert.DoesNotContain(diagnostics, d => d.Id == HttpClientUsageAnalyzer.DiagnosticId);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task CodeFix_RewritesToFactoryCall()
{
const string source = """
@@ -113,6 +116,7 @@ public sealed class HttpClientUsageAnalyzerTests
{
using var workspace = new AdhocWorkspace();
using StellaOps.TestKit;
var projectId = ProjectId.CreateNewId();
var documentId = DocumentId.CreateNewId(projectId);
var stubDocumentId = DocumentId.CreateNewId(projectId);

View File

@@ -33,7 +33,8 @@ public sealed class PolicyAnalyzerRoslynTests
{
#region AIRGAP-5100-005: Expected Diagnostics & No False Positives
[Theory]
[Trait("Category", TestCategories.Unit)]
[Theory]
[InlineData("var client = new HttpClient();", true, "Direct construction should trigger diagnostic")]
[InlineData("var client = new System.Net.Http.HttpClient();", true, "Fully qualified construction should trigger diagnostic")]
[InlineData("HttpClient client = new();", true, "Target-typed new should trigger diagnostic")]
@@ -60,7 +61,8 @@ public sealed class PolicyAnalyzerRoslynTests
hasDiagnostic.Should().Be(shouldTrigger, reason);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task NoDiagnostic_ForHttpClientParameter()
{
const string source = """
@@ -83,7 +85,8 @@ public sealed class PolicyAnalyzerRoslynTests
"Using HttpClient as parameter should not trigger diagnostic");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task NoDiagnostic_ForHttpClientField()
{
const string source = """
@@ -107,7 +110,8 @@ public sealed class PolicyAnalyzerRoslynTests
"Declaring HttpClient field should not trigger diagnostic");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task NoDiagnostic_ForFactoryMethodReturn()
{
const string source = """
@@ -138,7 +142,8 @@ public sealed class PolicyAnalyzerRoslynTests
"Using factory method should not trigger diagnostic");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task NoDiagnostic_InTestAssembly()
{
const string source = """
@@ -160,7 +165,8 @@ public sealed class PolicyAnalyzerRoslynTests
"Test assemblies should be exempt from diagnostic");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task NoDiagnostic_InPolicyAssembly()
{
const string source = """
@@ -179,7 +185,8 @@ public sealed class PolicyAnalyzerRoslynTests
"Policy assembly itself should be exempt");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task Diagnostic_HasCorrectSeverity()
{
const string source = """
@@ -203,7 +210,8 @@ public sealed class PolicyAnalyzerRoslynTests
"Diagnostic should be a warning, not an error");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task Diagnostic_HasCorrectLocation()
{
const string source = """
@@ -228,7 +236,8 @@ public sealed class PolicyAnalyzerRoslynTests
lineSpan.StartLinePosition.Line.Should().Be(8, "Diagnostic should point to line 9 (0-indexed: 8)");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task MultipleHttpClientUsages_ReportMultipleDiagnostics()
{
const string source = """
@@ -265,7 +274,8 @@ public sealed class PolicyAnalyzerRoslynTests
#region AIRGAP-5100-006: Golden Generated Code Tests
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task CodeFix_GeneratesExpectedFactoryCall()
{
const string source = """
@@ -301,7 +311,8 @@ public sealed class PolicyAnalyzerRoslynTests
"Code fix should match golden output exactly");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task CodeFix_PreservesTrivia()
{
const string source = """
@@ -326,7 +337,8 @@ public sealed class PolicyAnalyzerRoslynTests
"Leading comment should be preserved");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task CodeFix_DeterministicOutput()
{
const string source = """
@@ -352,7 +364,8 @@ public sealed class PolicyAnalyzerRoslynTests
result2.Should().Be(result3, "Code fix should be deterministic");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task CodeFix_ContainsRequiredPlaceholders()
{
const string source = """
@@ -383,7 +396,8 @@ public sealed class PolicyAnalyzerRoslynTests
fixedCode.Should().Contain("REPLACE_INTENT");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task CodeFix_UsesFullyQualifiedNames()
{
const string source = """
@@ -408,7 +422,8 @@ public sealed class PolicyAnalyzerRoslynTests
fixedCode.Should().Contain("global::System.Uri");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task FixAllProvider_IsWellKnownBatchFixer()
{
var provider = new HttpClientUsageCodeFixProvider();
@@ -418,7 +433,8 @@ public sealed class PolicyAnalyzerRoslynTests
"Should use batch fixer for efficient multi-fix application");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task Analyzer_SupportedDiagnostics_ContainsExpectedId()
{
var analyzer = new HttpClientUsageAnalyzer();
@@ -428,7 +444,8 @@ public sealed class PolicyAnalyzerRoslynTests
supportedDiagnostics[0].Id.Should().Be("AIRGAP001");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task CodeFixProvider_FixableDiagnosticIds_MatchesAnalyzer()
{
var analyzer = new HttpClientUsageAnalyzer();
@@ -466,6 +483,7 @@ public sealed class PolicyAnalyzerRoslynTests
{
using var workspace = new AdhocWorkspace();
using StellaOps.TestKit;
var projectId = ProjectId.CreateNewId();
var documentId = DocumentId.CreateNewId(projectId);
var stubDocumentId = DocumentId.CreateNewId(projectId);