Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/Wolfgang.Etl.TestKit.Xunit/EtlScenarioOfT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public sealed class EtlScenario<T>
where T : notnull
{
private readonly T[] _items;
private (int Index, System.Exception Exception, bool Skip)? _extractorFault;
private (int Index, System.Exception Exception, bool Skip)? _loaderFault;
private (int Index, Exception Exception, bool Skip)? _extractorFault;
private (int Index, Exception Exception, bool Skip)? _loaderFault;
private TransformerBase<T, T, Report>? _transformer;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public void ExtractAsync_with_null_progress_throws_ArgumentNullException()

var ex = Assert.Throws<ArgumentNullException>(() =>
{
_ = sut.ExtractAsync((IProgress<TProgress>)null!);
_ = sut.ExtractAsync(null!);
});

Assert.Equal("progress", ex.ParamName);
Expand Down Expand Up @@ -282,7 +282,7 @@ public void ExtractAsync_with_null_progress_and_token_throws_ArgumentNullExcepti

var ex = Assert.Throws<ArgumentNullException>(() =>
{
_ = sut.ExtractAsync((IProgress<TProgress>)null!, CancellationToken.None);
_ = sut.ExtractAsync(null!, CancellationToken.None);
});

Assert.Equal("progress", ex.ParamName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void ExtractAsync_with_null_progress_throws_ArgumentNullException()
var ex = Assert.Throws<ArgumentNullException>(() =>
{
// The exception is thrown when the method is called, before enumeration starts.
_ = sut.ExtractAsync((IProgress<TProgress>)null!);
_ = sut.ExtractAsync(null!);
});

Assert.Equal("progress", ex.ParamName);
Expand Down
4 changes: 2 additions & 2 deletions src/Wolfgang.Etl.TestKit.Xunit/ExtractorBaseContractTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public void ExtractAsync_with_null_progress_throws_ArgumentNullException()

var ex = Assert.Throws<ArgumentNullException>(() =>
{
_ = sut.ExtractAsync((IProgress<TProgress>)null!);
_ = sut.ExtractAsync(null!);
});

Assert.Equal("progress", ex.ParamName);
Expand Down Expand Up @@ -443,7 +443,7 @@ public void ExtractAsync_with_null_progress_and_token_throws_ArgumentNullExcepti

var ex = Assert.Throws<ArgumentNullException>(() =>
{
_ = sut.ExtractAsync((IProgress<TProgress>)null!, CancellationToken.None);
_ = sut.ExtractAsync(null!, CancellationToken.None);
});

Assert.Equal("progress", ex.ParamName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public async Task LoadAsync_with_null_progress_throws_ArgumentNullException_Asyn

var ex = await Assert.ThrowsAsync<ArgumentNullException>
(
() => sut.LoadAsync(AsyncEnumerable.Empty<TItem>(), (IProgress<TProgress>)null!)
() => sut.LoadAsync(AsyncEnumerable.Empty<TItem>(), null!)
).ConfigureAwait(false);

Assert.Equal("progress", ex.ParamName);
Expand Down Expand Up @@ -292,7 +292,7 @@ public async Task LoadAsync_with_null_progress_and_token_throws_ArgumentNullExce

var ex = await Assert.ThrowsAsync<ArgumentNullException>
(
() => sut.LoadAsync(AsyncEnumerable.Empty<TItem>(), (IProgress<TProgress>)null!, CancellationToken.None)
() => sut.LoadAsync(AsyncEnumerable.Empty<TItem>(), null!, CancellationToken.None)
).ConfigureAwait(false);

Assert.Equal("progress", ex.ParamName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public async Task LoadAsync_with_null_progress_throws_ArgumentNullException_Asyn

var ex = await Assert.ThrowsAsync<ArgumentNullException>
(
() => sut.LoadAsync(AsyncEnumerable.Empty<TItem>(), (IProgress<TProgress>)null!)
() => sut.LoadAsync(AsyncEnumerable.Empty<TItem>(), null!)
).ConfigureAwait(false);

Assert.Equal("progress", ex.ParamName);
Expand Down
12 changes: 6 additions & 6 deletions src/Wolfgang.Etl.TestKit.Xunit/LoaderBaseContractTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public async Task LoadAsync_with_null_items_throws_ArgumentNullException_Async()
var sut = CreateSut();

var ex = await Assert.ThrowsAsync<ArgumentNullException>(() =>
sut.LoadAsync((IAsyncEnumerable<TItem>)null!)).ConfigureAwait(false);
sut.LoadAsync(null!)).ConfigureAwait(false);

Assert.Equal("items", ex.ParamName);
}
Expand Down Expand Up @@ -217,7 +217,7 @@ public async Task LoadAsync_with_token_and_null_items_throws_ArgumentNullExcepti
var sut = CreateSut();

var ex = await Assert.ThrowsAsync<ArgumentNullException>(() =>
sut.LoadAsync((IAsyncEnumerable<TItem>)null!, CancellationToken.None)).ConfigureAwait(false);
sut.LoadAsync(null!, CancellationToken.None)).ConfigureAwait(false);

Assert.Equal("items", ex.ParamName);
}
Expand Down Expand Up @@ -338,7 +338,7 @@ public async Task LoadAsync_with_progress_and_null_items_throws_ArgumentNullExce
var progress = new SynchronousProgress<TProgress>(_ => { });

var ex = await Assert.ThrowsAsync<ArgumentNullException>(() =>
sut.LoadAsync((IAsyncEnumerable<TItem>)null!, progress)).ConfigureAwait(false);
sut.LoadAsync(null!, progress)).ConfigureAwait(false);

Assert.Equal("items", ex.ParamName);
}
Expand All @@ -353,7 +353,7 @@ public async Task LoadAsync_with_null_progress_throws_ArgumentNullException_Asyn
var sut = CreateSut();

var ex = await Assert.ThrowsAsync<ArgumentNullException>(() =>
sut.LoadAsync(CreateInputItemsAsync(), (IProgress<TProgress>)null!)).ConfigureAwait(false);
sut.LoadAsync(CreateInputItemsAsync(), null!)).ConfigureAwait(false);

Assert.Equal("progress", ex.ParamName);
}
Expand Down Expand Up @@ -473,7 +473,7 @@ public async Task LoadAsync_with_progress_and_token_and_null_items_throws_Argume
var progress = new SynchronousProgress<TProgress>(_ => { });

var ex = await Assert.ThrowsAsync<ArgumentNullException>(() =>
sut.LoadAsync((IAsyncEnumerable<TItem>)null!, progress, CancellationToken.None)).ConfigureAwait(false);
sut.LoadAsync(null!, progress, CancellationToken.None)).ConfigureAwait(false);

Assert.Equal("items", ex.ParamName);
}
Expand All @@ -488,7 +488,7 @@ public async Task LoadAsync_with_progress_and_token_and_null_progress_throws_Arg
var sut = CreateSut();

var ex = await Assert.ThrowsAsync<ArgumentNullException>(() =>
sut.LoadAsync(CreateInputItemsAsync(), (IProgress<TProgress>)null!, CancellationToken.None)).ConfigureAwait(false);
sut.LoadAsync(CreateInputItemsAsync(), null!, CancellationToken.None)).ConfigureAwait(false);

Assert.Equal("progress", ex.ParamName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public void TransformAsync_with_null_progress_throws_ArgumentNullException()

var ex = Assert.Throws<ArgumentNullException>(() =>
{
_ = sut.TransformAsync(AsyncEnumerable.Empty<TItem>(), (IProgress<TProgress>)null!);
_ = sut.TransformAsync(AsyncEnumerable.Empty<TItem>(), null!);
});

Assert.Equal("progress", ex.ParamName);
Expand Down Expand Up @@ -282,7 +282,7 @@ public void TransformAsync_with_null_progress_and_token_throws_ArgumentNullExcep

var ex = Assert.Throws<ArgumentNullException>(() =>
{
_ = sut.TransformAsync(AsyncEnumerable.Empty<TItem>(), (IProgress<TProgress>)null!, CancellationToken.None);
_ = sut.TransformAsync(AsyncEnumerable.Empty<TItem>(), null!, CancellationToken.None);
});

Assert.Equal("progress", ex.ParamName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void TransformAsync_with_null_progress_throws_ArgumentNullException()

var ex = Assert.Throws<ArgumentNullException>(() =>
{
_ = sut.TransformAsync(AsyncEnumerable.Empty<TItem>(), (IProgress<TProgress>)null!);
_ = sut.TransformAsync(AsyncEnumerable.Empty<TItem>(), null!);
});

Assert.Equal("progress", ex.ParamName);
Expand Down
12 changes: 6 additions & 6 deletions src/Wolfgang.Etl.TestKit.Xunit/TransformerBaseContractTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public void TransformAsync_with_null_items_throws_ArgumentNullException()

var ex = Assert.Throws<ArgumentNullException>(() =>
{
_ = sut.TransformAsync((IAsyncEnumerable<TItem>)null!);
_ = sut.TransformAsync(null!);
});

Assert.Equal("items", ex.ParamName);
Expand Down Expand Up @@ -244,7 +244,7 @@ public void TransformAsync_with_token_and_null_items_throws_ArgumentNullExceptio

var ex = Assert.Throws<ArgumentNullException>(() =>
{
_ = sut.TransformAsync((IAsyncEnumerable<TItem>)null!, CancellationToken.None);
_ = sut.TransformAsync(null!, CancellationToken.None);
});

Assert.Equal("items", ex.ParamName);
Expand Down Expand Up @@ -363,7 +363,7 @@ public void TransformAsync_with_progress_and_null_items_throws_ArgumentNullExcep

var ex = Assert.Throws<ArgumentNullException>(() =>
{
_ = sut.TransformAsync((IAsyncEnumerable<TItem>)null!, progress);
_ = sut.TransformAsync(null!, progress);
});

Assert.Equal("items", ex.ParamName);
Expand All @@ -380,7 +380,7 @@ public void TransformAsync_with_null_progress_throws_ArgumentNullException()

var ex = Assert.Throws<ArgumentNullException>(() =>
{
_ = sut.TransformAsync(CreateInputItemsAsync(), (IProgress<TProgress>)null!);
_ = sut.TransformAsync(CreateInputItemsAsync(), null!);
});

Assert.Equal("progress", ex.ParamName);
Expand Down Expand Up @@ -496,7 +496,7 @@ public void TransformAsync_with_progress_and_token_and_null_items_throws_Argumen

var ex = Assert.Throws<ArgumentNullException>(() =>
{
_ = sut.TransformAsync((IAsyncEnumerable<TItem>)null!, progress, CancellationToken.None);
_ = sut.TransformAsync(null!, progress, CancellationToken.None);
});

Assert.Equal("items", ex.ParamName);
Expand All @@ -513,7 +513,7 @@ public void TransformAsync_with_progress_and_token_and_null_progress_throws_Argu

var ex = Assert.Throws<ArgumentNullException>(() =>
{
_ = sut.TransformAsync(CreateInputItemsAsync(), (IProgress<TProgress>)null!, CancellationToken.None);
_ = sut.TransformAsync(CreateInputItemsAsync(), null!, CancellationToken.None);
});

Assert.Equal("progress", ex.ParamName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private sealed class ClockLoader : LoaderBase<int, EtlProgress>

protected override async Task LoadWorkerAsync(IAsyncEnumerable<int> items, CancellationToken token)
{
await foreach (var item in items.WithCancellation(token).ConfigureAwait(false))
await foreach (var _ in items.WithCancellation(token).ConfigureAwait(false))
{
IncrementCurrentItemCount();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ protected override async IAsyncEnumerable<int> WrapWorkerExecution(
SeamCallCount++;
if (WorkerRuns == 1)
{
await foreach (var item in base.WrapWorkerExecution(workerFactory, token).WithCancellation(token))
await foreach (var item in base.WrapWorkerExecution(workerFactory, token))
{
yield return item;
}
Expand Down Expand Up @@ -427,7 +427,7 @@ protected override async IAsyncEnumerable<int> WrapWorkerExecution(
SeamCallCount++;
if (WorkerRuns == 1)
{
await foreach (var item in base.WrapWorkerExecution(workerFactory, token).WithCancellation(token))
await foreach (var item in base.WrapWorkerExecution(workerFactory, token))
{
yield return item;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,10 @@ public async Task Start_after_dispose_does_not_throw()
public async Task Timer_callback_fires_during_extraction()
{
var elapsedCount = 0;
IProgressTimer? capturedTimer = null;

var sut = new CapturingExtractor(
onTimerCreated: t =>
{
capturedTimer = t;
t.Elapsed += () => Interlocked.Increment(ref elapsedCount);
},
intervalMs: 30,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private sealed class ErroringLoader : LoaderBase<int, EtlProgress>

protected override async Task LoadWorkerAsync(IAsyncEnumerable<int> items, CancellationToken token)
{
await foreach (var item in items.WithCancellation(token))
await foreach (var _ in items.WithCancellation(token))
{
IncrementCurrentItemCount();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public void From_when_stream_is_null_throws_ArgumentNullException()
{
Assert.Throws<ArgumentNullException>(() => EtlPipeline
.Create()
.From<int>((IAsyncEnumerable<int>)null!));
.From<int>(null!));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void TransformStage_Load_cancel_null_throws()
{
Assert.Throws<ArgumentNullException>
(
() => MidChainStage().Load((ILoadWithCancellationAsync<int>)null!)
() => MidChainStage().Load(null!)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void Bare_Load_when_loader_is_null_throws()
public void CancelOnly_Load_when_loader_is_null_throws()
{
var stage = Pipeline.Extract(new BareExtractor<int>(new[] { 1 }));
Assert.Throws<ArgumentNullException>(() => stage.Load((ILoadWithCancellationAsync<int>)null!));
Assert.Throws<ArgumentNullException>(() => stage.Load(null!));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,29 @@ public async IAsyncEnumerable<T> ExtractAsync(IProgress<TProgress> progress)
}


public async IAsyncEnumerable<T> ExtractAsync
public IAsyncEnumerable<T> ExtractAsync
(
IProgress<TProgress> progress,
[EnumeratorCancellation] CancellationToken token
CancellationToken token
)
{
if (progress is null)
{
throw new ArgumentNullException(nameof(progress));
}

// Split so the null check runs eagerly at call time rather than being
// deferred to the first MoveNextAsync of the iterator (S4456).
return ExtractFullCoreAsync(progress, token);
}


private async IAsyncEnumerable<T> ExtractFullCoreAsync
(
IProgress<TProgress> progress,
[EnumeratorCancellation] CancellationToken token
)
{
FullOverloadWasCalled = true;
LastReceivedProgress = progress;
LastReceivedToken = token;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ private static IReadOnlyList<MetadataReference> ReferenceAssemblies()
var tree = CSharpSyntaxTree.ParseText
(
source,
new CSharpParseOptions(LanguageVersion.Latest, DocumentationMode.Parse)
new CSharpParseOptions(LanguageVersion.Latest)
);

var docComments = tree.GetRoot()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void Constructor_when_delaySelector_is_null_throws_ArgumentNullException(
{
Assert.Throws<ArgumentNullException>
(
() => new DelayingExtractor<int>(new[] { 1 }, (Func<int, TimeSpan>)null!)
() => new DelayingExtractor<int>(new[] { 1 }, null!)
);
}

Expand Down
6 changes: 3 additions & 3 deletions tests/Wolfgang.Etl.TestKit.Tests.Unit/TestExtractorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ public void Constructor_with_indexed_factory_and_timer_when_timer_is_null_throws
{
var ex = Assert.Throws<ArgumentNullException>
(
() => new TestExtractorWithTimer((Func<int, int>)(i => i), null!)
() => new TestExtractorWithTimer(i => i, null!)
);

Assert.Equal("timer", ex.ParamName);
Expand Down Expand Up @@ -785,7 +785,7 @@ public void Constructor_with_indexed_factory_count_and_timer_when_count_is_negat
using var timer = new ManualProgressTimer();
var ex = Assert.Throws<ArgumentOutOfRangeException>
(
() => new TestExtractorWithTimer((Func<int, int>)(i => i), -1, timer)
() => new TestExtractorWithTimer(i => i, -1, timer)
);

Assert.Equal("count", ex.ParamName);
Expand All @@ -798,7 +798,7 @@ public void Constructor_with_indexed_factory_count_and_timer_when_timer_is_null_
{
var ex = Assert.Throws<ArgumentNullException>
(
() => new TestExtractorWithTimer((Func<int, int>)(i => i), 3, null!)
() => new TestExtractorWithTimer(i => i, 3, null!)
);

Assert.Equal("timer", ex.ParamName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public void FinalReportSatisfies_when_predicate_null_throws_ArgumentNullExceptio
var capture = new ProgressCapture<int>();

Assert.Throws<ArgumentNullException>(() =>
ProgressAssert.FinalReportSatisfies<int>(capture, null!));
ProgressAssert.FinalReportSatisfies(capture, null!));
}


Expand Down Expand Up @@ -331,7 +331,7 @@ public void AllReportsSatisfy_when_predicate_null_throws_ArgumentNullException()
var capture = new ProgressCapture<int>();

Assert.Throws<ArgumentNullException>(() =>
ProgressAssert.AllReportsSatisfy<int>(capture, null!));
ProgressAssert.AllReportsSatisfy(capture, null!));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected override Task<RetryOutcome> RunWithPermanentFaultAsync(int maxAttempts
private static async Task<RetryOutcome> DriveAsync(RetryingExtractor<int> sut)
{
var itemCount = 0;
var succeeded = false;
bool succeeded;

try
{
Expand Down
Loading