You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
xUnit2007 warns to change Assert.IsAssignableFrom(typeof(IInterface), new Class()); into Assert.IsAssignableFrom<IInterface>(new Class());. However this is impossible and results in a CS8920 compiler error because interfaces with virtual static members cannot be used as a type parameter.
I did some research on the issue. A year ago there was a long discussion on whether to disallow static abstract members as type parameters for generics or not, and apparently now it's a part of .NET 7.0, C#11 (and C# 10 preview).
Clearly, .NET Framework does not support it. I think we can take advantage of notifying user about xUnit2007 if there is a static abstract member for any target runtime though. If the construction is not supported, there would be a compile error in the first place, so skipping xUnit2007 doesn't matter.
This is still not a mainline language feature as the issue is still open: dotnet/csharplang#4436
As such, I'm reluctant to merge the proposed fix, even though it seems simple enough, because we generally don't track previews for concerns that the proposal might be rejected and/or whatever code we add may be wrong in the face of the evolution of the feature.
xUnit2007 warns to change
Assert.IsAssignableFrom(typeof(IInterface), new Class());
intoAssert.IsAssignableFrom<IInterface>(new Class());
. However this is impossible and results in a CS8920 compiler error because interfaces with virtual static members cannot be used as a type parameter.Repro
The text was updated successfully, but these errors were encountered: