internal static IRuntimeMethodInfo EnsureNonNullMethodInfo(IRuntimeMethodInfo method) { if (method == null) { throw new ArgumentNullException(null, Environment.GetResourceString("Arg_InvalidHandle")); } return method; }
public unsafe override MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) { MetadataToken metadataToken2 = new MetadataToken(metadataToken); if (!this.MetadataImport.IsValidToken(metadataToken2)) { throw new ArgumentOutOfRangeException("metadataToken", Environment.GetResourceString("Argument_InvalidToken", new object[] { metadataToken2, this })); } RuntimeTypeHandle[] typeInstantiationContext = RuntimeModule.ConvertToTypeHandleArray(genericTypeArguments); RuntimeTypeHandle[] methodInstantiationContext = RuntimeModule.ConvertToTypeHandleArray(genericMethodArguments); MethodBase methodBase; try { if (!metadataToken2.IsMethodDef && !metadataToken2.IsMethodSpec) { if (!metadataToken2.IsMemberRef) { throw new ArgumentException("metadataToken", Environment.GetResourceString("Argument_ResolveMethod", new object[] { metadataToken2, this })); } if (*(byte *)this.MetadataImport.GetMemberRefProps(metadataToken2).Signature.ToPointer() == 6) { throw new ArgumentException("metadataToken", Environment.GetResourceString("Argument_ResolveMethod", new object[] { metadataToken2, this })); } } IRuntimeMethodInfo runtimeMethodInfo = ModuleHandle.ResolveMethodHandleInternal(this.GetNativeHandle(), metadataToken2, typeInstantiationContext, methodInstantiationContext); Type type = RuntimeMethodHandle.GetDeclaringType(runtimeMethodInfo); if (type.IsGenericType || type.IsArray) { MetadataToken token = new MetadataToken(this.MetadataImport.GetParentToken(metadataToken2)); if (metadataToken2.IsMethodSpec) { token = new MetadataToken(this.MetadataImport.GetParentToken(token)); } type = this.ResolveType(token, genericTypeArguments, genericMethodArguments); } methodBase = RuntimeType.GetMethodBase(type as RuntimeType, runtimeMethodInfo); } catch (BadImageFormatException innerException) { throw new ArgumentException(Environment.GetResourceString("Argument_BadImageFormatExceptionResolve"), innerException); } return(methodBase); }
public override bool Equals(object obj) { if (!IsGenericMethod) { return(obj == (object)this); } // We cannot do simple object identity comparisons for generic methods. // Equals will be called in CerHashTable when RuntimeType+RuntimeTypeCache.GetGenericMethodInfo() // retrieve items from and insert items into s_methodInstantiations which is a CerHashtable. RuntimeMethodInfo mi = obj as RuntimeMethodInfo; if (mi == null || !mi.IsGenericMethod) { return(false); } // now we know that both operands are generic methods IRuntimeMethodInfo handle1 = RuntimeMethodHandle.StripMethodInstantiation(this); IRuntimeMethodInfo handle2 = RuntimeMethodHandle.StripMethodInstantiation(mi); if (handle1.Value.Value != handle2.Value.Value) { return(false); } Type[] lhs = GetGenericArguments(); Type[] rhs = mi.GetGenericArguments(); if (lhs.Length != rhs.Length) { return(false); } for (int i = 0; i < lhs.Length; i++) { if (lhs[i] != rhs[i]) { return(false); } } if (DeclaringType != mi.DeclaringType) { return(false); } if (ReflectedType != mi.ReflectedType) { return(false); } return(true); }
internal static ParameterInfo[] GetParameters( IRuntimeMethodInfo method, MemberInfo member, Signature sig ) { Debug.Assert(method is RuntimeMethodInfo || method is RuntimeConstructorInfo); return(GetParameters(method, member, sig, out _, fetchReturnParameter: false)); }
internal static INVOCATION_FLAGS GetSecurityFlags(IRuntimeMethodInfo handle) { INVOCATION_FLAGS specialSecurityFlags = (INVOCATION_FLAGS)GetSpecialSecurityFlags(handle); if ((((specialSecurityFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY) == INVOCATION_FLAGS.INVOCATION_FLAGS_UNKNOWN) && IsSecurityCritical(handle)) && !IsSecuritySafeCritical(handle)) { specialSecurityFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY; } return(specialSecurityFlags); }
internal static MethodBase InternalGetCurrentMethod(ref StackCrawlMark stackMark) { IRuntimeMethodInfo currentMethod = RuntimeMethodHandle.GetCurrentMethod(ref stackMark); if (currentMethod == null) { return(null); } return(RuntimeType.GetMethodBase(currentMethod)); }
private MethodBase GetExceptionMethodFromStackTrace() { IRuntimeMethodInfo methodFromStackTrace = Exception.GetMethodFromStackTrace(this._stackTrace); if (methodFromStackTrace == null) { return(null); } return(RuntimeType.GetMethodBase(methodFromStackTrace)); }
private MethodBase GetExceptionMethodFromStackTrace() { IRuntimeMethodInfo method = GetMethodFromStackTrace(_stackTrace); // Under certain race conditions when exceptions are re-used, this can be null if (method == null) return null; return RuntimeType.GetMethodBase(method); }
private static unsafe object CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, ref IntPtr blob, IntPtr blobEnd, out int namedArgs) { int num; byte * ppBlob = (byte *)blob; byte * pEndBlob = (byte *)blobEnd; object obj2 = _CreateCaObject(module, ctor, &ppBlob, pEndBlob, &num); blob = (IntPtr)ppBlob; namedArgs = num; return(obj2); }
protected virtual MethodInfo GetMethodImpl() { if ((_methodBase == null) || !(_methodBase is MethodInfo)) { IRuntimeMethodInfo method = FindMethodHandle(); RuntimeType? declaringType = RuntimeMethodHandle.GetDeclaringType(method); // need a proper declaring type instance method on a generic type if (RuntimeTypeHandle.IsGenericTypeDefinition(declaringType) || RuntimeTypeHandle.HasInstantiation(declaringType)) { bool isStatic = (RuntimeMethodHandle.GetAttributes(method) & MethodAttributes.Static) != (MethodAttributes)0; if (!isStatic) { if (_methodPtrAux == IntPtr.Zero) { // The target may be of a derived type that doesn't have visibility onto the // target method. We don't want to call RuntimeType.GetMethodBase below with that // or reflection can end up generating a MethodInfo where the ReflectedType cannot // see the MethodInfo itself and that breaks an important invariant. But the // target type could include important generic type information we need in order // to work out what the exact instantiation of the method's declaring type is. So // we'll walk up the inheritance chain (which will yield exactly instantiated // types at each step) until we find the declaring type. Since the declaring type // we get from the method is probably shared and those in the hierarchy we're // walking won't be we compare using the generic type definition forms instead. Type?currentType = _target !.GetType(); Type targetType = declaringType.GetGenericTypeDefinition(); while (currentType != null) { if (currentType.IsGenericType && currentType.GetGenericTypeDefinition() == targetType) { declaringType = currentType as RuntimeType; break; } currentType = currentType.BaseType; } // RCWs don't need to be "strongly-typed" in which case we don't find a base type // that matches the declaring type of the method. This is fine because interop needs // to work with exact methods anyway so declaringType is never shared at this point. Debug.Assert(currentType != null || _target.GetType().IsCOMObject, "The class hierarchy should declare the method"); } else { // it's an open one, need to fetch the first arg of the instantiation MethodInfo invoke = this.GetType().GetMethod("Invoke") !; declaringType = (RuntimeType)invoke.GetParameters()[0].ParameterType; } } } _methodBase = (MethodInfo)RuntimeType.GetMethodBase(declaringType, method) !; } return((MethodInfo)_methodBase); }
private unsafe static object CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, ref IntPtr blob, IntPtr blobEnd, out int namedArgs) { byte * value = (byte *)((void *)blob); byte * pEndBlob = (byte *)((void *)blobEnd); int num; object result = CustomAttribute._CreateCaObject(module, ctor, &value, pEndBlob, &num); blob = (IntPtr)((void *)value); namedArgs = num; return(result); }
public virtual MethodBase GetMethodBase(int i) { IntPtr methodHandleValue = this.rgMethodHandle[i]; if (methodHandleValue.IsNull()) { return(null); } IRuntimeMethodInfo typicalMethodDefinition = RuntimeMethodHandle.GetTypicalMethodDefinition(new RuntimeMethodInfoStub(methodHandleValue, this)); return(RuntimeType.GetMethodBase(typicalMethodDefinition)); }
private RuntimeMethodHandle(SerializationInfo info, StreamingContext context) { if (info == null) { throw new ArgumentNullException("info"); } this.m_value = ((MethodBase)info.GetValue("MethodObj", typeof(MethodBase))).MethodHandle.m_value; if (this.m_value == null) { throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState")); } }
private RuntimeMethodHandle(SerializationInfo info, StreamingContext context) { if (info == null) { throw new ArgumentNullException("info"); } MethodBase methodBase = (MethodBase)info.GetValue("MethodObj", typeof(MethodBase)); this.m_value = methodBase.MethodHandle.m_value; if (this.m_value == null) { throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState")); } }
private MethodBase?GetExceptionMethodFromStackTrace() { Debug.Assert(_stackTrace != null, "_stackTrace shouldn't be null when this method is called"); IRuntimeMethodInfo method = GetMethodFromStackTrace(_stackTrace !); // Under certain race conditions when exceptions are re-used, this can be null if (method == null) { return(null); } return(RuntimeType.GetMethodBase(method)); }
internal static ParameterInfo GetReturnParameter( IRuntimeMethodInfo method, MemberInfo member, Signature sig ) { Debug.Assert(method is RuntimeMethodInfo || method is RuntimeConstructorInfo); GetParameters( method, member, sig, out ParameterInfo? returnParameter, fetchReturnParameter: true ); return(returnParameter !); }
public virtual MethodBase GetMethodBase(int i) { // There may be a better way to do this. // we got RuntimeMethodHandles here and we need to go to MethodBase // but we don't know whether the reflection info has been initialized // or not. So we call GetMethods and GetConstructors on the type // and then we fetch the proper MethodBase!! IntPtr mh = rgMethodHandle[i]; if (mh.IsNull()) { return(null); } IRuntimeMethodInfo mhReal = RuntimeMethodHandle.GetTypicalMethodDefinition(new RuntimeMethodInfoStub(mh, this)); return(RuntimeType.GetMethodBase(mhReal)); }
public int GetTokenFor(RuntimeMethodHandle method) { IRuntimeMethodInfo methodInfo = method.GetMethodInfo(); RuntimeMethodHandleInternal internal2 = methodInfo.Value; if ((methodInfo != null) && !RuntimeMethodHandle.IsDynamicMethod(internal2)) { RuntimeType declaringType = RuntimeMethodHandle.GetDeclaringType(internal2); if ((declaringType != null) && RuntimeTypeHandle.IsGenericType(declaringType)) { MethodBase methodBase = RuntimeType.GetMethodBase(methodInfo); Type genericTypeDefinition = methodBase.DeclaringType.GetGenericTypeDefinition(); throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_MethodDeclaringTypeGenericLcg"), new object[] { methodBase, genericTypeDefinition })); } } this.m_tokens.Add(method); return((this.m_tokens.Count - 1) | 0x6000000); }
public int GetTokenFor(RuntimeMethodHandle method) { IRuntimeMethodInfo methodInfo = method.GetMethodInfo(); RuntimeMethodHandleInternal value = methodInfo.Value; if (methodInfo != null && !RuntimeMethodHandle.IsDynamicMethod(value)) { RuntimeType declaringType = RuntimeMethodHandle.GetDeclaringType(value); if (declaringType != null && RuntimeTypeHandle.HasInstantiation(declaringType)) { MethodBase methodBase = RuntimeType.GetMethodBase(methodInfo); Type genericTypeDefinition = methodBase.DeclaringType.GetGenericTypeDefinition(); throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_MethodDeclaringTypeGenericLcg"), methodBase, genericTypeDefinition)); } } this.m_tokens.Add(method); return(this.m_tokens.Count - 1 | 100663296); }
public override unsafe MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) { MethodBase methodBase; System.Reflection.MetadataToken token = new System.Reflection.MetadataToken(metadataToken); if (!this.MetadataImport.IsValidToken((int)token)) { throw new ArgumentOutOfRangeException("metadataToken", Environment.GetResourceString("Argument_InvalidToken", new object[] { token, this })); } RuntimeTypeHandle[] typeInstantiationContext = ConvertToTypeHandleArray(genericTypeArguments); RuntimeTypeHandle[] methodInstantiationContext = ConvertToTypeHandleArray(genericMethodArguments); try { if (!token.IsMethodDef && !token.IsMethodSpec) { if (!token.IsMemberRef) { throw new ArgumentException("metadataToken", Environment.GetResourceString("Argument_ResolveMethod", new object[] { token, this })); } if (*(((byte *)this.MetadataImport.GetMemberRefProps((int)token).Signature.ToPointer())) == 6) { throw new ArgumentException("metadataToken", Environment.GetResourceString("Argument_ResolveMethod", new object[] { token, this })); } } IRuntimeMethodInfo method = ModuleHandle.ResolveMethodHandleInternal(this.GetNativeHandle(), (int)token, typeInstantiationContext, methodInstantiationContext); Type declaringType = RuntimeMethodHandle.GetDeclaringType(method); if (declaringType.IsGenericType || declaringType.IsArray) { System.Reflection.MetadataToken token2 = new System.Reflection.MetadataToken(this.MetadataImport.GetParentToken((int)token)); if (token.IsMethodSpec) { token2 = new System.Reflection.MetadataToken(this.MetadataImport.GetParentToken((int)token2)); } declaringType = this.ResolveType((int)token2, genericTypeArguments, genericMethodArguments); } methodBase = System.RuntimeType.GetMethodBase(declaringType as System.RuntimeType, method); } catch (BadImageFormatException exception) { throw new ArgumentException(Environment.GetResourceString("Argument_BadImageFormatExceptionResolve"), exception); } return(methodBase); }
public override bool Equals(object obj) { if (!this.IsGenericMethod) { return(obj == this); } RuntimeMethodInfo method = obj as RuntimeMethodInfo; if ((method == null) || !method.IsGenericMethod) { return(false); } IRuntimeMethodInfo info2 = RuntimeMethodHandle.StripMethodInstantiation(this); IRuntimeMethodInfo info3 = RuntimeMethodHandle.StripMethodInstantiation(method); if (info2.Value.Value != info3.Value.Value) { return(false); } Type[] genericArguments = this.GetGenericArguments(); Type[] typeArray2 = method.GetGenericArguments(); if (genericArguments.Length != typeArray2.Length) { return(false); } for (int i = 0; i < genericArguments.Length; i++) { if (genericArguments[i] != typeArray2[i]) { return(false); } } if (this.DeclaringType != method.DeclaringType) { return(false); } if (this.ReflectedType != method.ReflectedType) { return(false); } return(true); }
protected override MethodInfo GetMethodImpl() { if (_invocationCount != (IntPtr)0 && _invocationList != null) { // multicast case Object[] invocationList = _invocationList as Object[]; if (invocationList != null) { int index = (int)_invocationCount - 1; return(((Delegate)invocationList[index]).Method); } MulticastDelegate innerDelegate = _invocationList as MulticastDelegate; if (innerDelegate != null) { // must be a secure/wrapper delegate return(innerDelegate.GetMethodImpl()); } } else if (IsUnmanagedFunctionPtr()) { // we handle unmanaged function pointers here because the generic ones (used for WinRT) would otherwise // be treated as open delegates by the base implementation, resulting in failure to get the MethodInfo if ((_methodBase == null) || !(_methodBase is MethodInfo)) { IRuntimeMethodInfo method = FindMethodHandle(); RuntimeType declaringType = RuntimeMethodHandle.GetDeclaringType(method); // need a proper declaring type instance method on a generic type if (RuntimeTypeHandle.IsGenericTypeDefinition(declaringType) || RuntimeTypeHandle.HasInstantiation(declaringType)) { // we are returning the 'Invoke' method of this delegate so use this.GetType() for the exact type RuntimeType reflectedType = GetType() as RuntimeType; declaringType = reflectedType; } _methodBase = (MethodInfo)RuntimeType.GetMethodBase(declaringType, method); } return((MethodInfo)_methodBase); } // Otherwise, must be an inner delegate of a SecureDelegate of an open virtual method. In that case, call base implementation return(base.GetMethodImpl()); }
public static unsafe void PrepareMethod(RuntimeMethodHandle method, RuntimeTypeHandle[]?instantiation) { IRuntimeMethodInfo methodInfo = method.GetMethodInfo(); if (methodInfo == null) { throw new ArgumentException(SR.InvalidOperation_HandleIsNotInitialized, nameof(method)); } // defensive copy of user-provided array, per CopyRuntimeTypeHandles contract instantiation = (RuntimeTypeHandle[]?)instantiation?.Clone(); IntPtr[]? instantiationHandles = RuntimeTypeHandle.CopyRuntimeTypeHandles(instantiation, out int length); fixed(IntPtr *pInstantiation = instantiationHandles) { PrepareMethod(methodInfo.Value, pInstantiation, length); GC.KeepAlive(instantiation); GC.KeepAlive(methodInfo); } }
public int GetTokenFor(RuntimeMethodHandle method) { IRuntimeMethodInfo methodReal = method.GetMethodInfo(); RuntimeMethodHandleInternal rmhi = methodReal.Value; if (methodReal != null && !RuntimeMethodHandle.IsDynamicMethod(rmhi)) { RuntimeType type = RuntimeMethodHandle.GetDeclaringType(rmhi); if ((type != null) && RuntimeTypeHandle.HasInstantiation(type)) { // Do we really need to retrieve this much info just to throw an exception? MethodBase m = RuntimeType.GetMethodBase(methodReal); Type t = m.DeclaringType.GetGenericTypeDefinition(); throw new ArgumentException(SR.Format(SR.Argument_MethodDeclaringTypeGenericLcg, m, t)); } } m_tokens.Add(method); return(m_tokens.Count - 1 | (int)MetadataTokenType.MethodDef); }
public override unsafe MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) { System.Reflection.MetadataToken metadataToken1 = new System.Reflection.MetadataToken(metadataToken); if (!this.MetadataImport.IsValidToken((int)metadataToken1)) { throw new ArgumentOutOfRangeException("metadataToken", Environment.GetResourceString("Argument_InvalidToken", (object)metadataToken1, (object)this)); } RuntimeTypeHandle[] typeHandleArray1 = RuntimeModule.ConvertToTypeHandleArray(genericTypeArguments); RuntimeTypeHandle[] typeHandleArray2 = RuntimeModule.ConvertToTypeHandleArray(genericMethodArguments); try { if (!metadataToken1.IsMethodDef && !metadataToken1.IsMethodSpec) { if (!metadataToken1.IsMemberRef) { throw new ArgumentException("metadataToken", Environment.GetResourceString("Argument_ResolveMethod", (object)metadataToken1, (object)this)); } if ((int)*(byte *)this.MetadataImport.GetMemberRefProps((int)metadataToken1).Signature.ToPointer() == 6) { throw new ArgumentException("metadataToken", Environment.GetResourceString("Argument_ResolveMethod", (object)metadataToken1, (object)this)); } } IRuntimeMethodInfo runtimeMethodInfo = ModuleHandle.ResolveMethodHandleInternal(this.GetNativeHandle(), (int)metadataToken1, typeHandleArray1, typeHandleArray2); Type type = (Type)RuntimeMethodHandle.GetDeclaringType(runtimeMethodInfo); if (type.IsGenericType || type.IsArray) { System.Reflection.MetadataToken metadataToken2 = new System.Reflection.MetadataToken(this.MetadataImport.GetParentToken((int)metadataToken1)); if (metadataToken1.IsMethodSpec) { metadataToken2 = new System.Reflection.MetadataToken(this.MetadataImport.GetParentToken((int)metadataToken2)); } type = this.ResolveType((int)metadataToken2, genericTypeArguments, genericMethodArguments); } return(RuntimeType.GetMethodBase(type as RuntimeType, runtimeMethodInfo)); } catch (BadImageFormatException ex) { throw new ArgumentException(Environment.GetResourceString("Argument_BadImageFormatExceptionResolve"), (Exception)ex); } }
private static unsafe bool FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, ref Assembly lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, bool mustBeInheritable, object[] attributes, IList derivedAttributes, out RuntimeType attributeType, out IRuntimeMethodInfo ctor, out bool ctorHasParameters, out bool isVarArg) { ctor = (IRuntimeMethodInfo)null; attributeType = (RuntimeType)null; ctorHasParameters = false; isVarArg = false; IntPtr num = (IntPtr)((void *)((IntPtr)(void *)caRecord.blob.Signature + caRecord.blob.Length)); attributeType = decoratedModule.ResolveType(scope.GetParentToken((int)caRecord.tkCtor), (Type[])null, (Type[])null) as RuntimeType; if (!attributeFilterType.IsAssignableFrom((TypeInfo)attributeType) || !CustomAttribute.AttributeUsageCheck(attributeType, mustBeInheritable, attributes, derivedAttributes) || (attributeType.Attributes & TypeAttributes.WindowsRuntime) == TypeAttributes.WindowsRuntime) { return(false); } RuntimeAssembly targetAssembly = (RuntimeAssembly)attributeType.Assembly; RuntimeAssembly sourceAssembly = (RuntimeAssembly)decoratedModule.Assembly; if ((Assembly)targetAssembly != lastAptcaOkAssembly && !RuntimeAssembly.AptcaCheck(targetAssembly, sourceAssembly)) { return(false); } lastAptcaOkAssembly = (Assembly)sourceAssembly; ConstArray methodSignature = scope.GetMethodSignature(caRecord.tkCtor); isVarArg = ((uint)methodSignature[0] & 5U) > 0U; ctorHasParameters = (uint)methodSignature[1] > 0U; RuntimeTypeHandle runtimeTypeHandle1; if (ctorHasParameters) { ctor = ModuleHandle.ResolveMethodHandleInternal(decoratedModule.GetNativeHandle(), (int)caRecord.tkCtor); } else { // ISSUE: explicit reference operation // ISSUE: variable of a reference type IRuntimeMethodInfo& local = @ctor; runtimeTypeHandle1 = attributeType.GetTypeHandleInternal(); IRuntimeMethodInfo defaultConstructor = runtimeTypeHandle1.GetDefaultConstructor();
[System.Security.SecuritySafeCritical] // auto-generated internal static IRuntimeMethodInfo StripMethodInstantiation(IRuntimeMethodInfo method) { IRuntimeMethodInfo strippedMethod = method; StripMethodInstantiation(method, JitHelpers.GetObjectHandleOnStack(ref strippedMethod)); return strippedMethod; }
[System.Security.SecuritySafeCritical] // auto-generated internal static IRuntimeMethodInfo GetTypicalMethodDefinition(IRuntimeMethodInfo method) { if (!IsTypicalMethodDefinition(method)) GetTypicalMethodDefinition(method, JitHelpers.GetObjectHandleOnStack(ref method)); return method; }
internal extern static bool IsTypicalMethodDefinition(IRuntimeMethodInfo method);
[System.Security.SecuritySafeCritical] // auto-generated internal static bool HasMethodInstantiation(IRuntimeMethodInfo method) { bool fRet = RuntimeMethodHandle.HasMethodInstantiation(method.Value); GC.KeepAlive(method); return fRet; }
[System.Security.SecuritySafeCritical] // auto-generated internal static bool IsSecurityTransparent(IRuntimeMethodInfo method) { return _IsSecurityTransparent(method); }
[System.Security.SecuritySafeCritical] // auto-generated internal static bool IsSecuritySafeCritical(IRuntimeMethodInfo method) { return _IsSecuritySafeCritical(method); }
internal static extern object CreateCaInstance(RuntimeType type, IRuntimeMethodInfo ctor);
internal RuntimeMethodHandle(IRuntimeMethodInfo method) { m_value = method; }
[System.Security.SecurityCritical] // auto-generated internal unsafe static ParameterInfo[] GetParameters( IRuntimeMethodInfo methodHandle, MemberInfo member, Signature sig, out ParameterInfo returnParameter, bool fetchReturnParameter) { returnParameter = null; int sigArgCount = sig.Arguments.Length; ParameterInfo[] args = fetchReturnParameter ? null : new ParameterInfo[sigArgCount]; int tkMethodDef = RuntimeMethodHandle.GetMethodDef(methodHandle); int cParamDefs = 0; // Not all methods have tokens. Arrays, pointers and byRef types do not have tokens as they // are generated on the fly by the runtime. if (!MdToken.IsNullToken(tkMethodDef)) { MetadataImport scope = RuntimeTypeHandle.GetMetadataImport(RuntimeMethodHandle.GetDeclaringType(methodHandle)); MetadataEnumResult tkParamDefs; scope.EnumParams(tkMethodDef, out tkParamDefs); cParamDefs = tkParamDefs.Length; // Not all parameters have tokens. Parameters may have no token // if they have no name and no attributes. if (cParamDefs > sigArgCount + 1 /* return type */) { throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ParameterSignatureMismatch")); } for (int i = 0; i < cParamDefs; i++) { #region Populate ParameterInfos ParameterAttributes attr; int position, tkParamDef = tkParamDefs[i]; scope.GetParamDefProps(tkParamDef, out position, out attr); position--; if (fetchReturnParameter == true && position == -1) { // more than one return parameter? if (returnParameter != null) { throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ParameterSignatureMismatch")); } returnParameter = new RuntimeParameterInfo(sig, scope, tkParamDef, position, attr, member); } else if (fetchReturnParameter == false && position >= 0) { // position beyong sigArgCount? if (position >= sigArgCount) { throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ParameterSignatureMismatch")); } args[position] = new RuntimeParameterInfo(sig, scope, tkParamDef, position, attr, member); } #endregion } } // Fill in empty ParameterInfos for those without tokens if (fetchReturnParameter) { if (returnParameter == null) { returnParameter = new RuntimeParameterInfo(sig, MetadataImport.EmptyImport, 0, -1, (ParameterAttributes)0, member); } } else { if (cParamDefs < args.Length + 1) { for (int i = 0; i < args.Length; i++) { if (args[i] != null) { continue; } args[i] = new RuntimeParameterInfo(sig, MetadataImport.EmptyImport, 0, i, (ParameterAttributes)0, member); } } } return(args); }
private static extern unsafe void _PrepareMethod(IRuntimeMethodInfo method, IntPtr *pInstantiation, int cInstantiation);
private extern void GetSignature( void* pCorSig, int cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType);
internal static extern void _CompileMethod(IRuntimeMethodInfo method);
[System.Security.SecuritySafeCritical] // auto-generated public Signature(IRuntimeMethodInfo methodHandle, RuntimeType declaringType) { GetSignature(null, 0, new RuntimeFieldHandleInternal(), methodHandle, declaringType); }
[System.Security.SecuritySafeCritical] // auto-generated internal static string ConstructInstantiation(IRuntimeMethodInfo method, TypeNameFormatFlags format) { string name = null; ConstructInstantiation(EnsureNonNullMethodInfo(method), format, JitHelpers.GetStringHandleOnStack(ref name)); return name; }
private static extern bool _IsSecuritySafeCritical(IRuntimeMethodInfo method);
[System.Security.SecuritySafeCritical] // auto-generated internal static RuntimeType GetDeclaringType(IRuntimeMethodInfo method) { RuntimeType type = RuntimeMethodHandle.GetDeclaringType(method.Value); GC.KeepAlive(method); return type; }
private static extern bool _IsSecurityTransparent(IRuntimeMethodInfo method);
[System.Security.SecurityCritical] // auto-generated internal static int GetSlot(IRuntimeMethodInfo method) { Contract.Requires(method != null); int slot = RuntimeMethodHandle.GetSlot(method.Value); GC.KeepAlive(method); return slot; }
[System.Security.SecuritySafeCritical] // auto-generated internal static Type[] GetMethodInstantiationPublic(IRuntimeMethodInfo method) { RuntimeType[] types = null; GetMethodInstantiation(EnsureNonNullMethodInfo(method).Value, JitHelpers.GetObjectHandleOnStack(ref types), false); GC.KeepAlive(method); return types; }
internal extern static int GetMethodDef(IRuntimeMethodInfo method);
[System.Security.SecuritySafeCritical] // auto-generated internal static bool IsGenericMethodDefinition(IRuntimeMethodInfo method) { bool fRet = RuntimeMethodHandle.IsGenericMethodDefinition(method.Value); GC.KeepAlive(method); return fRet; }
[System.Security.SecurityCritical] // auto-generated internal static string GetName(IRuntimeMethodInfo method) { string name = RuntimeMethodHandle.GetName(method.Value); GC.KeepAlive(method); return name; }
private extern static void GetTypicalMethodDefinition(IRuntimeMethodInfo method, ObjectHandleOnStack outMethod);
[System.Security.SecurityCritical] // auto-generated internal static INVOCATION_FLAGS GetSecurityFlags(IRuntimeMethodInfo handle) { return (INVOCATION_FLAGS)RuntimeMethodHandle.GetSpecialSecurityFlags(handle); }
private extern static void StripMethodInstantiation(IRuntimeMethodInfo method, ObjectHandleOnStack outMethod);
static extern internal uint GetSpecialSecurityFlags(IRuntimeMethodInfo method);
[System.Security.SecuritySafeCritical] // auto-generated internal extern static MethodBody GetMethodBody(IRuntimeMethodInfo method, RuntimeType declaringType);
static internal void PerformSecurityCheck(Object obj, IRuntimeMethodInfo method, RuntimeType parent, uint invocationFlags) { RuntimeMethodHandle.PerformSecurityCheck(obj, method.Value, parent, invocationFlags); GC.KeepAlive(method); return; }
[System.Security.SecuritySafeCritical] // auto-generated public Signature ( IRuntimeMethodInfo method, RuntimeType[] arguments, RuntimeType returnType, CallingConventions callingConvention) { m_pMethod = method.Value; m_arguments = arguments; m_returnTypeORfieldType = returnType; m_managedCallingConventionAndArgIteratorFlags = (byte)callingConvention; GetSignature(null, 0, new RuntimeFieldHandleInternal(), method, null); }
internal extern static void SerializationInvoke(IRuntimeMethodInfo method, Object target, SerializationInfo info, ref StreamingContext context);
internal static extern Object CreateCaInstance(RuntimeType type, IRuntimeMethodInfo ctor);
private extern bool BindToMethodInfo(object?target, IRuntimeMethodInfo method, RuntimeType methodType, DelegateBindingFlags flags);
private extern bool BindToMethodInfo(Object target, IRuntimeMethodInfo method, RuntimeType methodType, DelegateBindingFlags flags);
private static extern void InternalPrelink(IRuntimeMethodInfo m);