Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions TUnit.Core/TestContext.Output.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,8 @@ public partial class TestContext
// Internal backing fields and properties
internal ConcurrentBag<Timing> Timings { get; } = [];
private readonly ConcurrentBag<Artifact> _artifactsBag = new();
private List<Artifact>? _cachedArtifactsList;
private int _artifactsVersion = 0;

internal IReadOnlyList<Artifact> Artifacts
{
get
{
// Simple version check - if bag hasn't changed, return cached list
if (_cachedArtifactsList != null && _artifactsVersion == _artifactsBag.Count)
{
return _cachedArtifactsList;
}

_cachedArtifactsList = _artifactsBag.ToList();
_artifactsVersion = _artifactsBag.Count;
return _cachedArtifactsList;
}
}
internal IReadOnlyList<Artifact> Artifacts => _artifactsBag.ToList();

// Explicit interface implementations for ITestOutput
TextWriter ITestOutput.StandardOutput => OutputWriter;
Expand All @@ -45,7 +29,6 @@ void ITestOutput.RecordTiming(Timing timing)
void ITestOutput.AttachArtifact(Artifact artifact)
{
_artifactsBag.Add(artifact);
_artifactsVersion++; // Invalidate cache
}

string ITestOutput.GetStandardOutput() => GetOutput();
Expand Down
Loading