I have the following implementation which uses .NET 7's static abstract member functionality:
public interface IFoo
{
public static abstract string Bar { get; }
}
public class Foo : IFoo
{
public static string Bar => "Bar"
}
Now, whenever I use the interface as a type parameter to a generic class, I get an error. For example, if my Program.cs looks like this:
List<IFoo> fooList = new List<Foo>();
I get the following error:
error CS8920: The interface 'IFoo' cannot be used as type argument. Static member 'IFoo.Bar' does not have a most specific implementation in the interface.
I guess that, for whatever reason, this is a C# restriction. I could be wrong, though, so now I'm asking: is there any way to solve this case or at least get around this restriction?