-
Notifications
You must be signed in to change notification settings - Fork 60
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
Improve asynchronous calls #10
Improve asynchronous calls #10
Conversation
Hi Jan-Pieter Thanks for the PR! It's greatly appreciated so keep 'em coming! :-D Let have a talk about this and break that talk into two parts.
Directly returning vs async/awaitBefore DotPulsar moved to GitHub, for a long time I was returning directly whenever I could. The reason why I now consistently use async/await is because of David Fowler's guide: https://github.com/davidfowl/AspNetCoreDiagnosticScenarios/blob/master/AsyncGuidance.md#prefer-asyncawait-over-directly-returning-task Using ConfigureAwait(false)You may be right that we need to do this, however, I don't think the answer is so clear. Looking forward to hearing your thoughts on this :-) |
Thanks! For us, we always just do the (false) option and have an analyzer for it, ensuring that all code always uses at least one or the other. |
I wonder why Microsoft haven't just made a property for your csproj with what the default should be for your project and then automatically append ConfigureAwait(theValueFromCsProj) to all awaits when compiling... |
Agree, it's something the Fody project did, which I use sometimes (https://github.com/Fody/ConfigureAwait). It's an option. The Test project can be removed yeah, as I'm having the analyzer on it was easier to just have them all done. Let me know if you'd like me to:
And I'll send a new PR |
Fody sounds awesome! Just one question. Fody is installed as a "build dependency", but ConfigureAwait.Fody is installed as a "runtime dependency". I would guess that both were "build dependencies"? |
I just did some testing on another project.
And then changed FodyWeavers.xml to:
I can see with dotPeek that we get the ConfigureAwait(false) (on both Task and ValueTask) and Fody.ConfigureAwait is not added as a runtime dependency. If you can confirm, then you can alter the PR to actually just adding Fody and then we can create a 0.7.1 :-) |
@blankensteiner no clue how you got it to work, neither of the assemblies on my end get it. Any idea what's different? |
Damn, that was 1½ hours of my life that I will never get back. Damn you dotPeek! Ok, I know what might have troubled you. First, VS seems a bit weird, needing to restart (and/or clearing) sometimes before realizing that you have changed nuget-info on an existing package. Second, dotPeek is acting up. The first problem is that it is caching decompiled code, so I have to restart dotPeek every time I change the dll. Second, I can't have the "same dll" open multiple time, meaning I have DotPulsar 0.7.0 in one folder and the DotPulsar 0.7.0 in another folder, because when I ask to see something in the second I get the cached view from the first. What a mess. One more thing, I found out we only need this when including ConfigureAwait.Fody (makes it a bit shorter):
I'm btw ok when adding the xsd file to gitignore, but also ok with it being there. Up to you. |
Right, that was odd. I ran into the same thing here. I did see it happen, but the ValueTasks didn't get the ConfigureAwait added on here. For now we can merge this at least, that'd be more something for Fody to pick up. |
Following advise we always follow in libraries:. There's probably a couple more places where there's an explicit async/await where it can be avoided, as for example:
public async Task Send(CommandPing command) => await Send(command.AsBaseCommand());
can become
public Task Send(CommandPing command) => Send(command.AsBaseCommand());