Added overload to switch method for use with async code.#106
Added overload to switch method for use with async code.#106bwarthur wants to merge 1 commit intomcintyre321:masterfrom
Conversation
|
Will this result in IDE's highlighting that the Switch method is now The problem i tried to highlight in the original issue wasn't with dicovery of the async method, but rather its usage - IMO, developers will still forget to call Having an This SO post has a similar belief https://stackoverflow.com/a/47810905 @mcintyre321 what do you think? |
| }} | ||
|
|
||
| #if !NET35 | ||
| public Task Switch({RangeJoined(", ", e => $"Func<T{e}, Task> f{e}")}) |
| throw new InvalidOperationException(); | ||
| }} | ||
|
|
||
| #if !NET35 |
There was a problem hiding this comment.
This should probably be (!NETFRAMEWORK || NET40_OR_GREATER) instead of !NET35
|
Hi, would love to see this PR merged |
|
How does this compare to doing: await oneOf.Match<Task>( t1 => Task.CompletedTask, t2 => Task.CompletedTask); |
|
I badly need this. Any chance this happens? |
|
Is this ever gonna merged? |
|
Sorry, I'm not keen on adding this, and increasing the code/assembly size.
It seems to me that using the Match overload with the async keyword already
handles this capability.
Perhaps you could release it as a standalone nuget package.
…On Thu, 29 Feb 2024, 17:23 Md. Redwan Hossain, ***@***.***> wrote:
Is this ever gonna merged?
—
Reply to this email directly, view it on GitHub
<#106 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACDJ6TNCEDZ2427A7G5R2LYV5R25AVCNFSM5OLZ56QKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJXGE3DCMRRGE2A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Fixes #84.
I went with doing an overload of
Switchinstead of a separateSwitchAsyncbecause I think it will provide a better default experience. As soon as someone addsasyncto each of the actions, it will switch over to theFunc<>overload instead of relying on someone to know to go look for an explicitly named Async version.