We're updating the issue view to help you get more done. 

Finish implementation of MutableType


The following methods should be implemented by returning hard-coded values (easy).

  • GetElementType: null

  • IsArrayImpl: false

  • IsPointerImpl: false

  • IsPrimitiveImpl: false

  • IsCOMObjectImpl: false

For now implement these members as follows:

  • Module: return null (like Assembly)

  • GUID: throws NotSupportedException

  • AssemblyQualifiedName: throws NotSupportedException

  • InvokeMember(string name, BindingFlags invokeAttr, Binder binderOrNull, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters)

    • throws NotSupportedException

TODOs for existing Members:

  • GetFields: Support DeclaredOnly and FlattenHierarchy flags

    • Change UnderlyingTypeDescriptor.ExistingFields to also contain inherited static fields (include FlattenHierarchy flag in UnderlyingTypeDescriptor.GetAllFields)

    • Refactor IBindingFlagsEvaluator: Change HasRightAttributes methods to take MethodBase and FieldInfo, plus MutableType reflectedType.

    • Change BindingFlagsEvaluator to support DeclaredOnly/FlattenHierarchy, based on method/field.DeclaringType and reflectedType.

    • Rename HasRightAttributes to something more appropriate, e.g., IsMatch.

Implement the following (more involved).

  • GetMembers (BindingFlags bindingAttr)

    • Concatenate results of GetFields(..), GetConstructors(..), etc.

  • GetMember

    • Use GetMembers.

  • GetInterface (string name, bool ignoreCase)

    • Implement using GetInterfaces and filter by name

  • GetEvent

  • GetEvents

  • GetNestedTypes

  • GetNestedType

  • GetPropertyImpl

  • GetProperties

  • GetMethodImpl

  • GetMethods

  • GetCustomAttributes (bool inherit)

    • Add UnderlyingTypeDescriptor.GetCustomAttributes (bool). Implement by storing a Func<bool, object[]> _customAttributeProvider in UnderlyingTypeDescriptor. The Create method passes in inherit => originalType.GetCustomAttributes (inherit).

  • IsDefined (Type attributeType, bool inherit)

    • Like GetCustomAttributes.

  • GetCustomAttributes (Type attributeType, bool inherit)

    • Like GetCustomAttributes.

  • IsGeneric, IsGenericTypeDefinition, GetGenericTypeDefinition, GetGenericArguments

    • Forward to descriptor. For new types: false, false, etc.

    • Use in ModifyGenericTypeTest (see TODO comment).

Other virtual members:

  • Add tests.

  • For methods throwing exceptions, discuss whether they should be implemented.

    • Don't support MakePointerType, MakeByRefType, MakeArrayType, StructLayoutAttribute.

    • GetArrayRank, GenericParameterAttributes, GenericParameterPosition, GetGenericParameterConstraints, MakeGenericType should do the same as any non-array/non-generic-parameter/non-generic type.

      • There should be a check that the underlying type for a mutable type cannot be a pointer, byref, array type, generic parameter.

    • GetInterfaceMap should throw for now.

    • MetadataToken should throw (as long as Module always returns null).

      • This means that we also cannot support CustomAttributeData.GetCustomAttributes

  • IsAssignableFrom (Type c)

    • For existing types, the default impl should work alright (mutableType.IsAssignableFrom (originalType) == true, mutableType.IsAssignableFrom (mutableType) == true, mutableType.IsAssignableFrom (subTypeOfOriginalType) == true, mutableType.IsAssignableFrom (baseOfOriginalType) == false, mutableType.IsAssignableFrom (intefaceOfOriginalType) == false, mutableType.IsAssignableFrom (unrelatedType) == false).

    • For added types, an override is required to support the desired semantics (mutableType.IsAssignableFrom (mutableType) == true, mutableType.IsAssignableFrom (baseType) == false, mutableType.IsAssignableFrom (baseInterface) == false, mutableType.IsAssignableFrom (unrelatedType) == false, assertion that argument cannot have a MutableType as base class).

  • Add an IsAssignableTo (Type type) method:

    • For new types, returns true for: type, base types (iterate over hierarchy), interfaces. False for everything else.

    • For existing types, returns true for: type, base types, interfaces, original type.

  • IsInstanceOfType (object o)

    • After implementing IsAssignableFrom, this should work for existing types. (Cannot be true for new types.)

  • Equals and GetHashCode

    • Leave implementation, just add tests comparing mutable types with themselves, with other types, and with original type.




User known



Time tracking



Fix versions