public static String ComputeToString(MethodBase contextMethod, RuntimeTypeInfo[] methodTypeArguments, RuntimeParameterInfo[] runtimeParametersAndReturn) { StringBuilder sb = new StringBuilder(30); sb.Append(runtimeParametersAndReturn[0].ParameterTypeString); sb.Append(' '); sb.Append(contextMethod.Name); if (methodTypeArguments.Length != 0) { String sep = ""; sb.Append('['); foreach (RuntimeTypeInfo methodTypeArgument in methodTypeArguments) { sb.Append(sep); sep = ","; String name = methodTypeArgument.InternalNameIfAvailable; if (name == null) name = ToStringUtils.UnavailableType; sb.Append(methodTypeArgument.Name); } sb.Append(']'); } sb.Append('('); sb.Append(ComputeParametersString(runtimeParametersAndReturn, 1)); sb.Append(')'); return sb.ToString(); }
// // propertyHandle - the "tkPropertyDef" that identifies the property. // definingType - the "tkTypeDef" that defined the field (this is where you get the metadata reader that created propertyHandle.) // contextType - the type that supplies the type context (i.e. substitutions for generic parameters.) Though you // get your raw information from "definingType", you report "contextType" as your DeclaringType property. // // For example: // // typeof(Foo<>).GetTypeInfo().DeclaredMembers // // The definingType and contextType are both Foo<> // // typeof(Foo<int,String>).GetTypeInfo().DeclaredMembers // // The definingType is "Foo<,>" // The contextType is "Foo<int,String>" // // We don't report any DeclaredMembers for arrays or generic parameters so those don't apply. // private NativeFormatRuntimePropertyInfo(PropertyHandle propertyHandle, NativeFormatRuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo, RuntimeTypeInfo reflectedType) : base(contextTypeInfo, reflectedType) { _propertyHandle = propertyHandle; _definingTypeInfo = definingTypeInfo; _reader = definingTypeInfo.Reader; _property = propertyHandle.GetProperty(_reader); }
// // fieldHandle - the "tkFieldDef" that identifies the field. // definingType - the "tkTypeDef" that defined the field (this is where you get the metadata reader that created fieldHandle.) // contextType - the type that supplies the type context (i.e. substitutions for generic parameters.) Though you // get your raw information from "definingType", you report "contextType" as your DeclaringType property. // // For example: // // typeof(Foo<>).GetTypeInfo().DeclaredMembers // // The definingType and contextType are both Foo<> // // typeof(Foo<int,String>).GetTypeInfo().DeclaredMembers // // The definingType is "Foo<,>" // The contextType is "Foo<int,String>" // // We don't report any DeclaredMembers for arrays or generic parameters so those don't apply. // private NativeFormatRuntimeFieldInfo(FieldHandle fieldHandle, NativeFormatRuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo, RuntimeTypeInfo reflectedType) : base(contextTypeInfo, reflectedType) { _fieldHandle = fieldHandle; _definingTypeInfo = definingTypeInfo; _reader = definingTypeInfo.Reader; _field = fieldHandle.GetField(_reader); }
// // eventHandle - the "tkEventDef" that identifies the event. // definingType - the "tkTypeDef" that defined the field (this is where you get the metadata reader that created eventHandle.) // contextType - the type that supplies the type context (i.e. substitutions for generic parameters.) Though you // get your raw information from "definingType", you report "contextType" as your DeclaringType property. // // For example: // // typeof(Foo<>).GetTypeInfo().DeclaredMembers // // The definingType and contextType are both Foo<> // // typeof(Foo<int,String>).GetTypeInfo().DeclaredMembers // // The definingType is "Foo<,>" // The contextType is "Foo<int,String>" // // We don't report any DeclaredMembers for arrays or generic parameters so those don't apply. // private NativeFormatRuntimeEventInfo(EventHandle eventHandle, NativeFormatRuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo, RuntimeTypeInfo reflectedType) : base(contextTypeInfo, reflectedType) { _eventHandle = eventHandle; _definingTypeInfo = definingTypeInfo; _reader = definingTypeInfo.Reader; _event = eventHandle.GetEvent(_reader); }
private RuntimeSyntheticConstructorInfo(SyntheticMethodId syntheticMethodId, RuntimeTypeInfo declaringType, RuntimeTypeInfo[] runtimeParameterTypes, InvokerOptions options, Func<Object, Object[], Object> invoker) { _syntheticMethodId = syntheticMethodId; _declaringType = declaringType; _options = options; _invoker = invoker; _runtimeParameterTypes = runtimeParameterTypes; }
public TypeInfoCachedData(RuntimeTypeInfo runtimeTypeInfo) { _runtimeTypeInfo = runtimeTypeInfo; _methodLookupDispenser = new DispenserThatAlwaysReuses<String, RuntimeMethodInfo>(LookupDeclaredMethodByName); _fieldLookupDispenser = new DispenserThatAlwaysReuses<String, RuntimeFieldInfo>(LookupDeclaredFieldByName); _propertyLookupDispenser = new DispenserThatAlwaysReuses<String, RuntimePropertyInfo>(LookupDeclaredPropertyByName); _eventLookupDispenser = new DispenserThatAlwaysReuses<String, RuntimeEventInfo>(LookupDeclaredEventByName); }
// // methodHandle - the "tkMethodDef" that identifies the method. // definingType - the "tkTypeDef" that defined the method (this is where you get the metadata reader that created methodHandle.) // contextType - the type that supplies the type context (i.e. substitutions for generic parameters.) Though you // get your raw information from "definingType", you report "contextType" as your DeclaringType property. // // For example: // // typeof(Foo<>).GetTypeInfo().DeclaredMembers // // The definingType and contextType are both Foo<> // // typeof(Foo<int,String>).GetTypeInfo().DeclaredMembers // // The definingType is "Foo<,>" // The contextType is "Foo<int,String>" // // We don't report any DeclaredMembers for arrays or generic parameters so those don't apply. // public RuntimeMethodCommon(MethodHandle methodHandle, RuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo) { _definingTypeInfo = definingTypeInfo; _methodHandle = methodHandle; _contextTypeInfo = contextTypeInfo; _reader = definingTypeInfo.Reader; _method = methodHandle.GetMethod(_reader); }
// // eventHandle - the "tkEventDef" that identifies the event. // definingType - the "tkTypeDef" that defined the field (this is where you get the metadata reader that created eventHandle.) // contextType - the type that supplies the type context (i.e. substitutions for generic parameters.) Though you // get your raw information from "definingType", you report "contextType" as your DeclaringType property. // // For example: // // typeof(Foo<>).GetTypeInfo().DeclaredMembers // // The definingType and contextType are both Foo<> // // typeof(Foo<int,String>).GetTypeInfo().DeclaredMembers // // The definingType is "Foo<,>" // The contextType is "Foo<int,String>" // // We don't report any DeclaredMembers for arrays or generic parameters so those don't apply. // private RuntimeEventInfo(EventHandle eventHandle, RuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo) { _eventHandle = eventHandle; _definingTypeInfo = definingTypeInfo; _contextTypeInfo = contextTypeInfo; _reader = definingTypeInfo.Reader; _event = eventHandle.GetEvent(_reader); }
// // fieldHandle - the "tkFieldDef" that identifies the field. // definingType - the "tkTypeDef" that defined the field (this is where you get the metadata reader that created fieldHandle.) // contextType - the type that supplies the type context (i.e. substitutions for generic parameters.) Though you // get your raw information from "definingType", you report "contextType" as your DeclaringType property. // // For example: // // typeof(Foo<>).GetTypeInfo().DeclaredMembers // // The definingType and contextType are both Foo<> // // typeof(Foo<int,String>).GetTypeInfo().DeclaredMembers // // The definingType is "Foo<,>" // The contextType is "Foo<int,String>" // // We don't report any DeclaredMembers for arrays or generic parameters so those don't apply. // private RuntimeFieldInfo(FieldHandle fieldHandle, RuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo) { _fieldHandle = fieldHandle; _definingTypeInfo = definingTypeInfo; _contextTypeInfo = contextTypeInfo; _reader = definingTypeInfo.Reader; _field = fieldHandle.GetField(_reader); }
// // propertyHandle - the "tkPropertyDef" that identifies the property. // definingType - the "tkTypeDef" that defined the field (this is where you get the metadata reader that created propertyHandle.) // contextType - the type that supplies the type context (i.e. substitutions for generic parameters.) Though you // get your raw information from "definingType", you report "contextType" as your DeclaringType property. // // For example: // // typeof(Foo<>).GetTypeInfo().DeclaredMembers // // The definingType and contextType are both Foo<> // // typeof(Foo<int,String>).GetTypeInfo().DeclaredMembers // // The definingType is "Foo<,>" // The contextType is "Foo<int,String>" // // We don't report any DeclaredMembers for arrays or generic parameters so those don't apply. // private RuntimePropertyInfo(PropertyHandle propertyHandle, RuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo) { _propertyHandle = propertyHandle; _definingTypeInfo = definingTypeInfo; _contextTypeInfo = contextTypeInfo; _reader = definingTypeInfo.Reader; _property = propertyHandle.GetProperty(_reader); }
internal sealed override IEnumerable<PropertyInfo> CoreGetDeclaredProperties(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType, RuntimeTypeInfo contextTypeInfo) { MetadataReader reader = Reader; foreach (PropertyHandle propertyHandle in DeclaredPropertyHandles) { if (optionalNameFilter == null || optionalNameFilter.Matches(propertyHandle.GetProperty(reader).Name, reader)) yield return NativeFormatRuntimePropertyInfo.GetRuntimePropertyInfo(propertyHandle, this, contextTypeInfo, reflectedType); } }
internal sealed override IEnumerable<EventInfo> CoreGetDeclaredEvents(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType, RuntimeTypeInfo contextTypeInfo) { MetadataReader reader = Reader; foreach (EventHandle eventHandle in DeclaredEventHandles) { if (optionalNameFilter == null || optionalNameFilter.Matches(eventHandle.GetEvent(reader).Name, reader)) yield return NativeFormatRuntimeEventInfo.GetRuntimeEventInfo(eventHandle, this, contextTypeInfo, reflectedType); } }
private RuntimeSyntheticMethodInfo(SyntheticMethodId syntheticMethodId, String name, RuntimeTypeInfo declaringType, RuntimeTypeInfo[] runtimeParameterTypesAndReturn, InvokerOptions options, Func<Object, Object[], Object> invoker) { _syntheticMethodId = syntheticMethodId; _name = name; _declaringType = declaringType; _options = options; _invoker = invoker; _runtimeParameterTypesAndReturn = runtimeParameterTypesAndReturn; }
public RuntimePseudoCustomAttributeData(RuntimeTypeInfo attributeType, IList<CustomAttributeTypedArgument> constructorArguments, IList<CustomAttributeNamedArgument> namedArguments) { _attributeType = attributeType; if (constructorArguments == null) constructorArguments = Array.Empty<CustomAttributeTypedArgument>(); _constructorArguments = new ReadOnlyCollection<CustomAttributeTypedArgument>(constructorArguments); if (namedArguments == null) namedArguments = Array.Empty<CustomAttributeNamedArgument>(); _namedArguments = new ReadOnlyCollection<CustomAttributeNamedArgument>(namedArguments); return; }
internal sealed override IEnumerable<MethodInfo> CoreGetDeclaredMethods(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType, RuntimeTypeInfo contextTypeInfo) { MetadataReader reader = Reader; foreach (MethodHandle methodHandle in DeclaredMethodAndConstructorHandles) { Method method = methodHandle.GetMethod(reader); if (MetadataReaderExtensions.IsConstructor(ref method, reader)) continue; if (optionalNameFilter == null || optionalNameFilter.Matches(method.Name, reader)) yield return RuntimeNamedMethodInfo<NativeFormatMethodCommon>.GetRuntimeNamedMethodInfo(new NativeFormatMethodCommon(methodHandle, this, contextTypeInfo), reflectedType); } }
public sealed override Exception TryResolve(RuntimeAssembly currentAssembly, bool ignoreCase, out RuntimeTypeInfo result) { result = null; if (AssemblyName == null) { return TypeName.TryResolve(currentAssembly, ignoreCase, out result); } else { RuntimeAssembly newAssembly; Exception assemblyLoadException = RuntimeAssembly.TryGetRuntimeAssembly(AssemblyName, out newAssembly); if (assemblyLoadException != null) return assemblyLoadException; return TypeName.TryResolve(newAssembly, ignoreCase, out result); } }
internal sealed override IEnumerable<ConstructorInfo> CoreGetDeclaredConstructors(NameFilter optionalNameFilter, RuntimeTypeInfo contextTypeInfo) { // // - It may sound odd to get a non-null name filter for a constructor search, but Type.GetMember() is an api that does this. // // - All GetConstructor() apis act as if BindingFlags.DeclaredOnly were specified. So the ReflectedType will always be the declaring type and so is not passed to this method. // MetadataReader reader = Reader; foreach (MethodHandle methodHandle in DeclaredMethodAndConstructorHandles) { Method method = methodHandle.GetMethod(reader); if (!MetadataReaderExtensions.IsConstructor(ref method, reader)) continue; if (optionalNameFilter == null || optionalNameFilter.Matches(method.Name, reader)) yield return RuntimePlainConstructorInfo<NativeFormatMethodCommon>.GetRuntimePlainConstructorInfo(new NativeFormatMethodCommon(methodHandle, this, contextTypeInfo)); } }
public sealed override Exception TryResolve(RuntimeAssembly currentAssembly, bool ignoreCase, out RuntimeTypeInfo result) { result = null; RuntimeTypeInfo declaringType; Exception typeLoadException = DeclaringType.TryResolve(currentAssembly, ignoreCase, out declaringType); if (typeLoadException != null) return typeLoadException; TypeInfo nestedTypeInfo = FindDeclaredNestedType(declaringType, Name, ignoreCase); if (nestedTypeInfo == null) return new TypeLoadException(SR.Format(SR.TypeLoad_TypeNotFound, declaringType.FullName + "+" + Name, currentAssembly.FullName)); result = nestedTypeInfo.CastToRuntimeTypeInfo(); return null; }
private QueriedMemberList(int totalCount, int declaredOnlyCount, M[] members, BindingFlags[] allFlagsThatMustMatch, RuntimeTypeInfo typeThatBlockedBrowsing) { _totalCount = totalCount; _declaredOnlyCount = declaredOnlyCount; _members = members; _allFlagsThatMustMatch = allFlagsThatMustMatch; _typeThatBlockedBrowsing = typeThatBlockedBrowsing; }
public static RuntimeTypeInfo GetPointerType(this RuntimeTypeInfo targetType, RuntimeTypeHandle precomputedTypeHandle) { return(RuntimePointerTypeInfo.GetPointerTypeInfo(targetType, precomputedTypeHandle)); }
public static RuntimeTypeInfo GetArrayType(this RuntimeTypeInfo elementType, RuntimeTypeHandle precomputedTypeHandle) { return(RuntimeArrayTypeInfo.GetArrayTypeInfo(elementType, multiDim: false, rank: 1, precomputedTypeHandle: precomputedTypeHandle)); }
public static RuntimeTypeInfo GetPointerType(this RuntimeTypeInfo targetType) { return(targetType.GetPointerType(default(RuntimeTypeHandle))); }
internal static RuntimeEventInfo GetRuntimeEventInfo(EventDefinitionHandle eventHandle, EcmaFormatRuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo, RuntimeTypeInfo reflectedType) { return(new EcmaFormatRuntimeEventInfo(eventHandle, definingTypeInfo, contextTypeInfo, reflectedType).WithDebugName()); }
internal static RuntimeSyntheticConstructorInfo GetRuntimeSyntheticConstructorInfo(SyntheticMethodId syntheticMethodId, RuntimeTypeInfo declaringType, RuntimeTypeInfo[] runtimeParameterTypes, InvokerOptions options, Func <Object, Object[], Object> invoker) { return(new RuntimeSyntheticConstructorInfo(syntheticMethodId, declaringType, runtimeParameterTypes, options, invoker)); }
// // Main routine to parse a metadata type specification signature. // private static RuntimeTypeInfo TryResolveTypeSignature(this TypeSpecificationHandle typeSpecHandle, MetadataReader reader, TypeContext typeContext, ref Exception exception) { Handle typeHandle = typeSpecHandle.GetTypeSpecification(reader).Signature; switch (typeHandle.HandleType) { case HandleType.ArraySignature: { ArraySignature sig = typeHandle.ToArraySignatureHandle(reader).GetArraySignature(reader); int rank = sig.Rank; if (rank <= 0) { throw new BadImageFormatException(); // Bad rank. } RuntimeTypeInfo elementType = sig.ElementType.TryResolve(reader, typeContext, ref exception); if (elementType == null) { return(null); } return(elementType.GetMultiDimArrayType(rank)); } case HandleType.ByReferenceSignature: { ByReferenceSignature sig = typeHandle.ToByReferenceSignatureHandle(reader).GetByReferenceSignature(reader); RuntimeTypeInfo targetType = sig.Type.TryResolve(reader, typeContext, ref exception); if (targetType == null) { return(null); } return(targetType.GetByRefType()); } case HandleType.MethodTypeVariableSignature: { MethodTypeVariableSignature sig = typeHandle.ToMethodTypeVariableSignatureHandle(reader).GetMethodTypeVariableSignature(reader); return(typeContext.GenericMethodArguments[sig.Number]); } case HandleType.PointerSignature: { PointerSignature sig = typeHandle.ToPointerSignatureHandle(reader).GetPointerSignature(reader); RuntimeTypeInfo targetType = sig.Type.TryResolve(reader, typeContext, ref exception); if (targetType == null) { return(null); } return(targetType.GetPointerType()); } case HandleType.SZArraySignature: { SZArraySignature sig = typeHandle.ToSZArraySignatureHandle(reader).GetSZArraySignature(reader); RuntimeTypeInfo elementType = sig.ElementType.TryResolve(reader, typeContext, ref exception); if (elementType == null) { return(null); } return(elementType.GetArrayType()); } case HandleType.TypeDefinition: { return(typeHandle.ToTypeDefinitionHandle(reader).ResolveTypeDefinition(reader)); } case HandleType.TypeInstantiationSignature: { TypeInstantiationSignature sig = typeHandle.ToTypeInstantiationSignatureHandle(reader).GetTypeInstantiationSignature(reader); RuntimeTypeInfo genericTypeDefinition = sig.GenericType.TryResolve(reader, typeContext, ref exception); if (genericTypeDefinition == null) { return(null); } LowLevelList <RuntimeTypeInfo> genericTypeArguments = new LowLevelList <RuntimeTypeInfo>(); foreach (Handle genericTypeArgumentHandle in sig.GenericTypeArguments) { RuntimeTypeInfo genericTypeArgument = genericTypeArgumentHandle.TryResolve(reader, typeContext, ref exception); if (genericTypeArgument == null) { return(null); } genericTypeArguments.Add(genericTypeArgument); } return(genericTypeDefinition.GetConstructedGenericType(genericTypeArguments.ToArray())); } case HandleType.TypeReference: { return(typeHandle.ToTypeReferenceHandle(reader).TryResolveTypeReference(reader, ref exception)); } case HandleType.TypeVariableSignature: { TypeVariableSignature sig = typeHandle.ToTypeVariableSignatureHandle(reader).GetTypeVariableSignature(reader); return(typeContext.GenericTypeArguments[sig.Number]); } default: throw new NotSupportedException(); // Unexpected Type signature type. } }
// // Main routine to resolve a typeReference. // private static RuntimeTypeInfo TryResolveTypeReference(this TypeReferenceHandle typeReferenceHandle, MetadataReader reader, ref Exception exception) { RuntimeTypeHandle resolvedRuntimeTypeHandle; if (ReflectionCoreExecution.ExecutionEnvironment.TryGetNamedTypeForTypeReference(reader, typeReferenceHandle, out resolvedRuntimeTypeHandle)) { return(resolvedRuntimeTypeHandle.GetTypeForRuntimeTypeHandle()); } TypeReference typeReference = typeReferenceHandle.GetTypeReference(reader); String name = typeReference.TypeName.GetString(reader); Handle parent = typeReference.ParentNamespaceOrType; HandleType parentType = parent.HandleType; TypeInfo outerTypeInfo = null; // Check if this is a reference to a nested type. if (parentType == HandleType.TypeDefinition) { outerTypeInfo = parent.ToTypeDefinitionHandle(reader).GetNamedType(reader); } else if (parentType == HandleType.TypeReference) { RuntimeTypeInfo outerType = parent.ToTypeReferenceHandle(reader).TryResolveTypeReference(reader, ref exception); if (outerType == null) { return(null); } outerTypeInfo = outerType; // Since we got to outerType via a metadata reference, we're assured GetTypeInfo() won't throw a MissingMetadataException. } if (outerTypeInfo != null) { // It was a nested type. We've already resolved the containing type recursively - just find the nested among its direct children. TypeInfo resolvedTypeInfo = outerTypeInfo.GetDeclaredNestedType(name); if (resolvedTypeInfo == null) { exception = ReflectionCoreExecution.ExecutionDomain.CreateMissingMetadataException(outerTypeInfo, name); return(null); } return(resolvedTypeInfo.CastToRuntimeTypeInfo()); } // If we got here, the typeReference was to a non-nested type. if (parentType == HandleType.NamespaceReference) { NamespaceReferenceHandle namespaceReferenceHandle = parent.ToNamespaceReferenceHandle(reader); string fullName = namespaceReferenceHandle.ToFullyQualifiedTypeName(name, reader); Handle parentHandleToSearch = parent; while (parentHandleToSearch.HandleType != HandleType.ScopeReference) { parentHandleToSearch = parentHandleToSearch.ToNamespaceReferenceHandle(reader).GetNamespaceReference(reader).ParentScopeOrNamespace; } ScopeReferenceHandle scopeReferenceHandle = parentHandleToSearch.ToScopeReferenceHandle(reader); RuntimeAssemblyName assemblyName = scopeReferenceHandle.ToRuntimeAssemblyName(reader); RuntimeAssembly runtimeAssembly; exception = RuntimeAssembly.TryGetRuntimeAssembly(assemblyName, out runtimeAssembly); if (exception != null) { return(null); } RuntimeTypeInfo runtimeType = runtimeAssembly.GetTypeCore(fullName, ignoreCase: false); if (runtimeType == null) { exception = Helpers.CreateTypeLoadException(fullName, assemblyName.FullName); return(null); } return(runtimeType); } throw new BadImageFormatException(); // Expected TypeReference parent to be typeRef, typeDef or namespaceRef. }
// // methodHandle - the "tkMethodDef" that identifies the method. // definingType - the "tkTypeDef" that defined the method (this is where you get the metadata reader that created methodHandle.) // contextType - the type that supplies the type context (i.e. substitutions for generic parameters.) Though you // get your raw information from "definingType", you report "contextType" as your DeclaringType property. // // For example: // // typeof(Foo<>).GetTypeInfo().DeclaredMembers // // The definingType and contextType are both Foo<> // // typeof(Foo<int,String>).GetTypeInfo().DeclaredMembers // // The definingType is "Foo<,>" // The contextType is "Foo<int,String>" // // We don't report any DeclaredMembers for arrays or generic parameters so those don't apply. // private RuntimeNamedMethodInfo(MethodHandle methodHandle, RuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo) : base() { _common = new RuntimeMethodCommon(methodHandle, definingTypeInfo, contextTypeInfo); }
public override sealed MethodInfo MakeGenericMethod(params Type[] typeArguments) { #if ENABLE_REFLECTION_TRACE if (ReflectionTrace.Enabled) ReflectionTrace.MethodInfo_MakeGenericMethod(this, typeArguments); #endif if (typeArguments == null) throw new ArgumentNullException(nameof(typeArguments)); if (GenericTypeParameters.Length == 0) throw new InvalidOperationException(SR.Format(SR.Arg_NotGenericMethodDefinition, this)); RuntimeTypeInfo[] genericTypeArguments = new RuntimeTypeInfo[typeArguments.Length]; for (int i = 0; i < typeArguments.Length; i++) { if (typeArguments[i] == null) throw new ArgumentNullException(); if (!typeArguments[i].IsRuntimeImplemented()) throw new ArgumentException(SR.Format(SR.Reflection_CustomReflectionObjectsNotSupported, typeArguments[i]), "typeArguments[" + i + "]"); // Not a runtime type. genericTypeArguments[i] = typeArguments[i].CastToRuntimeTypeInfo(); } if (typeArguments.Length != GenericTypeParameters.Length) throw new ArgumentException(SR.Format(SR.Argument_NotEnoughGenArguments, typeArguments.Length, GenericTypeParameters.Length)); RuntimeMethodInfo methodInfo = (RuntimeMethodInfo)RuntimeConstructedGenericMethodInfo.GetRuntimeConstructedGenericMethodInfo(this, genericTypeArguments); MethodInvoker methodInvoker = methodInfo.MethodInvoker; // For compatibility with other Make* apis, trigger any MissingMetadataExceptions now rather than later. return methodInfo; }
// // propertyHandle - the "tkPropertyDef" that identifies the property. // definingType - the "tkTypeDef" that defined the field (this is where you get the metadata reader that created propertyHandle.) // contextType - the type that supplies the type context (i.e. substitutions for generic parameters.) Though you // get your raw information from "definingType", you report "contextType" as your DeclaringType property. // // For example: // // typeof(Foo<>).GetTypeInfo().DeclaredMembers // // The definingType and contextType are both Foo<> // // typeof(Foo<int,String>).GetTypeInfo().DeclaredMembers // // The definingType is "Foo<,>" // The contextType is "Foo<int,String>" // // We don't report any DeclaredMembers for arrays or generic parameters so those don't apply. // protected RuntimePropertyInfo(RuntimeTypeInfo contextTypeInfo, RuntimeTypeInfo reflectedType) { ContextTypeInfo = contextTypeInfo; _reflectedType = reflectedType; }
private static String NonQualifiedTypeName(this Type type) { if (!type.IsRuntimeImplemented()) { return(null); } RuntimeTypeInfo runtimeType = type.CastToRuntimeTypeInfo(); if (runtimeType.HasElementType) { String elementTypeName = runtimeType.InternalRuntimeElementType.NonQualifiedTypeName(); if (elementTypeName == null) { return(null); } String suffix; if (runtimeType.IsArray) { int rank = runtimeType.GetArrayRank(); if (rank == 1) { suffix = "[" + (runtimeType.IsMultiDimensionalArray ? "*" : "") + "]"; } else { suffix = "[" + new String(',', rank - 1) + "]"; } } else if (runtimeType.IsByRef) { suffix = "&"; } else if (runtimeType.IsPointer) { suffix = "*"; } else { return(null); } return(elementTypeName + suffix); } else if (runtimeType.IsGenericParameter) { return(null); } else if (runtimeType.IsConstructedGenericType) { StringBuilder sb = new StringBuilder(); String genericTypeDefinitionTypeName = runtimeType.GetGenericTypeDefinition().NonQualifiedTypeName(); if (genericTypeDefinitionTypeName == null) { return(null); } sb.Append(genericTypeDefinitionTypeName); sb.Append("["); String sep = ""; foreach (RuntimeTypeInfo ga in runtimeType.InternalRuntimeGenericTypeArguments) { String gaTypeName = ga.AssemblyQualifiedTypeName(); if (gaTypeName == null) { return(null); } sb.Append(sep + "[" + gaTypeName + "]"); sep = ","; } sb.Append("]"); return(sb.ToString()); } else { RuntimeNamedTypeInfo runtimeNamedTypeInfo = type.GetTypeInfo() as RuntimeNamedTypeInfo; if (runtimeNamedTypeInfo == null) { return(null); } return(runtimeNamedTypeInfo.TraceableTypeName); } }
internal static RuntimeFieldInfo GetRuntimeFieldInfo(FieldDefinitionHandle fieldHandle, EcmaFormatRuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo, RuntimeTypeInfo reflectedType) { return(new EcmaFormatRuntimeFieldInfo(fieldHandle, definingTypeInfo, contextTypeInfo, reflectedType).WithDebugName()); }
internal static RuntimeMethodInfo GetRuntimeSyntheticMethodInfo(SyntheticMethodId syntheticMethodId, String name, RuntimeTypeInfo declaringType, RuntimeTypeInfo[] runtimeParameterTypes, RuntimeTypeInfo returnType, InvokerOptions options, Func <Object, Object[], Object> invoker) { return(new RuntimeSyntheticMethodInfo(syntheticMethodId, name, declaringType, runtimeParameterTypes, returnType, options, invoker).WithDebugName()); }
private RuntimeConstructedGenericMethodInfo(RuntimeNamedMethodInfo genericMethodDefinition, RuntimeTypeInfo[] genericTypeArguments) { _genericMethodDefinition = genericMethodDefinition; _genericTypeArguments = genericTypeArguments; }
internal static RuntimeNamedMethodInfo <TRuntimeMethodCommon> GetRuntimeNamedMethodInfo(TRuntimeMethodCommon common, RuntimeTypeInfo reflectedType) { RuntimeNamedMethodInfo <TRuntimeMethodCommon> method = new RuntimeNamedMethodInfo <TRuntimeMethodCommon>(common, reflectedType); method.WithDebugName(); return(method); }
public static RuntimeTypeInfo GetMultiDimArrayType(this RuntimeTypeInfo elementType, int rank) { return(elementType.GetMultiDimArrayType(rank, default(RuntimeTypeHandle))); }
internal static RuntimeMethodInfo GetRuntimeSyntheticMethodInfo(SyntheticMethodId syntheticMethodId, String name, RuntimeArrayTypeInfo declaringType, RuntimeTypeInfo[] runtimeParameterTypes, RuntimeTypeInfo returnType, InvokerOptions options, CustomMethodInvokerAction action) { return(new RuntimeSyntheticMethodInfo(syntheticMethodId, name, declaringType, runtimeParameterTypes, returnType, options, action).WithDebugName()); }
public static RuntimeTypeInfo GetConstructedGenericType(this RuntimeTypeInfo genericTypeDefinition, RuntimeTypeInfo[] genericTypeArguments) { return(genericTypeDefinition.GetConstructedGenericType(genericTypeArguments, default(RuntimeTypeHandle))); }
internal static RuntimeSyntheticParameterInfo GetRuntimeSyntheticParameterInfo(MemberInfo member, int position, RuntimeTypeInfo parameterType) { return(new RuntimeSyntheticParameterInfo(member, position, parameterType)); }
public static RuntimeTypeInfo GetMultiDimArrayType(this RuntimeTypeInfo elementType, int rank, RuntimeTypeHandle precomputedTypeHandle) { return(RuntimeArrayTypeInfo.GetArrayTypeInfo(elementType, multiDim: true, rank: rank, precomputedTypeHandle: precomputedTypeHandle)); }
// // methodHandle - the "tkMethodDef" that identifies the method. // definingType - the "tkTypeDef" that defined the method (this is where you get the metadata reader that created methodHandle.) // contextType - the type that supplies the type context (i.e. substitutions for generic parameters.) Though you // get your raw information from "definingType", you report "contextType" as your DeclaringType property. // // For example: // // typeof(Foo<>).GetTypeInfo().DeclaredMembers // // The definingType and contextType are both Foo<> // // typeof(Foo<int,String>).GetTypeInfo().DeclaredMembers // // The definingType is "Foo<,>" // The contextType is "Foo<int,String>" // // We don't report any DeclaredMembers for arrays or generic parameters so those don't apply. // public EcmaFormatMethodCommon(MethodDefinitionHandle methodHandle, EcmaFormatRuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo) { _definingTypeInfo = definingTypeInfo; _methodHandle = methodHandle; _contextTypeInfo = contextTypeInfo; _reader = definingTypeInfo.Reader; _method = _reader.GetMethodDefinition(methodHandle); }
// // Filter by name and visibility from the ReflectedType. // public static QueriedMemberList <M> Create(RuntimeTypeInfo type, string optionalNameFilter, bool ignoreCase) { RuntimeTypeInfo reflectedType = type; MemberPolicies <M> policies = MemberPolicies <M> .Default; NameFilter nameFilter; if (optionalNameFilter == null) { nameFilter = null; } else if (ignoreCase) { nameFilter = new NameFilterCaseInsensitive(optionalNameFilter); } else { nameFilter = new NameFilterCaseSensitive(optionalNameFilter); } bool inBaseClass = false; QueriedMemberList <M> queriedMembers = new QueriedMemberList <M>(); while (type != null) { int numCandidatesInDerivedTypes = queriedMembers._totalCount; foreach (M member in policies.CoreGetDeclaredMembers(type, nameFilter, reflectedType)) { MethodAttributes visibility; bool isStatic; bool isVirtual; bool isNewSlot; policies.GetMemberAttributes(member, out visibility, out isStatic, out isVirtual, out isNewSlot); if (inBaseClass && visibility == MethodAttributes.Private) { continue; } if (numCandidatesInDerivedTypes != 0 && policies.IsSuppressedByMoreDerivedMember(member, queriedMembers._members, startIndex: 0, endIndex: numCandidatesInDerivedTypes)) { continue; } BindingFlags allFlagsThatMustMatch = default(BindingFlags); allFlagsThatMustMatch |= (isStatic ? BindingFlags.Static : BindingFlags.Instance); if (isStatic && inBaseClass) { allFlagsThatMustMatch |= BindingFlags.FlattenHierarchy; } allFlagsThatMustMatch |= ((visibility == MethodAttributes.Public) ? BindingFlags.Public : BindingFlags.NonPublic); queriedMembers.Add(member, allFlagsThatMustMatch); } if (!inBaseClass) { queriedMembers._declaredOnlyCount = queriedMembers._totalCount; if (policies.AlwaysTreatAsDeclaredOnly) { break; } inBaseClass = true; } type = type.BaseType.CastToRuntimeTypeInfo(); if (type != null && !type.CanBrowseWithoutMissingMetadataExceptions) { // If we got here, one of the base classes is missing metadata. We don't want to throw a MissingMetadataException now because we may be // building a cached result for a caller who passed BindingFlags.DeclaredOnly. So we'll mark the results in a way that // it will throw a MissingMetadataException if a caller attempts to iterate past the declared-only subset. queriedMembers._typeThatBlockedBrowsing = type; queriedMembers._totalCount = queriedMembers._declaredOnlyCount; break; } } return(queriedMembers); }
private RuntimeSyntheticMethodInfo(SyntheticMethodId syntheticMethodId, String name, RuntimeTypeInfo declaringType, RuntimeTypeInfo[] parameterTypes, RuntimeTypeInfo returnType, InvokerOptions options, Func <Object, Object[], Object> invoker) { _syntheticMethodId = syntheticMethodId; _name = name; _declaringType = declaringType; _options = options; _invoker = invoker; _runtimeParameterTypes = parameterTypes; _returnType = returnType; }
// // methodHandle - the "tkMethodDef" that identifies the method. // definingType - the "tkTypeDef" that defined the method (this is where you get the metadata reader that created methodHandle.) // contextType - the type that supplies the type context (i.e. substitutions for generic parameters.) Though you // get your raw information from "definingType", you report "contextType" as your DeclaringType property. // // For example: // // typeof(Foo<>).GetTypeInfo().DeclaredMembers // // The definingType and contextType are both Foo<> // // typeof(Foo<int,String>).GetTypeInfo().DeclaredMembers // // The definingType is "Foo<,>" // The contextType is "Foo<int,String>" // // We don't report any DeclaredMembers for arrays or generic parameters so those don't apply. // private RuntimePlainConstructorInfo(MethodHandle methodHandle, RuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo) { _common = new RuntimeMethodCommon(methodHandle, definingTypeInfo, contextTypeInfo); }
//============================================================================================== // Non-public methods //============================================================================================== internal MethodInvoker GetMethodInvoker(MetadataReader reader, RuntimeTypeInfo declaringType, MethodHandle methodHandle, RuntimeTypeInfo[] genericMethodTypeArguments, MemberInfo exceptionPertainant) { if (declaringType.ContainsGenericParameters) return new OpenMethodInvoker(); for (int i = 0; i < genericMethodTypeArguments.Length; i++) { if (genericMethodTypeArguments[i].ContainsGenericParameters) return new OpenMethodInvoker(); } RuntimeTypeHandle typeDefinitionHandle = declaringType.TypeHandle; RuntimeTypeHandle[] genericMethodTypeArgumentHandles = new RuntimeTypeHandle[genericMethodTypeArguments.Length]; for (int i = 0; i < genericMethodTypeArguments.Length; i++) { genericMethodTypeArgumentHandles[i] = genericMethodTypeArguments[i].TypeHandle; } MethodInvoker methodInvoker = TryGetMethodInvoker(reader, typeDefinitionHandle, methodHandle, genericMethodTypeArgumentHandles); if (methodInvoker == null) throw ReflectionCoreExecution.ExecutionDomain.CreateNonInvokabilityException(exceptionPertainant); return methodInvoker; }
// // contextType - the type that supplies the type context (i.e. substitutions for generic parameters.) Though you // get your raw information from "definingType", you report "contextType" as your DeclaringType property. // // For example: // // typeof(Foo<>).GetTypeInfo().DeclaredMembers // // The definingType and contextType are both Foo<> // // typeof(Foo<int,String>).GetTypeInfo().DeclaredMembers // // The definingType is "Foo<,>" // The contextType is "Foo<int,String>" // // We don't report any DeclaredMembers for arrays or generic parameters so those don't apply. // protected RuntimeFieldInfo(RuntimeTypeInfo contextTypeInfo, RuntimeTypeInfo reflectedType) { _contextTypeInfo = contextTypeInfo; _reflectedType = reflectedType; }
/// <summary> /// Common CreateDelegate worker. NOTE: If the method signature is not compatible, this method returns null rather than throwing an ArgumentException. /// This is needed to support the api overloads that have a "throwOnBindFailure" parameter. /// </summary> internal Delegate CreateDelegateNoThrowOnBindFailure(RuntimeTypeInfo runtimeDelegateType, object target, bool allowClosed) { Debug.Assert(runtimeDelegateType.IsDelegate); ExecutionEnvironment executionEnvironment = ReflectionCoreExecution.ExecutionEnvironment; MethodInfo invokeMethod = runtimeDelegateType.GetInvokeMethod(); // Make sure the return type is assignment-compatible. Type expectedReturnType = ReturnParameter.ParameterType; Type actualReturnType = invokeMethod.ReturnParameter.ParameterType; if (!IsAssignableFrom(executionEnvironment, actualReturnType, expectedReturnType)) { return(null); } if (expectedReturnType.IsValueType && !actualReturnType.IsValueType) { // For value type returning methods, conversions between enums and primitives are allowed (and screened by the above call to IsAssignableFrom) // but conversions to Object or interfaces implemented by the value type are not. return(null); } IList <ParameterInfo> delegateParameters = invokeMethod.GetParametersNoCopy(); IList <ParameterInfo> targetParameters = this.GetParametersNoCopy(); IEnumerator <ParameterInfo> delegateParameterEnumerator = delegateParameters.GetEnumerator(); IEnumerator <ParameterInfo> targetParameterEnumerator = targetParameters.GetEnumerator(); bool isStatic = this.IsStatic; bool isOpen; if (isStatic) { if (delegateParameters.Count == targetParameters.Count) { // Open static: This is the "typical" case of calling a static method. isOpen = true; if (target != null) { return(null); } } else { // Closed static: This is the "weird" v2.0 case where the delegate is closed over the target method's first parameter. // (it make some kinda sense if you think of extension methods.) if (!allowClosed) { return(null); } isOpen = false; if (!targetParameterEnumerator.MoveNext()) { return(null); } if (target != null && !IsAssignableFrom(executionEnvironment, targetParameterEnumerator.Current.ParameterType, target.GetType())) { return(null); } } } else { if (delegateParameters.Count == targetParameters.Count) { // Closed instance: This is the "typical" case of invoking an instance method. isOpen = false; if (!allowClosed) { return(null); } if (target != null && !IsAssignableFrom(executionEnvironment, this.DeclaringType, target.GetType())) { return(null); } } else { // Open instance: This is the "weird" v2.0 case where the delegate has a leading extra parameter that's assignable to the target method's // declaring type. if (!delegateParameterEnumerator.MoveNext()) { return(null); } isOpen = true; Type firstParameterOfMethodType = this.DeclaringType; if (firstParameterOfMethodType.IsValueType) { firstParameterOfMethodType = firstParameterOfMethodType.MakeByRefType(); } if (!IsAssignableFrom(executionEnvironment, firstParameterOfMethodType, delegateParameterEnumerator.Current.ParameterType)) { return(null); } if (target != null) { return(null); } } } // Verify that the parameters that the delegate and method have in common are assignment-compatible. while (delegateParameterEnumerator.MoveNext()) { if (!targetParameterEnumerator.MoveNext()) { return(null); } if (!IsAssignableFrom(executionEnvironment, targetParameterEnumerator.Current.ParameterType, delegateParameterEnumerator.Current.ParameterType)) { return(null); } } if (targetParameterEnumerator.MoveNext()) { return(null); } return(CreateDelegateWithoutSignatureValidation(runtimeDelegateType, target, isStatic: isStatic, isOpen: isOpen)); }
public sealed override Exception TryResolve(RuntimeAssembly currentAssembly, bool ignoreCase, out RuntimeTypeInfo result) { result = null; RuntimeTypeInfo genericType; Exception typeLoadException = GenericType.TryResolve(currentAssembly, ignoreCase, out genericType); if (typeLoadException != null) return typeLoadException; LowLevelList<RuntimeTypeInfo> genericTypeArguments = new LowLevelList<RuntimeTypeInfo>(); foreach (TypeName genericTypeArgumentName in GenericArguments) { RuntimeTypeInfo genericTypeArgument; typeLoadException = genericTypeArgumentName.TryResolve(currentAssembly, ignoreCase, out genericTypeArgument); if (typeLoadException != null) return typeLoadException; genericTypeArguments.Add(genericTypeArgument); } result = genericType.GetConstructedGenericType(genericTypeArguments.ToArray()); return null; }
internal static RuntimePropertyInfo GetRuntimePropertyInfo(PropertyDefinitionHandle propertyHandle, EcmaFormatRuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo, RuntimeTypeInfo reflectedType) { return(new EcmaFormatRuntimePropertyInfo(propertyHandle, definingTypeInfo, contextTypeInfo, reflectedType).WithDebugName()); }
public sealed override Exception TryResolve(RuntimeAssembly currentAssembly, bool ignoreCase, out RuntimeTypeInfo result) { result = null; RuntimeTypeInfo elementType; Exception typeLoadException = ElementTypeName.TryResolve(currentAssembly, ignoreCase, out elementType); if (typeLoadException != null) return typeLoadException; result = elementType.GetPointerType(); return null; }
public static RuntimeTypeInfo GetConstructedGenericType(this RuntimeTypeInfo genericTypeDefinition, RuntimeTypeInfo[] genericTypeArguments, RuntimeTypeHandle precomputedTypeHandle) { return(RuntimeConstructedGenericTypeInfo.GetRuntimeConstructedGenericTypeInfo(genericTypeDefinition, genericTypeArguments, precomputedTypeHandle)); }
private RuntimeGenericParameterTypeInfoForTypes(MetadataReader reader, GenericParameterHandle genericParameterHandle, RuntimeTypeInfo declaringRuntimeNamedTypeInfo) : base(reader, genericParameterHandle) { _declaringRuntimeNamedTypeInfo = declaringRuntimeNamedTypeInfo; }
public static RuntimeTypeInfo GetArrayType(this RuntimeTypeInfo elementType) { return(elementType.GetArrayType(default(RuntimeTypeHandle))); }
private NativeFormatRuntimeGenericParameterTypeInfoForTypes(MetadataReader reader, GenericParameterHandle genericParameterHandle, RuntimeTypeInfo declaringRuntimeNamedTypeInfo) : base(reader, genericParameterHandle, genericParameterHandle.GetGenericParameter(reader)) { _declaringRuntimeNamedTypeInfo = declaringRuntimeNamedTypeInfo; }
// // Helper for the V1/V1.1 Delegate.CreateDelegate() api. These apis take method names rather than MethodInfo and only expect to create open static delegates // or closed instance delegates. For backward compatibility, they don't allow relaxed signature matching (which could make the choice of target method ambiguous.) // private static RuntimeMethodInfo LookupMethodForCreateDelegate(RuntimeTypeInfo runtimeDelegateType, RuntimeTypeInfo containingType, string method, bool isStatic, bool ignoreCase) { Debug.Assert(runtimeDelegateType.IsDelegate); BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.ExactBinding; if (isStatic) { bindingFlags |= BindingFlags.Static | BindingFlags.FlattenHierarchy; } else { bindingFlags |= BindingFlags.Instance; } if (ignoreCase) { bindingFlags |= BindingFlags.IgnoreCase; } RuntimeMethodInfo invokeMethod = runtimeDelegateType.GetInvokeMethod(); ParameterInfo[] parameters = invokeMethod.GetParametersNoCopy(); int numParameters = parameters.Length; Type[] parameterTypes = new Type[numParameters]; for (int i = 0; i < numParameters; i++) { parameterTypes[i] = parameters[i].ParameterType; } MethodInfo methodInfo = containingType.GetMethod(method, bindingFlags, null, parameterTypes, null); if (methodInfo == null) { return(null); } if (!methodInfo.ReturnType.Equals(invokeMethod.ReturnType)) { return(null); } return((RuntimeMethodInfo)methodInfo); // This cast is safe since we already verified that containingType is runtime implemented. }
// // Helper for the V1/V1.1 Delegate.CreateDelegate() api. These apis take method names rather than MethodInfo and only expect to create open static delegates // or closed instance delegates. For backward compatibility, they don't allow relaxed signature matching (which could make the choice of target method ambiguous.) // private static RuntimeMethodInfo LookupMethodForCreateDelegate(RuntimeTypeInfo runtimeDelegateType, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] RuntimeTypeInfo containingType, string method, bool isStatic, bool ignoreCase) { Debug.Assert(runtimeDelegateType.IsDelegate); BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.ExactBinding; if (isStatic) { bindingFlags |= BindingFlags.Static; } else { bindingFlags |= BindingFlags.Instance | BindingFlags.DeclaredOnly; } if (ignoreCase) { bindingFlags |= BindingFlags.IgnoreCase; } RuntimeMethodInfo invokeMethod = runtimeDelegateType.GetInvokeMethod(); ParameterInfo[] parameters = invokeMethod.GetParametersNoCopy(); int numParameters = parameters.Length; Type[] parameterTypes = new Type[numParameters]; for (int i = 0; i < numParameters; i++) { parameterTypes[i] = parameters[i].ParameterType; } while (containingType != null) { MethodInfo?methodInfo = containingType.GetMethod(method, 0, bindingFlags, null, parameterTypes, null); if (methodInfo != null && methodInfo.ReturnType.Equals(invokeMethod.ReturnType)) { return((RuntimeMethodInfo)methodInfo); // This cast is safe since we already verified that containingType is runtime implemented. } #pragma warning disable IL2072 // https://github.com/dotnet/linker/issues/2673 containingType = (RuntimeTypeInfo)(containingType.BaseType); #pragma warning restore } return(null); }
internal abstract MethodInvoker GetUncachedMethodInvoker(RuntimeTypeInfo[] methodArguments, MemberInfo exceptionPertainant);
// // fieldHandle - the "tkFieldDef" that identifies the field. // definingType - the "tkTypeDef" that defined the field (this is where you get the metadata reader that created fieldHandle.) // contextType - the type that supplies the type context (i.e. substitutions for generic parameters.) Though you // get your raw information from "definingType", you report "contextType" as your DeclaringType property. // // For example: // // typeof(Foo<>).GetTypeInfo().DeclaredMembers // // The definingType and contextType are both Foo<> // // typeof(Foo<int,String>).GetTypeInfo().DeclaredMembers // // The definingType is "Foo<,>" // The contextType is "Foo<int,String>" // // We don't report any DeclaredMembers for arrays or generic parameters so those don't apply. // private RuntimeFieldInfo(FieldHandle fieldHandle, RuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo, RuntimeTypeInfo reflectedType) { _fieldHandle = fieldHandle; _definingTypeInfo = definingTypeInfo; _contextTypeInfo = contextTypeInfo; _reflectedType = reflectedType; _reader = definingTypeInfo.Reader; _field = fieldHandle.GetField(_reader); }