/// <summary> /// Check if MethodImpl requires slot unification. /// </summary> /// <param name="method">Method to check</param> /// <returns>True when the method is marked with the PreserveBaseOverrides custom attribute, false otherwise.</returns> public static bool RequiresSlotUnification(this MethodDesc method) { if (method.HasCustomAttribute("System.Runtime.CompilerServices", "PreserveBaseOverridesAttribute")) { #if DEBUG // We shouldn't be calling this for non-MethodImpls, so verify that the method being checked is really a MethodImpl MetadataType mdType = method.OwningType as MetadataType; if (mdType != null) { bool isMethodImpl = false; foreach (MethodImplRecord methodImplRecord in mdType.VirtualMethodImplsForType) { if (method == methodImplRecord.Body) { isMethodImpl = true; break; } } Debug.Assert(isMethodImpl); } #endif return(true); } return(false); }
/// <summary> /// Gets a value indicating whether the method has the SuppressGCTransition attribute /// </summary> public static bool HasSuppressGCTransitionAttribute(this MethodDesc method) { Debug.Assert(method.IsPInvoke); if (method is Internal.IL.Stubs.PInvokeTargetNativeMethod rawPinvoke) { method = rawPinvoke.Target; } // Check SuppressGCTransition attribute return(method.HasCustomAttribute("System.Runtime.InteropServices", "SuppressGCTransitionAttribute")); }
protected override IMethodNode CreateMethodEntrypointNode(MethodDesc method) { if (method.HasCustomAttribute("System.Runtime", "RuntimeImportAttribute")) { return new RuntimeImportMethodNode(method); } if (CompilationModuleGroup.ContainsMethod(method)) { return new MethodCodeNode(method); } else { return new ExternMethodSymbolNode(method); } }
protected override IMethodNode CreateMethodEntrypointNode(MethodDesc method) { if (method.IsInternalCall) { // The only way to locate the entrypoint for an internal call is through the RuntimeImportAttribute. // If this is a method that doesn't have it (e.g. a string constructor), the method should never // have reached this code path. Debug.Assert(method.HasCustomAttribute("System.Runtime", "RuntimeImportAttribute")); return new RuntimeImportMethodNode(method); } if (CompilationModuleGroup.ContainsMethod(method)) { return new MethodCodeNode(method); } else { return new ExternMethodSymbolNode(method); } }
public static UnmanagedCallingConventions GetPInvokeMethodCallingConventions(this MethodDesc method) { Debug.Assert(method.IsPInvoke); UnmanagedCallingConventions result; if (method is Internal.IL.Stubs.PInvokeTargetNativeMethod pinvokeTarget) { method = pinvokeTarget.Target; } MethodSignatureFlags unmanagedCallConv = method.GetPInvokeMethodMetadata().Flags.UnmanagedCallingConvention; if (unmanagedCallConv != MethodSignatureFlags.None) { Debug.Assert((int)MethodSignatureFlags.UnmanagedCallingConventionCdecl == (int)UnmanagedCallingConventions.Cdecl && (int)MethodSignatureFlags.UnmanagedCallingConventionStdCall == (int)UnmanagedCallingConventions.Stdcall && (int)MethodSignatureFlags.UnmanagedCallingConventionThisCall == (int)UnmanagedCallingConventions.Thiscall); result = (UnmanagedCallingConventions)unmanagedCallConv; } else { CustomAttributeValue <TypeDesc>?unmanagedCallConvAttribute = ((EcmaMethod)method).GetDecodedCustomAttribute("System.Runtime.InteropServices", "UnmanagedCallConvAttribute"); if (unmanagedCallConvAttribute != null) { result = GetUnmanagedCallingConventionFromAttribute(unmanagedCallConvAttribute.Value, method.Context); } else { result = GetPlatformDefaultUnmanagedCallingConvention(method.Context); } } if (method.HasCustomAttribute("System.Runtime.InteropServices", "SuppressGCTransitionAttribute")) { result |= UnmanagedCallingConventions.IsSuppressGcTransition; } return(result); }
protected override IMethodNode CreateMethodEntrypointNode(MethodDesc method) { if (method.IsInternalCall) { // The only way to locate the entrypoint for an internal call is through the RuntimeImportAttribute. if (method.HasCustomAttribute("System.Runtime", "RuntimeImportAttribute")) { return new RuntimeImportMethodNode(method); } // On CLR this would throw a SecurityException with "ECall methods must be packaged into a system module." // This is a corner case that nobody is likely to care about. throw new TypeSystemException.InvalidProgramException(ExceptionStringID.InvalidProgramSpecific, method); } if (CompilationModuleGroup.ContainsMethod(method)) { return new MethodCodeNode(method); } else { return new ExternMethodSymbolNode(method); } }
public override bool HasCustomAttribute(string attributeNamespace, string attributeName) { return(_typicalMethodDef.HasCustomAttribute(attributeNamespace, attributeName)); }