Skip to content

[WARNING] Fix in CS4014 #6633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 6, 2023
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
2 changes: 2 additions & 0 deletions src/core/Akka.Streams.Tests/Dsl/FlowSelectAsyncSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ await this.AssertAllStagesStoppedAsync(async() =>
var counter = new AtomicCounter();
var queue = new BlockingQueue<(TaskCompletionSource<int>, long)>();
var cancellation = new CancellationTokenSource();
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Task.Run(() =>
{
var delay = 500; // 50000 nanoseconds
Expand All @@ -369,6 +370,7 @@ await this.AssertAllStagesStoppedAsync(async() =>
}
}
}, cancellation.Token);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

Func<Task<int>> deferred = () =>
{
Expand Down
2 changes: 2 additions & 0 deletions src/core/Akka.Streams.Tests/Dsl/FlowWireTapSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ public async Task A_wireTap_must_yield_the_first_error()
await this.AssertAllStagesStoppedAsync(async() => {
var p = this.CreateManualPublisherProbe<int>();

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
Source.FromPublisher(p)
.WireTap(i => TestActor.Tell(i))
.RunWith(Sink.Ignore<int>(), Materializer)
.ContinueWith(t => TestActor.Tell(t.Exception.InnerException));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

var proc = await p.ExpectSubscriptionAsync();
await proc.ExpectRequestAsync();
Expand Down
2 changes: 2 additions & 0 deletions src/core/Akka.Streams.Tests/Dsl/LazySourceSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,14 @@ await this.AssertAllStagesStoppedAsync(async() => {
var boom = new TestException("boom");
await probe.ExpectMsgAsync<Done>();
killSwitch.Abort(boom);
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
doneF.ContinueWith(t =>
{
t.Exception.Should().NotBeNull();
t.Exception.InnerException.Should().NotBeNull();
t.Exception.InnerException.Should().Be(boom);
});
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
}, Materializer);
}

Expand Down
20 changes: 20 additions & 0 deletions src/core/Akka.Streams.Tests/Dsl/QueueSinkSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ await this.AssertAllStagesStoppedAsync(async() => {

foreach(var v in expected)
{
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
queue.PullAsync().PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
await ExpectMsgAsync(v);
};
}, _materializer);
Expand All @@ -71,7 +73,9 @@ await this.AssertAllStagesStoppedAsync(async() => {
future2.Invoking(t => t.Wait(RemainingOrDefault)).Should().Throw<IllegalStateException>();

sub.SendNext(1);
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
future.PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
await ExpectMsgAsync(Option<int>.Create(1));

sub.SendComplete();
Expand All @@ -87,7 +91,9 @@ await this.AssertAllStagesStoppedAsync(async() => {
var queue = Source.FromPublisher(probe).RunWith(Sink.Queue<int>(), _materializer);
var sub = probe.ExpectSubscription();

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
queue.PullAsync().PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
await ExpectNoMsgAsync(_pause);

sub.SendNext(1);
Expand All @@ -105,7 +111,9 @@ await this.AssertAllStagesStoppedAsync(async() => {
var queue = Source.FromPublisher(probe).RunWith(Sink.Queue<int>(), _materializer);
var sub = await probe.ExpectSubscriptionAsync();

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
queue.PullAsync().PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
await ExpectNoMsgAsync(_pause);

sub.SendError(TestException());
Expand Down Expand Up @@ -136,7 +144,9 @@ await this.AssertAllStagesStoppedAsync(async() => {
var queue = Source.FromPublisher(probe).RunWith(Sink.Queue<int>(), _materializer);
var sub = await probe.ExpectSubscriptionAsync();

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
queue.PullAsync().PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
await ExpectNoMsgAsync(_pause);

sub.SendNext(1);
Expand All @@ -154,7 +164,9 @@ await this.AssertAllStagesStoppedAsync(async() => {
var queue = Source.FromPublisher(probe).RunWith(Sink.Queue<int>(), _materializer);
var sub = await probe.ExpectSubscriptionAsync();

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
queue.PullAsync().PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
sub.SendNext(1);
await ExpectMsgAsync(Option<int>.Create(1));

Expand Down Expand Up @@ -186,10 +198,14 @@ await this.AssertAllStagesStoppedAsync(async() => {

for (var i = 1; i <= streamElementCount; i++)
{
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
queue.PullAsync().PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
await ExpectMsgAsync(Option<int>.Create(i));
}
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
queue.PullAsync().PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
await ExpectMsgAsync(Option<int>.None);
}, _materializer);
}
Expand All @@ -203,11 +219,15 @@ await this.AssertAllStagesStoppedAsync(async() => {
var queue = Source.FromPublisher(probe).RunWith(sink, _materializer);
var sub = await probe.ExpectSubscriptionAsync();

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
queue.PullAsync().PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
sub.SendNext(1); // should pull next element
await ExpectMsgAsync(Option<int>.Create(1));

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
queue.PullAsync().PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
await ExpectNoMsgAsync(); // element requested but buffer empty
sub.SendNext(2);
await ExpectMsgAsync(Option<int>.Create(2));
Expand Down
26 changes: 26 additions & 0 deletions src/core/Akka.Streams.Tests/Dsl/QueueSourceSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ await this.AssertAllStagesStoppedAsync(async() => {
.Run(_materializer);
var sub = await s.ExpectSubscriptionAsync();

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
queue.OfferAsync(1).PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
await ExpectNoMsgAsync(_pause);
sub.Request(1);
await ExpectMsgAsync<Enqueued>();
Expand All @@ -160,10 +162,14 @@ await this.AssertAllStagesStoppedAsync(async() => {
.Run(_materializer);
var sub = await s.ExpectSubscriptionAsync();

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
queue.WatchCompletionAsync()
.ContinueWith(t => "done", TaskContinuationOptions.OnlyOnRanToCompletion)
.PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
queue.OfferAsync(1).PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
await ExpectNoMsgAsync(_pause);

sub.Cancel();
Expand Down Expand Up @@ -223,8 +229,12 @@ await this.AssertAllStagesStoppedAsync(async() => {
for (var i = 1; i <= 5; i++)
AssertSuccess(queue.OfferAsync(i));

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
queue.OfferAsync(6).PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
queue.OfferAsync(7).PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
var expect = await ExpectMsgAsync<Status.Failure>();
expect.Cause.Should().BeOfType<IllegalStateException>();
await probe.RequestNextAsync(1);
Expand All @@ -246,7 +256,9 @@ await this.AssertAllStagesStoppedAsync(async() => {
Source.Queue<int>(1, OverflowStrategy.Fail)
.To(Sink.FromSubscriber(s))
.Run(_materializer);
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
queue.WatchCompletionAsync().PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
await queue.OfferAsync(1); // need to wait when first offer is done as initialization can be done in this moment
await queue.OfferAsync(2);
await ExpectMsgAsync<Status.Failure>();
Expand All @@ -262,7 +274,9 @@ await this.AssertAllStagesStoppedAsync(async() => {
var queue = Source.Queue<int>(1, OverflowStrategy.Fail)
.To(Sink.FromSubscriber(s))
.Run(tempMap);
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
queue.WatchCompletionAsync().PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
tempMap.Shutdown();
await ExpectMsgAsync<Status.Failure>();
}, _materializer);
Expand All @@ -280,7 +294,9 @@ await this.AssertAllStagesStoppedAsync(async() => {
var sub = await s.ExpectSubscriptionAsync();

await queue.OfferAsync(1);
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
queue.OfferAsync(2).PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
await ExpectMsgAsync<Dropped>();

sub.Request(1);
Expand All @@ -301,7 +317,9 @@ await this.AssertAllStagesStoppedAsync(async () => {
var sub = await s.ExpectSubscriptionAsync();
AssertSuccess(queue.OfferAsync(1));

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
queue.OfferAsync(2).PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
await ExpectNoMsgAsync(_pause);

sub.Request(1);
Expand All @@ -326,7 +344,9 @@ await this.AssertAllStagesStoppedAsync(async() => {
.Run(_materializer);
var sub = await s.ExpectSubscriptionAsync();

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
queue.WatchCompletionAsync().ContinueWith(t => Done.Instance).PipeTo(TestActor);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
sub.Cancel();
await ExpectMsgAsync(Done.Instance);

Expand Down Expand Up @@ -402,8 +422,12 @@ public async Task QueueSource_should_complete_the_stream_when_buffer_is_full_and
var source = tuple.Item1;
var probe = tuple.Item2;

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
source.OfferAsync(1);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
source.OfferAsync(2);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
source.Complete();
await probe.RequestNext(1)
.RequestNext(2)
Expand Down Expand Up @@ -440,7 +464,9 @@ public async Task QueueSource_should_complete_the_stream_when_no_buffer_is_used_
var source = tuple.Item1;
var probe = tuple.Item2;

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
source.OfferAsync(1);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
source.Complete();
await probe.RequestNext(1).ExpectCompleteAsync();
var task = source.WatchCompletionAsync();
Expand Down