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:
@@ -18,17 +18,33 @@ public class TraceCapturingLoggerTests
|
||||
/// <summary>An inner logger that records what it was asked to write, at a configurable minimum level.</summary>
|
||||
private sealed class RecordingLogger(LogLevel minimum = LogLevel.Trace) : ILogger
|
||||
{
|
||||
/// <summary>Gets the entries written to this logger.</summary>
|
||||
public List<(LogLevel Level, string Message)> Entries { get; } = [];
|
||||
/// <summary>Gets the scopes begun on this logger.</summary>
|
||||
public List<object?> Scopes { get; } = [];
|
||||
|
||||
/// <summary>Records the scope state and returns no scope handle.</summary>
|
||||
/// <typeparam name="TState">The type of the scope state.</typeparam>
|
||||
/// <param name="state">The scope state.</param>
|
||||
/// <returns>Always <see langword="null"/>.</returns>
|
||||
public IDisposable? BeginScope<TState>(TState state) where TState : notnull
|
||||
{
|
||||
Scopes.Add(state);
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Reports whether the level meets the configured minimum.</summary>
|
||||
/// <param name="logLevel">The log level being checked.</param>
|
||||
/// <returns><see langword="true"/> when the level is at or above the minimum.</returns>
|
||||
public bool IsEnabled(LogLevel logLevel) => logLevel >= minimum;
|
||||
|
||||
/// <summary>Records the formatted message for later assertions.</summary>
|
||||
/// <typeparam name="TState">The type of the log state.</typeparam>
|
||||
/// <param name="level">The log level.</param>
|
||||
/// <param name="eventId">The event id.</param>
|
||||
/// <param name="state">The log state.</param>
|
||||
/// <param name="exception">The exception being logged, if any.</param>
|
||||
/// <param name="formatter">The message formatter.</param>
|
||||
public void Log<TState>(LogLevel level, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter) =>
|
||||
Entries.Add((level, formatter(state, exception)));
|
||||
}
|
||||
@@ -47,6 +63,7 @@ public class TraceCapturingLoggerTests
|
||||
return (new TraceCapturingLogger(inner, sink), inner, rows);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a debug entry is forwarded to the inner logger but not captured.</summary>
|
||||
[Fact]
|
||||
public void Debug_IsForwarded_ButNotCaptured()
|
||||
{
|
||||
@@ -58,6 +75,7 @@ public class TraceCapturingLoggerTests
|
||||
Assert.Empty(rows);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a warning is captured as a runtime row together with its exception.</summary>
|
||||
[Fact]
|
||||
public void Warning_IsCapturedAsARuntimeRow_WithItsException()
|
||||
{
|
||||
@@ -74,6 +92,7 @@ public class TraceCapturingLoggerTests
|
||||
Assert.Same(boom, row.Exception);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that error and critical entries are both captured as errors.</summary>
|
||||
[Fact]
|
||||
public void ErrorAndCritical_AreBothCapturedAsError()
|
||||
{
|
||||
@@ -85,6 +104,7 @@ public class TraceCapturingLoggerTests
|
||||
Assert.Equal(["error", "error"], rows.Select(r => r.Level));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that information level is enabled even when the inner logger disables it.</summary>
|
||||
[Fact]
|
||||
public void InformationIsEnabled_EvenWhenTheInnerLoggerSaysNo()
|
||||
{
|
||||
@@ -102,6 +122,7 @@ public class TraceCapturingLoggerTests
|
||||
Assert.Equal("captured anyway", row.Message);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that below information level the inner logger decides whether the level is enabled.</summary>
|
||||
[Fact]
|
||||
public void BelowInformation_TheInnerLoggerDecidesEnablement()
|
||||
{
|
||||
@@ -110,6 +131,7 @@ public class TraceCapturingLoggerTests
|
||||
Assert.False(logger.IsEnabled(LogLevel.Debug));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a disabled inner logger is not written to but the row is still captured.</summary>
|
||||
[Fact]
|
||||
public void ADisabledInnerLogger_IsNotWrittenTo_ButTheRowIsStillCaptured()
|
||||
{
|
||||
@@ -121,6 +143,7 @@ public class TraceCapturingLoggerTests
|
||||
Assert.Single(rows);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that captured lines carry the ambient step id.</summary>
|
||||
[Fact]
|
||||
public void CapturedLines_CarryTheAmbientStepId()
|
||||
{
|
||||
@@ -135,6 +158,7 @@ public class TraceCapturingLoggerTests
|
||||
Assert.Equal(stepId, Assert.Single(rows).StepEventId);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the constructor rejects a logger that is already decorated.</summary>
|
||||
[Fact]
|
||||
public void Ctor_RejectsAnAlreadyDecoratedLogger()
|
||||
{
|
||||
@@ -147,6 +171,7 @@ public class TraceCapturingLoggerTests
|
||||
Assert.Equal("inner", ex.ParamName);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the constructor requires both collaborators.</summary>
|
||||
[Fact]
|
||||
public void Ctor_RequiresBothCollaborators()
|
||||
{
|
||||
@@ -156,10 +181,11 @@ public class TraceCapturingLoggerTests
|
||||
Assert.Throws<ArgumentNullException>(() => new TraceCapturingLogger(new RecordingLogger(), null!));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a throwing formatter is swallowed and drops only that line.</summary>
|
||||
[Fact]
|
||||
public void AThrowingFormatter_IsSwallowed_AndDropsOnlyThatLine()
|
||||
{
|
||||
// Review M3. Most of what this decorator captures is the runtime's own best-effort
|
||||
// Most of what this decorator captures is the runtime's own best-effort
|
||||
// "audit write failed" warnings, logged from INSIDE a catch block: a formatter exception
|
||||
// escaping here would replace the original failure with a formatting one on a path whose
|
||||
// contract is that it never throws. The inner logger is disabled for this level so the
|
||||
@@ -177,6 +203,7 @@ public class TraceCapturingLoggerTests
|
||||
Assert.Equal("still alive", Assert.Single(rows).Message);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that beginning a scope delegates to the inner logger.</summary>
|
||||
[Fact]
|
||||
public void BeginScope_DelegatesToTheInnerLogger()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user