In the example below, I'm trying to understand why the BaseType
is not a generic type definition and more generally, why it isn't just equal to the typeof(List<>)
public class MyList<T> : List<T>
{
}
// this is true by definition
typeof(List<>).IsGenericTypeDefinition
// this is false
// also the BaseType.FullName is null ?!?
// also BaseType.IsConstructedGenericType is true ?!?!?
// as such, BaseType != typeof(List<>)
typeof(MyList<>).BaseType.IsGenericTypeDefinition;
EDIT - Here are some useful links on related topics:
Difference between Type.IsGenericTypeDefinition and Type.ContainsGenericParameters
What exactly is an "open generic type" in .NET?
Generics -Open and closed constructed Types
Detect if a generic type is open?
https://learn.microsoft.com/en-us/dotnet/api/system.type.isgenerictype
Difference between IsGenericType and IsGenericTypeDefinition