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

AK1001: must close over Sender when using PipeTo #5

Merged
merged 8 commits into from
Dec 28, 2023

Conversation

Aaronontheweb
Copy link
Member

Changes

Not 100% sure that this is an issue in newer versions of Akka.NET, but it's still a good idea to enforce this.

Should flag the following code:

using Akka.Actor;

public sealed class MyActor : ReceiveActor{
    Receive<string>(str => {
         async Task<int> LocalFunction(){
              await Task.Delay(10);
              return str.Length;
         }

         // invoke detatched async Task and PipeTo sender
         LocalFunction().PipeTo(Sender); // BUG: need to close over this.Sender using a local variable, because that value can change by the time the async function finishes evaluating.
     });
}

@Aaronontheweb Aaronontheweb marked this pull request as ready for review December 28, 2023 05:02
@Aaronontheweb Aaronontheweb enabled auto-merge (squash) December 28, 2023 05:02
@Aaronontheweb Aaronontheweb merged commit c12bd30 into master Dec 28, 2023
2 checks passed
@Aaronontheweb Aaronontheweb deleted the pipeto-closure branch December 28, 2023 05:02
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.

1 participant