This statement when run from a console application sets 'x' to true
:
var x = 3.GetType().IsAssignableTo(typeof(INumber<>)); // x == true
The same statement when run inside a unit test sets x
to false
. Why?
This was a bug that was introduced in .NET 6, and fixed in .NET 8.
The correct behaviour is that uninstantiated generics are not AssignableTo.
I guess this makes sense, as you can't write INumber<> x = 3
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With