Skip to content
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

Add analyzer and fixer for (AK1002) Must not await GracefulStop() inside ReceiveAsync #58

Merged

Conversation

Arkatufus
Copy link
Contributor

Fixes #49

Changes

  • Add new rule AK1002
  • Add analyzer
  • Add fixer

Converts

ReceiveAsync<string>(async str => {
    await Context.Self.GracefulStop(TimeSpan.FromSeconds(3));
});

to

ReceiveAsync<string>(async str => {
    _ = Context.Self.GracefulStop(TimeSpan.FromSeconds(3));
});

Converts

ReceiveAsync<string>(async str => await Context.Self.GracefulStop(TimeSpan.FromSeconds(3)));

to

ReceiveAsync<string>(async str => _ = Context.Self.GracefulStop(TimeSpan.FromSeconds(3)));

Copy link
Member

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

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

Only question I have is on the code fix - see comments

}, SyntaxKind.InvocationExpression);
}

private static bool IsInsideReceiveAsyncLambda(SyntaxNode node, SemanticModel semanticModel, AkkaContext akkaContext)
Copy link
Member

Choose a reason for hiding this comment

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

LGTM - this might be a pretty useful thing to have for some other analysis rules in the future too.

Copy link
Member

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

Choose a reason for hiding this comment

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

LGTM

@Aaronontheweb Aaronontheweb merged commit 4f86366 into akkadotnet:dev Jan 18, 2024
2 checks passed
@Arkatufus Arkatufus deleted the AK1002-MustNotAwaitGracefulStop branch January 25, 2024 18:28
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.

AK1000: don't allow actors to await on their own GracefulStop inside a ReceiveAsync
2 participants