Skip to content

[CS1998] This async method lacks 'await' operators and will run synchronously #6513

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 6 commits into from
Mar 15, 2023

Conversation

eaba
Copy link
Contributor

@eaba eaba commented Mar 13, 2023

Changes

"warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread."

Checklist

For significant changes, please ensure that the following have been completed (delete if not relevant):

Latest dev Benchmarks

Include data from the relevant benchmark prior to this change here.

This PR's Benchmarks

Include data from after this change here.

@@ -184,7 +184,8 @@ protected override bool ReceivePluginInternal(object message)

private async Task<(IEnumerable<string> Ids, int LastOrdering)> SelectAllPersistenceIdsAsync(int offset)
{
return (new HashSet<string>(_allMessages.Skip(offset).Select(p => p.PersistenceId)), _allMessages.Count);
return await Task.FromResult((new HashSet<string>(_allMessages.Skip(offset).Select(p => p.PersistenceId)), _allMessages.Count));
Copy link
Contributor Author

@eaba eaba Mar 13, 2023

Choose a reason for hiding this comment

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

Let's talk about this @Aaronontheweb @Arkatufus

image

Copy link
Member

Choose a reason for hiding this comment

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

I'd remove the async and the await here - just returning the Task.Result should be fine.

@@ -207,7 +208,8 @@ private async Task<int> ReplayTaggedMessagesAsync(ReplayTaggedMessages replay)
index++;
}

return _tagsToMessagesMapping[replay.Tag].Count - 1;
return await Task.FromResult(_tagsToMessagesMapping[replay.Tag].Count - 1);
Copy link
Contributor Author

@eaba eaba Mar 13, 2023

Choose a reason for hiding this comment

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

Let's talk about this @Aaronontheweb @Arkatufus

image

Copy link
Member

Choose a reason for hiding this comment

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

Same feedback as above.

@Aaronontheweb
Copy link
Member

@eaba is this ready for review?

@eaba
Copy link
Contributor Author

eaba commented Mar 13, 2023

I will tell you @Aaronontheweb

eaba added 2 commits March 13, 2023 16:54
- `TestPublisher.cs`
- `Utils.cs`
- `EventFilterApplier.cs`
- `BlockingQueue.cs`
- `TestKitBase_AwaitConditions.cs`
- `TestKitBase_Within.cs`
@eaba eaba marked this pull request as ready for review March 13, 2023 17:11
@Aaronontheweb
Copy link
Member

Akka.Tests.Actor.LocalActorRefProviderSpec.An_ActorRefFactory_must_only_create_one_instance_of_an_actor_with_a_specific_address_in_a_concurrent_environment
Akka.Actor.InvalidActorNameException : Actor name "new-actor0" is not unique!

This is broken

@eaba eaba closed this Mar 14, 2023
@eaba eaba reopened this Mar 14, 2023
@Aaronontheweb Aaronontheweb merged commit e55a5a5 into akkadotnet:dev Mar 15, 2023
@eaba eaba deleted the CS1998 branch March 15, 2023 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants