internal override bool CacheEquals(object?o) { return (o is RuntimeEventInfo m && m.m_token == m_token && RuntimeTypeHandle.GetModule(m_declaringType).Equals( RuntimeTypeHandle.GetModule(m.m_declaringType))); }
internal override bool CacheEquals(object o) { RuntimePropertyInfo runtimePropertyInfo = o as RuntimePropertyInfo; if (runtimePropertyInfo == null || runtimePropertyInfo.m_token != this.m_token) { return(false); } return(RuntimeTypeHandle.GetModule(this.m_declaringType).Equals((object)RuntimeTypeHandle.GetModule(runtimePropertyInfo.m_declaringType))); }
internal override bool CacheEquals(object o) { RuntimePropertyInfo info = o as RuntimePropertyInfo; if (info == null) { return(false); } return((info.m_token == this.m_token) && RuntimeTypeHandle.GetModule(this.m_declaringType).Equals(RuntimeTypeHandle.GetModule(info.m_declaringType))); }
internal override bool CacheEquals(object o) { RuntimePropertyInfo m = o as RuntimePropertyInfo; if ((object)m == null) { return(false); } return(m.m_token == m_token && RuntimeTypeHandle.GetModule(m_declaringType).Equals( RuntimeTypeHandle.GetModule(m.m_declaringType))); }
internal override bool CacheEquals(object?o) { RuntimeEventInfo?m = o as RuntimeEventInfo; if (m is null) { return(false); } return(m.m_token == m_token && RuntimeTypeHandle.GetModule(m_declaringType).Equals( RuntimeTypeHandle.GetModule(m.m_declaringType))); }
private static RuntimeMethodInfo?AssignAssociates( int tkMethod, RuntimeType declaredType, RuntimeType reflectedType) { if (MetadataToken.IsNullToken(tkMethod)) { return(null); } Debug.Assert(declaredType != null); Debug.Assert(reflectedType != null); bool isInherited = declaredType != reflectedType; Span <IntPtr> genericArgumentHandles = stackalloc IntPtr[0]; RuntimeType[] genericArguments = declaredType.TypeHandle.GetInstantiationInternal(); if (genericArguments != null) { genericArgumentHandles = genericArguments.Length <= 16 ? // arbitrary stackalloc limit stackalloc IntPtr[genericArguments.Length] : new IntPtr[genericArguments.Length]; for (int i = 0; i < genericArguments.Length; i++) { genericArgumentHandles[i] = genericArguments[i].TypeHandle.Value; } } RuntimeMethodHandleInternal associateMethodHandle = ModuleHandle.ResolveMethodHandleInternal(RuntimeTypeHandle.GetModule(declaredType), tkMethod, genericArgumentHandles, default); Debug.Assert(!associateMethodHandle.IsNullHandle(), "Failed to resolve associateRecord methodDef token"); if (isInherited) { MethodAttributes methAttr = RuntimeMethodHandle.GetAttributes(associateMethodHandle); // ECMA MethodSemantics: "All methods for a given Property or Event shall have the same accessibility // (ie the MemberAccessMask subfield of their Flags row) and cannot be CompilerControlled [CLS]" // Consequently, a property may be composed of public and private methods. If the declared type != // the reflected type, the private methods should not be exposed. Note that this implies that the // identity of a property includes it's reflected type. if ((methAttr & MethodAttributes.MemberAccessMask) == MethodAttributes.Private) { return(null); } // Note this is the first time the property was encountered walking from the most derived class // towards the base class. It would seem to follow that any associated methods would not // be overriden -- but this is not necessarily true. A more derived class may have overriden a // virtual method associated with a property in a base class without associating the override with // the same or any property in the derived class. if ((methAttr & MethodAttributes.Virtual) != 0) { bool declaringTypeIsClass = (RuntimeTypeHandle.GetAttributes(declaredType) & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Class; // It makes no sense to search for a virtual override of a method declared on an interface. if (declaringTypeIsClass) { int slot = RuntimeMethodHandle.GetSlot(associateMethodHandle); // Find the override visible from the reflected type associateMethodHandle = RuntimeTypeHandle.GetMethodAt(reflectedType, slot); } } } RuntimeMethodInfo?associateMethod = RuntimeType.GetMethodBase(reflectedType, associateMethodHandle) as RuntimeMethodInfo; // suppose a property was mapped to a method not in the derivation hierarchy of the reflectedTypeHandle return(associateMethod ?? reflectedType.Module.ResolveMethod(tkMethod, null, null) as RuntimeMethodInfo); }
internal RuntimeModule GetRuntimeModule() { return(RuntimeTypeHandle.GetModule(m_declaringType)); }
[System.Security.SecuritySafeCritical] // auto-generated internal override RuntimeModule GetRuntimeModule() { return(RuntimeTypeHandle.GetModule(RuntimeFieldHandle.GetApproxDeclaringType(this))); }
[System.Security.SecurityCritical] // auto-generated private static unsafe RuntimeMethodInfo AssignAssociates( int tkMethod, RuntimeType declaredType, RuntimeType reflectedType) { if (MetadataToken.IsNullToken(tkMethod)) { return(null); } Contract.Assert(declaredType != null); Contract.Assert(reflectedType != null); bool isInherited = declaredType != reflectedType; IntPtr[] genericArgumentHandles = null; int genericArgumentCount = 0; RuntimeType [] genericArguments = declaredType.GetTypeHandleInternal().GetInstantiationInternal(); if (genericArguments != null) { genericArgumentCount = genericArguments.Length; genericArgumentHandles = new IntPtr[genericArguments.Length]; for (int i = 0; i < genericArguments.Length; i++) { genericArgumentHandles[i] = genericArguments[i].GetTypeHandleInternal().Value; } } RuntimeMethodHandleInternal associateMethodHandle = ModuleHandle.ResolveMethodHandleInternalCore(RuntimeTypeHandle.GetModule(declaredType), tkMethod, genericArgumentHandles, genericArgumentCount, null, 0); Contract.Assert(!associateMethodHandle.IsNullHandle(), "Failed to resolve associateRecord methodDef token"); if (isInherited) { MethodAttributes methAttr = RuntimeMethodHandle.GetAttributes(associateMethodHandle); // ECMA MethodSemantics: "All methods for a given Property or Event shall have the same accessibility //(ie the MemberAccessMask subfield of their Flags row) and cannot be CompilerControlled [CLS]" // Consequently, a property may be composed of public and private methods. If the declared type != // the reflected type, the private methods should not be exposed. Note that this implies that the // identity of a property includes it's reflected type. // NetCF actually includes private methods from parent classes in Reflection results // We will mimic that in Mango Compat mode. if (!CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) { if ((methAttr & MethodAttributes.MemberAccessMask) == MethodAttributes.Private) { return(null); } } // Note this is the first time the property was encountered walking from the most derived class // towards the base class. It would seem to follow that any associated methods would not // be overriden -- but this is not necessarily true. A more derived class may have overriden a // virtual method associated with a property in a base class without associating the override with // the same or any property in the derived class. if ((methAttr & MethodAttributes.Virtual) != 0) { bool declaringTypeIsClass = (RuntimeTypeHandle.GetAttributes(declaredType) & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Class; // It makes no sense to search for a virtual override of a method declared on an interface. if (declaringTypeIsClass) { int slot = RuntimeMethodHandle.GetSlot(associateMethodHandle); // Find the override visible from the reflected type associateMethodHandle = RuntimeTypeHandle.GetMethodAt(reflectedType, slot); } } } RuntimeMethodInfo associateMethod = RuntimeType.GetMethodBase(reflectedType, associateMethodHandle) as RuntimeMethodInfo; // suppose a property was mapped to a method not in the derivation hierarchy of the reflectedTypeHandle if (associateMethod == null) { associateMethod = reflectedType.Module.ResolveMethod(tkMethod, null, null) as RuntimeMethodInfo; } return(associateMethod); }
private static RuntimeMethodInfo AssignAssociates(int tkMethod, RuntimeType declaredType, RuntimeType reflectedType) { if (MetadataToken.IsNullToken(tkMethod)) { return(null); } bool flag = declaredType != reflectedType; IntPtr[] array = null; int typeInstCount = 0; RuntimeType[] instantiationInternal = declaredType.GetTypeHandleInternal().GetInstantiationInternal(); if (instantiationInternal != null) { typeInstCount = instantiationInternal.Length; array = new IntPtr[instantiationInternal.Length]; for (int i = 0; i < instantiationInternal.Length; i++) { array[i] = instantiationInternal[i].GetTypeHandleInternal().Value; } } RuntimeMethodHandleInternal runtimeMethodHandleInternal = ModuleHandle.ResolveMethodHandleInternalCore(RuntimeTypeHandle.GetModule(declaredType), tkMethod, array, typeInstCount, null, 0); if (flag) { MethodAttributes attributes = RuntimeMethodHandle.GetAttributes(runtimeMethodHandleInternal); if (!CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && (attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private) { return(null); } if ((attributes & MethodAttributes.Virtual) != MethodAttributes.PrivateScope) { bool flag2 = (RuntimeTypeHandle.GetAttributes(declaredType) & TypeAttributes.ClassSemanticsMask) == TypeAttributes.NotPublic; if (flag2) { int slot = RuntimeMethodHandle.GetSlot(runtimeMethodHandleInternal); runtimeMethodHandleInternal = RuntimeTypeHandle.GetMethodAt(reflectedType, slot); } } } RuntimeMethodInfo runtimeMethodInfo = RuntimeType.GetMethodBase(reflectedType, runtimeMethodHandleInternal) as RuntimeMethodInfo; if (runtimeMethodInfo == null) { runtimeMethodInfo = (reflectedType.Module.ResolveMethod(tkMethod, null, null) as RuntimeMethodInfo); } return(runtimeMethodInfo); }
private static RuntimeMethodInfo AssignAssociates(int tkMethod, RuntimeType declaredType, RuntimeType reflectedType) { if (MetadataToken.IsNullToken(tkMethod)) { return(null); } bool flag = declaredType != reflectedType; IntPtr[] typeInstantiationContext = null; int typeInstCount = 0; RuntimeType[] instantiationInternal = declaredType.GetTypeHandleInternal().GetInstantiationInternal(); if (instantiationInternal != null) { typeInstCount = instantiationInternal.Length; typeInstantiationContext = new IntPtr[instantiationInternal.Length]; for (int i = 0; i < instantiationInternal.Length; i++) { typeInstantiationContext[i] = instantiationInternal[i].GetTypeHandleInternal().Value; } } RuntimeMethodHandleInternal method = ModuleHandle.ResolveMethodHandleInternalCore(RuntimeTypeHandle.GetModule(declaredType), tkMethod, typeInstantiationContext, typeInstCount, null, 0); if (flag) { MethodAttributes attributes = RuntimeMethodHandle.GetAttributes(method); if ((attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private) { return(null); } if (((attributes & MethodAttributes.Virtual) != MethodAttributes.PrivateScope) && ((RuntimeTypeHandle.GetAttributes(declaredType) & TypeAttributes.ClassSemanticsMask) == TypeAttributes.AnsiClass)) { int slot = RuntimeMethodHandle.GetSlot(method); method = RuntimeTypeHandle.GetMethodAt(reflectedType, slot); } } RuntimeMethodInfo methodBase = RuntimeType.GetMethodBase(reflectedType, method) as RuntimeMethodInfo; if (methodBase == null) { methodBase = reflectedType.Module.ResolveMethod(tkMethod, null, null) as RuntimeMethodInfo; } return(methodBase); }
internal override bool CacheEquals(object o) { RuntimeEventInfo runtimeEventInfo = o as RuntimeEventInfo; return(runtimeEventInfo != null && runtimeEventInfo.m_token == this.m_token && RuntimeTypeHandle.GetModule(this.m_declaringType).Equals(RuntimeTypeHandle.GetModule(runtimeEventInfo.m_declaringType))); }
private static RuntimeMethodInfo AssignAssociates(int tkMethod, RuntimeType declaredType, RuntimeType reflectedType) { if (MetadataToken.IsNullToken(tkMethod)) { return((RuntimeMethodInfo)null); } bool flag = declaredType != reflectedType; IntPtr[] typeInstantiationContext = (IntPtr[])null; int typeInstCount = 0; RuntimeType[] instantiationInternal = declaredType.GetTypeHandleInternal().GetInstantiationInternal(); if (instantiationInternal != null) { typeInstCount = instantiationInternal.Length; typeInstantiationContext = new IntPtr[instantiationInternal.Length]; for (int index = 0; index < instantiationInternal.Length; ++index) { typeInstantiationContext[index] = instantiationInternal[index].GetTypeHandleInternal().Value; } } RuntimeMethodHandleInternal methodHandleInternal = ModuleHandle.ResolveMethodHandleInternalCore(RuntimeTypeHandle.GetModule(declaredType), tkMethod, typeInstantiationContext, typeInstCount, (IntPtr[])null, 0); if (flag) { MethodAttributes attributes = RuntimeMethodHandle.GetAttributes(methodHandleInternal); if (!CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && (attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private) { return((RuntimeMethodInfo)null); } if ((attributes & MethodAttributes.Virtual) != MethodAttributes.PrivateScope && (RuntimeTypeHandle.GetAttributes(declaredType) & TypeAttributes.ClassSemanticsMask) == TypeAttributes.NotPublic) { int slot = RuntimeMethodHandle.GetSlot(methodHandleInternal); methodHandleInternal = RuntimeTypeHandle.GetMethodAt(reflectedType, slot); } } RuntimeMethodInfo runtimeMethodInfo = RuntimeType.GetMethodBase(reflectedType, methodHandleInternal) as RuntimeMethodInfo; if ((MethodInfo)runtimeMethodInfo == (MethodInfo)null) { runtimeMethodInfo = reflectedType.Module.ResolveMethod(tkMethod, (Type[])null, (Type[])null) as RuntimeMethodInfo; } return(runtimeMethodInfo); }
internal RuntimeModule GetRuntimeModule() { return RuntimeTypeHandle.GetModule((RuntimeType)DeclaringType); }