docs(tests): fix CommentChecker findings across tests/ — 13,392 → 0 (repo-wide scan clean)

Comment/XML-doc changes only:
- add summaries to ~10k test methods, fixtures, fakes and helpers
  (+ <param> on theories, <returns> on async Task methods,
  <inheritdoc/> on interface implementations the checker can resolve)
- strip ~2.6k project-tracking references (WP*, P*-*, row-NN, Task N,
  #NN, Component-0NN) from comments, keeping the explanatory text;
  reword false positives in comments only
- real docs on fakes implementing BCL/library interfaces
  (IDisposable, ILogger, IOptionsMonitor, IAsyncLifetime)
- reword the last 5 src/ false positives (CWE-1236, failures-1,
  year-0001, M365)

Only non-comment edits: four one-line nested classes split across lines
so members can carry docs. Build 0 errors / 0 warnings.
This commit is contained in:
Joseph Doherty
2026-10-07 15:05:49 -04:00
parent 0ffd4bdbea
commit 513fa1aa16
998 changed files with 17896 additions and 2395 deletions
@@ -3,7 +3,7 @@ using ZB.MOM.WW.ScadaBridge.TemplateEngine.Validation;
namespace ZB.MOM.WW.ScadaBridge.TemplateEngine.Tests.Validation;
/// <summary>
/// M3.2: the design-time deploy gate now delegates to the shared
/// The design-time deploy gate now delegates to the shared
/// <c>ZB.MOM.WW.ScadaBridge.ScriptAnalysis</c> analyzer — a real Roslyn semantic
/// forbidden-API verdict plus a real CSharpScript compile against the
/// runtime-mirroring <c>ScriptCompileSurface</c>. These tests assert the
@@ -18,6 +18,7 @@ public class ScriptCompilerTests
{
private readonly ScriptCompiler _sut = new();
/// <summary>Verifies that compiling empty code returns a failure.</summary>
[Fact]
public void TryCompile_EmptyCode_ReturnsFailure()
{
@@ -26,6 +27,7 @@ public class ScriptCompilerTests
Assert.Contains("empty", result.Error, StringComparison.OrdinalIgnoreCase);
}
/// <summary>Verifies that compiling whitespace-only code returns a failure.</summary>
[Fact]
public void TryCompile_WhitespaceOnly_ReturnsFailure()
{
@@ -36,6 +38,7 @@ public class ScriptCompilerTests
// --- Forbidden-API gate (authoritative) ---
/// <summary>Verifies that compiling code that uses a forbidden API returns a failure.</summary>
[Fact]
public void TryCompile_ForbiddenApi_ReturnsFailure()
{
@@ -44,10 +47,11 @@ public class ScriptCompilerTests
Assert.Contains("forbidden", result.Error, StringComparison.OrdinalIgnoreCase);
}
/// <summary>Verifies that compiling code that uses several forbidden APIs reports all of them.</summary>
[Fact]
public void TryCompile_MultipleForbiddenApis_ReportsAll()
{
// #05-T24: the failure message must enumerate EVERY forbidden API, not
// The failure message must enumerate EVERY forbidden API, not
// just the first, so an operator fixing one isn't surprised by the next.
var result = _sut.TryCompile(
"System.IO.File.ReadAllText(\"x\"); System.Diagnostics.Process.Start(\"y\");",
@@ -57,6 +61,8 @@ public class ScriptCompilerTests
Assert.Contains("Process", result.Error, StringComparison.Ordinal);
}
/// <summary>Verifies that adversarial attempts to bypass the forbidden-API check are still rejected.</summary>
/// <param name="code">The adversarial script source under test.</param>
[Theory]
// Namespace alias — the old substring scan never saw "System.IO." spelled out.
[InlineData("using IO = System.IO; IO.File.ReadAllText(\"x\");")]
@@ -73,6 +79,7 @@ public class ScriptCompilerTests
Assert.Contains("forbidden", result.Error, StringComparison.OrdinalIgnoreCase);
}
/// <summary>Verifies that a forbidden type in an otherwise allowed namespace is rejected as forbidden.</summary>
[Fact]
public void TryCompile_ForbiddenTypeInAllowedNamespace_RejectedAsForbidden()
{
@@ -87,6 +94,7 @@ public class ScriptCompilerTests
Assert.Contains("forbidden", result.Error, StringComparison.OrdinalIgnoreCase);
}
/// <summary>Verifies that using the stopwatch from the allowed diagnostics namespace compiles successfully.</summary>
[Fact]
public void TryCompile_StopwatchInAllowedDiagnostics_ReturnsSuccess()
{
@@ -100,6 +108,7 @@ public class ScriptCompilerTests
// --- Real-compile gate (the win over the old structural-only scan) ---
/// <summary>Verifies that compiling code with an undefined symbol returns a failure.</summary>
[Fact]
public void TryCompile_UndefinedSymbol_ReturnsFailure()
{
@@ -111,6 +120,7 @@ public class ScriptCompilerTests
Assert.Contains("compile", result.Error, StringComparison.OrdinalIgnoreCase);
}
/// <summary>Verifies that compiling code with a syntax error returns a failure.</summary>
[Fact]
public void TryCompile_SyntaxError_ReturnsFailure()
{
@@ -121,6 +131,7 @@ public class ScriptCompilerTests
// --- Valid real script against the script API surface ---
/// <summary>Verifies that a valid script using the API surface compiles successfully.</summary>
[Fact]
public void TryCompile_ValidScriptUsingApiSurface_ReturnsSuccess()
{
@@ -137,6 +148,7 @@ public class ScriptCompilerTests
// --- Trigger-expression gate via ValidationService.CheckExpressionSyntax ---
/// <summary>Verifies that checking a valid expression returns null.</summary>
[Fact]
public void CheckExpressionSyntax_ValidExpression_ReturnsNull()
{
@@ -145,6 +157,7 @@ public class ScriptCompilerTests
Assert.Null(error);
}
/// <summary>Verifies that checking an expression that uses a forbidden API returns an error message.</summary>
[Fact]
public void CheckExpressionSyntax_ForbiddenApi_ReturnsMessage()
{
@@ -153,6 +166,7 @@ public class ScriptCompilerTests
Assert.Contains("forbidden", error, StringComparison.OrdinalIgnoreCase);
}
/// <summary>Verifies that checking the same expression twice serves the second call from the cache.</summary>
[Fact]
public void CheckExpressionSyntax_SameExpressionTwice_SecondCallIsCacheHit()
{
@@ -164,6 +178,7 @@ public class ScriptCompilerTests
Assert.Equal(hitsBefore + 1, ScriptCompileVerdictCache.Hits); // FAILS today: no cache use
}
/// <summary>Verifies that a verdict cached for the script surface is not reused for the trigger surface.</summary>
[Fact]
public void CheckExpressionSyntax_ScriptSurfaceVerdict_NotReusedForTriggerSurface()
{
@@ -176,6 +191,7 @@ public class ScriptCompilerTests
Assert.NotNull(error); // green today (no cache), and MUST STAY green after T3 — the T2 key makes it structural
}
/// <summary>Verifies that checking an expression with several forbidden APIs reports all of them.</summary>
[Fact]
public void CheckExpressionSyntax_MultipleForbiddenApis_ReportsAll()
{
@@ -186,6 +202,7 @@ public class ScriptCompilerTests
Assert.Contains("Process", error);
}
/// <summary>Verifies that checking an expression with several compile errors reports all of them.</summary>
[Fact]
public void CheckExpressionSyntax_MultipleCompileErrors_ReportsAll()
{
@@ -197,6 +214,7 @@ public class ScriptCompilerTests
// --- Compile-verdict cache: unchanged code compiles once per process ---
/// <summary>Verifies that compiling the same code twice serves the second call from the cache.</summary>
[Fact]
public void TryCompile_SameCodeTwice_SecondCallIsCacheHit()
{
@@ -209,6 +227,7 @@ public class ScriptCompilerTests
Assert.Equal(hitsBefore + 1, ScriptCompileVerdictCache.Hits);
}
/// <summary>Verifies that the same code on different surfaces computes separate verdicts.</summary>
[Fact]
public void GetOrAdd_SameCodeDifferentSurface_ComputesSeparateVerdicts()
{
@@ -223,6 +242,7 @@ public class ScriptCompilerTests
Assert.Equal(2, ScriptCompileVerdictCache.Count);
}
/// <summary>Verifies that a cached failure formats the script name separately for each caller.</summary>
[Fact]
public void TryCompile_CachedFailure_FormatsNameForEachCaller()
{