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:
+22
-2
@@ -5,7 +5,7 @@ using ZB.MOM.WW.ScadaBridge.Communication.Grpc;
|
||||
namespace ZB.MOM.WW.ScadaBridge.Communication.Tests.Grpc;
|
||||
|
||||
/// <summary>
|
||||
/// Regression tests for Communication-007 — the factory's synchronous
|
||||
/// Regression tests: the factory's synchronous
|
||||
/// <see cref="SiteStreamGrpcClientFactory.Dispose"/> must not block on the
|
||||
/// async disposal path (sync-over-async). It must dispose each client through
|
||||
/// the client's synchronous <see cref="SiteStreamGrpcClient.Dispose"/>.
|
||||
@@ -17,11 +17,15 @@ public class SiteStreamGrpcClientFactoryDisposeTests
|
||||
/// </summary>
|
||||
private sealed class TrackingClient : SiteStreamGrpcClient
|
||||
{
|
||||
/// <summary>Gets a value indicating whether the synchronous dispose path was called.</summary>
|
||||
public bool SyncDisposeCalled { get; private set; }
|
||||
/// <summary>Gets a value indicating whether the asynchronous dispose path was called.</summary>
|
||||
public bool AsyncDisposeCalled { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Dispose() => SyncDisposeCalled = true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override ValueTask DisposeAsync()
|
||||
{
|
||||
AsyncDisposeCalled = true;
|
||||
@@ -37,10 +41,13 @@ public class SiteStreamGrpcClientFactoryDisposeTests
|
||||
{
|
||||
private readonly ConcurrentBag<TrackingClient> _created = new();
|
||||
|
||||
/// <summary>Initializes the factory with a null logger factory.</summary>
|
||||
public TrackingFactory() : base(NullLoggerFactory.Instance) { }
|
||||
|
||||
/// <summary>Gets the clients this factory has created.</summary>
|
||||
public IReadOnlyCollection<TrackingClient> Created => _created.ToList();
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override SiteStreamGrpcClient CreateClient(string siteIdentifier, string grpcEndpoint)
|
||||
{
|
||||
var client = new TrackingClient();
|
||||
@@ -49,6 +56,7 @@ public class SiteStreamGrpcClientFactoryDisposeTests
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Dispose disposes clients synchronously and not via the async path.</summary>
|
||||
[Fact]
|
||||
public void Dispose_DisposesClientsSynchronously_NotViaAsyncPath()
|
||||
{
|
||||
@@ -69,12 +77,14 @@ public class SiteStreamGrpcClientFactoryDisposeTests
|
||||
/// <summary>
|
||||
/// Test client whose disposal always throws — stands in for a client whose
|
||||
/// <c>ReleaseResources</c> hit an <see cref="ObjectDisposedException"/> on a subscription
|
||||
/// token source (arch-review 2026-08-19 P3-1).
|
||||
/// token source.
|
||||
/// </summary>
|
||||
private sealed class ThrowingClient : SiteStreamGrpcClient
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void Dispose() => throw new ObjectDisposedException(nameof(CancellationTokenSource));
|
||||
|
||||
/// <inheritdoc />
|
||||
public override ValueTask DisposeAsync() =>
|
||||
throw new ObjectDisposedException(nameof(CancellationTokenSource));
|
||||
}
|
||||
@@ -85,10 +95,13 @@ public class SiteStreamGrpcClientFactoryDisposeTests
|
||||
private readonly ConcurrentBag<TrackingClient> _created = new();
|
||||
private int _next;
|
||||
|
||||
/// <summary>Initializes the factory with a null logger factory.</summary>
|
||||
public OneThrowingClientFactory() : base(NullLoggerFactory.Instance) { }
|
||||
|
||||
/// <summary>Gets the clients this factory has created.</summary>
|
||||
public IReadOnlyCollection<TrackingClient> Created => _created.ToList();
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override SiteStreamGrpcClient CreateClient(string siteIdentifier, string grpcEndpoint)
|
||||
{
|
||||
if (Interlocked.Increment(ref _next) == 1)
|
||||
@@ -102,6 +115,8 @@ public class SiteStreamGrpcClientFactoryDisposeTests
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Verifies that DisposeAsync still disposes every other client when one client throws.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task DisposeAsync_OneClientThrowing_StillDisposesEveryOtherClient()
|
||||
{
|
||||
@@ -119,6 +134,7 @@ public class SiteStreamGrpcClientFactoryDisposeTests
|
||||
Assert.True(c.AsyncDisposeCalled, "a throwing client must not strand its peers undisposed"));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Dispose still disposes every other client when one client throws.</summary>
|
||||
[Fact]
|
||||
public void Dispose_OneClientThrowing_StillDisposesEveryOtherClient()
|
||||
{
|
||||
@@ -134,6 +150,7 @@ public class SiteStreamGrpcClientFactoryDisposeTests
|
||||
Assert.True(c.SyncDisposeCalled, "a throwing client must not strand its peers undisposed"));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Dispose does not deadlock under a single-threaded synchronization context.</summary>
|
||||
[Fact]
|
||||
public void Dispose_DoesNotDeadlock_UnderSingleThreadedSynchronizationContext()
|
||||
{
|
||||
@@ -173,6 +190,7 @@ public class SiteStreamGrpcClientFactoryDisposeTests
|
||||
private readonly BlockingCollection<(SendOrPostCallback cb, object? state)> _queue = new();
|
||||
private readonly Thread _thread;
|
||||
|
||||
/// <summary>Initializes the synchronization context.</summary>
|
||||
public SingleThreadSyncContext()
|
||||
{
|
||||
_thread = new Thread(Run) { IsBackground = true };
|
||||
@@ -186,8 +204,10 @@ public class SiteStreamGrpcClientFactoryDisposeTests
|
||||
cb(state);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Post(SendOrPostCallback d, object? state) => _queue.Add((d, state));
|
||||
|
||||
/// <summary>Releases the resources held by this instance.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
_queue.CompleteAdding();
|
||||
|
||||
Reference in New Issue
Block a user