-
Notifications
You must be signed in to change notification settings - Fork 164
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
Added overload to switch method for use with async code. #106
base: master
Are you sure you want to change the base?
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? |
@@ -100,6 +104,18 @@ public void Switch({RangeJoined(", ", e => $"Action<T{e}> f{e}")}) | |||
throw new InvalidOperationException(); | |||
}} | |||
|
|||
#if !NET35 | |||
public Task Switch({RangeJoined(", ", e => $"Func<T{e}, Task> f{e}")}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename this to SwitchAsync
.
@@ -100,6 +104,18 @@ public void Switch({RangeJoined(", ", e => $"Action<T{e}> f{e}")}) | |||
throw new InvalidOperationException(); | |||
}} | |||
|
|||
#if !NET35 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Switch
instead of a separateSwitchAsync
because I think it will provide a better default experience. As soon as someone addsasync
to 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.