C
Join ServerC#
help
Interfaces containing static abstracts as type arguments
Tthinker2279/15/2022
So curiously, this works
but these don't
Is there any way to work around this without using a regular factory interface?
public interface IFoo
{
static abstract IFoo Create();
}
but these don't
public interface IBar
{
static abstract Task<IBar> CreateAsync();
}
public interface IBar<TSelf> where TSelf : IBar<TSelf>
{
static abstract Task<IBar<TSelf>> CreateAsync();
}
The interface 'IBar' cannot be used as type argument. Static member 'IBar.CreateAsync()' does not have a most specific implementation in the interface.
Is there any way to work around this without using a regular factory interface?
OOrannis9/15/2022
Just return TSelf from CreateAsync
Tthinker2279/15/2022
Oh yeah, right
Tthinker2279/15/2022
Yeah I'm slowly realizing this use-case isn't even that good