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
@@ -4,9 +4,9 @@ using ZB.MOM.WW.ScadaBridge.SiteRuntime.Scripts;
namespace ZB.MOM.WW.ScadaBridge.SiteRuntime.Tests.Scripts;
/// <summary>
/// WP-19: Script Trust Model tests — validates forbidden API detection and compilation.
/// Script Trust Model tests — validates forbidden API detection and compilation.
///
/// As of the M3.3 consolidation, <c>ScriptCompilationService.ValidateTrustModel</c>
/// As of the consolidation, <c>ScriptCompilationService.ValidateTrustModel</c>
/// delegates its forbidden-API verdict to the shared authoritative
/// <c>ScriptAnalysis.ScriptTrustValidator</c>, which is stricter than SiteRuntime's
/// original deny-list: ALL of <c>System.Net</c> is forbidden (not just Sockets/Http),
@@ -26,11 +26,13 @@ public class ScriptCompilationServiceTests
private readonly SiteScriptCompileCache _cache = new();
private readonly ScriptCompilationService _service;
/// <summary>Initializes the test class with a compilation service.</summary>
public ScriptCompilationServiceTests()
{
_service = new ScriptCompilationService(NullLogger<ScriptCompilationService>.Instance, _cache);
}
/// <summary>Verifies that compiling a valid script succeeds.</summary>
[Fact]
public void Compile_ValidScript_Succeeds()
{
@@ -40,6 +42,7 @@ public class ScriptCompilationServiceTests
Assert.Empty(result.Errors);
}
/// <summary>Verifies that compiling the same code twice shares a single Roslyn compile.</summary>
[Fact]
public void Compile_SameCodeTwice_SharesOneRoslynCompile()
{
@@ -55,6 +58,7 @@ public class ScriptCompilationServiceTests
Assert.Equal(1, _cache.Count);
}
/// <summary>Verifies that a script and a trigger expression with the same code do not cross-contaminate.</summary>
[Fact]
public void Compile_ScriptAndTriggerExpression_DoNotCrossContaminate()
{
@@ -66,6 +70,7 @@ public class ScriptCompilationServiceTests
Assert.Equal(0, _cache.Hits);
}
/// <summary>Verifies that compiling invalid syntax returns errors.</summary>
[Fact]
public void Compile_InvalidSyntax_ReturnsErrors()
{
@@ -74,6 +79,7 @@ public class ScriptCompilationServiceTests
Assert.NotEmpty(result.Errors);
}
/// <summary>Verifies that System.IO is forbidden by the trust model.</summary>
[Fact]
public void ValidateTrustModel_SystemIO_Forbidden()
{
@@ -82,6 +88,7 @@ public class ScriptCompilationServiceTests
Assert.Contains(violations, v => v.Contains("System.IO"));
}
/// <summary>Verifies that Process is forbidden by the trust model.</summary>
[Fact]
public void ValidateTrustModel_Process_Forbidden()
{
@@ -90,6 +97,7 @@ public class ScriptCompilationServiceTests
Assert.NotEmpty(violations);
}
/// <summary>Verifies that Reflection is forbidden by the trust model.</summary>
[Fact]
public void ValidateTrustModel_Reflection_Forbidden()
{
@@ -98,6 +106,7 @@ public class ScriptCompilationServiceTests
Assert.NotEmpty(violations);
}
/// <summary>Verifies that Sockets are forbidden by the trust model.</summary>
[Fact]
public void ValidateTrustModel_Sockets_Forbidden()
{
@@ -106,6 +115,7 @@ public class ScriptCompilationServiceTests
Assert.NotEmpty(violations);
}
/// <summary>Verifies that HttpClient is forbidden by the trust model.</summary>
[Fact]
public void ValidateTrustModel_HttpClient_Forbidden()
{
@@ -114,6 +124,7 @@ public class ScriptCompilationServiceTests
Assert.NotEmpty(violations);
}
/// <summary>Verifies that async and await are allowed by the trust model.</summary>
[Fact]
public void ValidateTrustModel_AsyncAwait_Allowed()
{
@@ -123,6 +134,7 @@ public class ScriptCompilationServiceTests
Assert.Empty(violations);
}
/// <summary>Verifies that CancellationToken is allowed by the trust model.</summary>
[Fact]
public void ValidateTrustModel_CancellationToken_Allowed()
{
@@ -131,6 +143,7 @@ public class ScriptCompilationServiceTests
Assert.Empty(violations);
}
/// <summary>Verifies that clean code produces no trust model violations.</summary>
[Fact]
public void ValidateTrustModel_CleanCode_NoViolations()
{
@@ -143,6 +156,7 @@ public class ScriptCompilationServiceTests
Assert.Empty(violations);
}
/// <summary>Verifies that compiling a script that uses a forbidden API fails validation.</summary>
[Fact]
public void Compile_ForbiddenApi_FailsValidation()
{
@@ -151,8 +165,9 @@ public class ScriptCompilationServiceTests
Assert.NotEmpty(result.Errors);
}
// ── M3.3: stricter shared-validator behavior ──
// ── Stricter shared-validator behavior ──
/// <summary>Verifies that System.Net.Dns is forbidden by the trust model.</summary>
[Fact]
public void ValidateTrustModel_SystemNetDns_Forbidden()
{
@@ -164,6 +179,7 @@ public class ScriptCompilationServiceTests
Assert.Contains(violations, v => v.Contains("System.Net"));
}
/// <summary>Verifies that a reflection gateway reached through a permitted type is forbidden.</summary>
[Fact]
public void ValidateTrustModel_ReflectionGatewayViaPermittedType_Forbidden()
{
@@ -175,6 +191,7 @@ public class ScriptCompilationServiceTests
Assert.NotEmpty(violations);
}
/// <summary>Verifies that dynamic is forbidden by the trust model.</summary>
[Fact]
public void ValidateTrustModel_Dynamic_Forbidden()
{
@@ -182,6 +199,7 @@ public class ScriptCompilationServiceTests
Assert.NotEmpty(violations);
}
/// <summary>Verifies that Activator is forbidden by the trust model.</summary>
[Fact]
public void ValidateTrustModel_Activator_Forbidden()
{
@@ -190,6 +208,7 @@ public class ScriptCompilationServiceTests
Assert.NotEmpty(violations);
}
/// <summary>Verifies that InteropServices are forbidden by the trust model.</summary>
[Fact]
public void ValidateTrustModel_InteropServices_Forbidden()
{
@@ -198,6 +217,7 @@ public class ScriptCompilationServiceTests
Assert.NotEmpty(violations);
}
/// <summary>Verifies that Stopwatch is allowed by the trust model.</summary>
[Fact]
public void ValidateTrustModel_Stopwatch_Allowed()
{
@@ -255,6 +275,7 @@ public class ScriptCompilationServiceTests
Assert.Same(first.CompiledScript.Options, second.CompiledScript.Options);
}
/// <summary>Verifies that compilation uses the process-wide caching metadata resolver.</summary>
[Fact]
public void Compile_UsesProcessWideCachingMetadataResolver()
{