Skip to content
New issue

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

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

Already on GitHub? # to your account

AK1001: Sender closure not detected in PipeTo when Context.Sender is used instead of this.Sender #52

Closed
Aaronontheweb opened this issue Jan 16, 2024 · 0 comments · Fixed by #54
Labels
AK1000 Actor design rules. bug Something isn't working

Comments

@Aaronontheweb
Copy link
Member

Version Information
Version of Akka.NET? v0.2.0
Which Akka.NET Modules? Akka.Analyzers

Describe the bug

using Akka.Actor;
using System.Threading.Tasks;

public sealed class MyActor : UntypedActor{

   protected override void OnReceive(object message){
       async Task<int> LocalFunction(){
           await Task.Delay(10);
           return message.ToString().Length;
       }

       // incorrect use of closures
       LocalFunction().PipeTo(Context.Sender);
   }
}

Context.Sender should get flagged by AK1001 but currently does not, even though it's equally unsafe.

@Aaronontheweb Aaronontheweb added bug Something isn't working AK1000 Actor design rules. labels Jan 16, 2024
Aaronontheweb added a commit to Aaronontheweb/akka.analyzers that referenced this issue Jan 16, 2024
@Aaronontheweb Aaronontheweb changed the title AK1001: Sender closure not detected in PipeTo when Context.Sender is used instead of this.Sender AK1002: Sender closure not detected in PipeTo when Context.Sender is used instead of this.Sender Jan 16, 2024
@Aaronontheweb Aaronontheweb changed the title AK1002: Sender closure not detected in PipeTo when Context.Sender is used instead of this.Sender AK1001: Sender closure not detected in PipeTo when Context.Sender is used instead of this.Sender Jan 16, 2024
@Arkatufus Arkatufus mentioned this issue Jan 16, 2024
4 tasks
Aaronontheweb added a commit that referenced this issue Jan 16, 2024
* AK2001: harden so rule only runs for Akka.NET v1.5.15 and later

* fixed package warning

* added failure cases for #52

* added fix to Analyzer

* Fix bad expected value

---------

Co-authored-by: Aaron Stannard <aaron@petabridge.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
AK1000 Actor design rules. bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant