There are eight different enumerated values for System.Reflection.MemberTypes. Five map directly to specific MemberInfo classes (ConstructorInfo, MemberInfo, etc.). The MemberTypes.NestedType can be thought of as Type rather than a MemberInfo. I'm trying to get my head around (1) MemberTypes.Custom and (2) MemberTypes.TypeInfo members. Does anyone have an example of such members?
public class Foo
{
public class Bar { }
}
With these two classes the following will be true.
typeof(Foo).MemberType == MemberTypes.TypeInfo
typeof(Foo.Bar).MemberType == MemberTypes.NestedType
Both TypeInfo
and NestedType
indicate that you are dealing with a type with the distinction whether the type is nested or not. The enumeration value TypeInfo
just sticks with the naming convention while the actual subtype of MemberInfo
is Type
. On the one hand Type
should have been called TypeInfo
to stick with the naming convention, on the other hand it seems a bit questionable that Type
is derived from MemberInfo
in the first place. But that is just the way it is. Maybe member in MemberInfo
should be better understood as assembly or type member instead of just type member.
Since .NET 4.5 there is new subclass TypeInfo
inheriting from Type
and accessible using the Type.GetTypeInfo()
extension method; see there for the distinction.
I am not sure about MemberTypes.Custom
but looking at CLI specification, especially II.10.2, it may be the case that this refers to custom attributes or other custom data associated with a type. Looking at the .NET reference source code does not provide additional insight either.
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