AK1001 CodeFix bugs
Aaronontheweb opened this issue · comments
Thanks for the explanation @Aaronontheweb. But I've one follow up question regarding this topic.
Also @wesselkranenborg, you code is fine - minus the bit I said about the perf hit using
ReceiveAsync
instead ofReceive
when you're not performing anyawait
s.
Basically we are now writing non-blocking code if I hear you correctly. And we might thus break the actor model?
I've three examples on how we could write this:
In this example we have the LeaveClusterCore
async method which is awaiting code. We want this method to be executed and freeing up the actor once this logic is performed. We are now using the first method, the second method is to make it with the Receive<> but if I hear you correctly we should use the last way of writing it. Am I correct on that?
Originally posted by @wesselkranenborg in #55 (comment)
From me on #55
Thanks for the answers
Your second example is fine and should not be flagged by AK1001 (is it being flagged currently?)
Yes, it is.
Question, why is this code safe?
this.Receive<Message>(s ==> MessageHandler(s).PipeTo(this.Sender));
Question, why is this code safe?
this.Receive<Message>(s ==> MessageHandler(s).PipeTo(this.Sender));
Ah, is MessageHandler
returning a Task
? If so it's not safe and the analyzer is right, so we could close this issue. @akkadotnet/ci-admins
whoops, meant to tag you @Arkatufus
Judging by the context of the other code fragments, LeaveClusterCore()
does return a Task
.
My mistake then.