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
@@ -39,6 +39,7 @@ public sealed class SemanticValidatorImportTests : IDisposable
{
private readonly ServiceProvider _provider;
/// <summary>Initializes the test class with an in-memory service provider wired for Transport.</summary>
public SemanticValidatorImportTests()
{
var services = new ServiceCollection();
@@ -55,7 +56,7 @@ public sealed class SemanticValidatorImportTests : IDisposable
services.AddScoped<IExternalSystemRepository, ExternalSystemRepository>();
services.AddScoped<INotificationRepository, NotificationRepository>();
services.AddScoped<IInboundApiRepository, InboundApiRepository>();
// M8: DependencyResolver now injects ISiteRepository to walk the
// DependencyResolver now injects ISiteRepository to walk the
// site/data-connection/instance closure; register it or activation fails.
services.AddScoped<ISiteRepository, SiteRepository>();
services.AddScoped<IAuditCorrelationContext, AuditCorrelationContext>();
@@ -65,6 +66,7 @@ public sealed class SemanticValidatorImportTests : IDisposable
_provider = services.BuildServiceProvider();
}
/// <summary>Releases the resources held by this test class.</summary>
public void Dispose() => _provider.Dispose();
/// <summary>
@@ -81,7 +83,7 @@ public sealed class SemanticValidatorImportTests : IDisposable
var exporter = scope.ServiceProvider.GetRequiredService<IBundleExporter>();
var ctx = scope.ServiceProvider.GetRequiredService<ScadaBridgeDbContext>();
var ids = await ctx.Templates.Select(t => t.Id).ToListAsync();
// #05-T19: also carry any seeded ApiMethods so the severity-split
// Also carry any seeded ApiMethods so the severity-split
// tests (template-script = warning, ApiMethod = hard error) exercise
// both source kinds through the same export→load→apply path.
var apiIds = await ctx.ApiMethods.Select(m => m.Id).ToListAsync();
@@ -198,10 +200,12 @@ public sealed class SemanticValidatorImportTests : IDisposable
}
}
/// <summary>Verifies that a template script with an unresolved reference produces a warning but does not block the import.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task TemplateScript_with_unresolved_reference_warns_but_does_not_block_import()
{
// #05-T19 — a template whose script body calls UnknownHelper(): a
// A template whose script body calls UnknownHelper(): a
// PascalCase identifier that doesn't resolve to any SharedScript or
// ExternalSystem in the bundle or the target. Under the severity split,
// template-script name-resolution findings are ADVISORY (the design-time
@@ -244,10 +248,12 @@ public sealed class SemanticValidatorImportTests : IDisposable
}
}
/// <summary>Verifies that a template script with a local PascalCase method does not hard-block the import.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Apply_TemplateScriptWithLocalPascalCaseMethod_DoesNotHardBlock()
{
// #05-T19 — a template script that DECLARES and calls its own local
// A template script that DECLARES and calls its own local
// PascalCase function. The identifier scan would otherwise flag
// ComputeRate as a missing SharedScript reference; the local-declaration
// exclusion (Roslyn-parsed local functions/methods) removes it, so the
@@ -284,10 +290,12 @@ public sealed class SemanticValidatorImportTests : IDisposable
w => w.Contains("ComputeRate", StringComparison.Ordinal));
}
/// <summary>Verifies that a template script using Regex and StringBuilder does not hard-block the import.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Apply_TemplateScriptWithRegexAndStringBuilder_DoesNotHardBlock()
{
// #05-T19 — a template script using stdlib helpers that the extended
// A template script using stdlib helpers that the extended
// denylist now recognizes (Regex, StringBuilder, …). None resolve to a
// user SharedScript/ExternalSystem, and none should be flagged.
await using (var scope = _provider.CreateAsyncScope())
@@ -326,10 +334,12 @@ public sealed class SemanticValidatorImportTests : IDisposable
|| w.Contains("StringBuilder", StringComparison.Ordinal));
}
/// <summary>Verifies that an API method with an unresolved reference still hard-blocks the import.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Apply_ApiMethodWithUnresolvedReference_StillHardBlocks()
{
// #05-T19 — an ApiMethod script referencing a genuinely-missing
// An ApiMethod script referencing a genuinely-missing
// ExternalSystem. ApiMethod findings have no downstream deploy gate, so
// they remain HARD errors: the apply throws SemanticValidationException.
await using (var scope = _provider.CreateAsyncScope())
@@ -368,10 +378,12 @@ public sealed class SemanticValidatorImportTests : IDisposable
}
}
/// <summary>Verifies that a template script using a forbidden API hard-blocks the import.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Apply_TemplateScriptWithForbiddenApi_HardBlocks()
{
// #05-T20 — bundle import is the fifth script-trust call site. A template
// Bundle import is the fifth script-trust call site. A template
// script that reaches a forbidden API (Process.Start) must be rejected at
// import review, NOT left to fail at runtime. Unlike the name-resolution
// heuristic, a trust verdict is authoritative → hard error for ALL kinds.
@@ -411,10 +423,12 @@ public sealed class SemanticValidatorImportTests : IDisposable
}
}
/// <summary>Verifies that an API method using a forbidden API hard-blocks the import.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Apply_ApiMethodWithForbiddenApi_HardBlocks()
{
// #05-T20 — same trust gate over ApiMethod script bodies.
// Same trust gate over ApiMethod script bodies.
await using (var scope = _provider.CreateAsyncScope())
{
var ctx = scope.ServiceProvider.GetRequiredService<ScadaBridgeDbContext>();
@@ -443,10 +457,12 @@ public sealed class SemanticValidatorImportTests : IDisposable
Assert.Contains(ex.Errors, err => err.Contains("Process", StringComparison.Ordinal));
}
/// <summary>Verifies that an alarm Expression trigger using a forbidden API hard-blocks the import.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Apply_AlarmExpressionTriggerWithForbiddenApi_HardBlocks()
{
// #05-T20 (code-review fix): an alarm's Expression trigger compiles and
// An alarm's Expression trigger compiles and
// executes at the site, so a forbidden API in the trigger expression must
// be caught at import — not just in template/shared/ApiMethod script bodies.
await using (var scope = _provider.CreateAsyncScope())
@@ -482,6 +498,8 @@ public sealed class SemanticValidatorImportTests : IDisposable
Assert.Contains(ex.Errors, err => err.Contains("Process", StringComparison.Ordinal));
}
/// <summary>Verifies that an instance alarm override expression using a forbidden API hard-blocks the import.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Apply_InstanceAlarmOverrideExpressionWithForbiddenApi_HardBlocks()
{
@@ -518,6 +536,8 @@ public sealed class SemanticValidatorImportTests : IDisposable
// pre-exist, but no new import ran — the throw is pre-write at Pass 0).
}
/// <summary>Verifies that previewing an instance alarm override expression with a forbidden API surfaces a blocker.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Preview_InstanceAlarmOverrideExpressionWithForbiddenApi_SurfacesBlocker()
{
@@ -538,6 +558,8 @@ public sealed class SemanticValidatorImportTests : IDisposable
&& b.BlockerReason!.Contains("trust violation", StringComparison.Ordinal));
}
/// <summary>Verifies that a clean instance alarm override expression imports successfully.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Apply_InstanceAlarmOverrideExpression_Clean_Imports()
{
@@ -587,10 +609,12 @@ public sealed class SemanticValidatorImportTests : IDisposable
}
}
/// <summary>Verifies that an API method reference is not suppressed by a template-local function of the same name.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Apply_ApiMethodReference_NotSuppressedByTemplateLocalFunction()
{
// #05-T19 (code-review fix): a local function declared in a TEMPLATE script
// A local function declared in a TEMPLATE script
// must not suppress a genuinely-missing reference of the same name in an
// ApiMethod — the ApiMethod finding stays a HARD error. A pre-fix global
// locallyDeclared set silently defeated this.
@@ -628,6 +652,8 @@ public sealed class SemanticValidatorImportTests : IDisposable
Assert.Contains(ex.Errors, err => err.Contains("SharedHelper", StringComparison.Ordinal));
}
/// <summary>Verifies that the semantic validator catches an alarm trigger type mismatch at import.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task SemanticValidator_catches_alarm_trigger_type_mismatch_at_import()
{
@@ -685,6 +711,8 @@ public sealed class SemanticValidatorImportTests : IDisposable
}
}
/// <summary>Verifies that a valid bundle passes semantic validation.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Valid_bundle_passes_semantic_validation()
{