Skip to content
Discussion options

You must be logged in to vote

I did it by using a dummy optional parameter:

https://github.com/YairHalberstadt/stronginject/blob/86f0e766bb2a2028d302f9402db166ca42cb7b84/StrongInject/ContainerExtensions.cs#L44-L56

So in your case that would be:

/// <summary>
/// A class with no possible value other than null. Used to mark an optional parameter which should never be set.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class DummyParameter
{
    private DummyParameter() { }
}
    
void Foo(Func<Task> task)
void Foo(Func<ValueTask> task, DummyParameter? _ = null)

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@maxkoshevoi
Comment options

Answer selected by maxkoshevoi
Comment options

You must be logged in to vote
1 reply
@maxkoshevoi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants