akkadotnet / akka.analyzers

Roslyn analyzers for Akka.NET developers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Aaronontheweb opened this issue · comments

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.