本文整理汇总了C#中System.Reflection.MethodBase.GetMethodImplementationFlags方法的典型用法代码示例。如果您正苦于以下问题:C# MethodBase.GetMethodImplementationFlags方法的具体用法?C# MethodBase.GetMethodImplementationFlags怎么用?C# MethodBase.GetMethodImplementationFlags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.MethodBase
的用法示例。
在下文中一共展示了MethodBase.GetMethodImplementationFlags方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCodeType
public static MethodImplAttributes GetCodeType(MethodBase method)
{
var methodImplementationFlags = method.GetMethodImplementationFlags();
if( methodImplementationFlags == MethodImplAttributes.InternalCall ||
methodImplementationFlags == MethodImplAttributes.PreserveSig )
return methodImplementationFlags;
return (methodImplementationFlags & MethodImplAttributes.CodeTypeMask);
}
示例2: HasBody
bool HasBody(MethodBase Base)
{
if(Base.IsAbstract)
return false;
MethodImplAttributes Attr = Base.GetMethodImplementationFlags();
if((Attr & MethodImplAttributes.Runtime) == MethodImplAttributes.Runtime &&
(Attr & MethodImplAttributes.Managed) == MethodImplAttributes.Managed)
return false;
return true;
}
示例3: Disassemble
public DisassembledMethod Disassemble(MethodBase method)
{
Contract.Requires(method != null);
Contract.Requires(CanDisassemble(method));
var methodBody = method.GetMethodBody();
if (methodBody == null)
{
throw new NotSupportedException(method.DeclaringType +" {" + method.ToString() + "} "+ method.GetMethodImplementationFlags() );
}
Contract.Assert(methodBody!=null);
// ReSharper disable PossibleNullReferenceException
var ilBytes = methodBody.GetILAsByteArray();
// ReSharper restore PossibleNullReferenceException
Type returnType = method is MethodInfo
? (method as MethodInfo).ReturnType
: typeof (void);
var handlingClauses = methodBody.ExceptionHandlingClauses;
Type[] genericParameters = null;
if (method.IsGenericMethod)
{
genericParameters = method.GetGenericArguments();
}
return new DisassembledMethod(
ilBytes,
Scan(ilBytes, handlingClauses),
new ModuleMetadataResolver(method.Module),
handlingClauses,
methodBody.LocalVariables,
returnType,
method.GetParameters(),
method.IsGenericMethodDefinition ,
genericParameters );
}
示例4: ScanMethod
//.........这里部分代码省略.........
}
}
}
#endregion
MethodBase xPlug = null;
// Plugs may use plugs, but plugs won't be plugged over themself
var inl = aMethod.GetCustomAttribute<InlineAttribute>();
if (!aIsPlug && !xIsDynamicMethod)
{
// Check to see if method is plugged, if it is we don't scan body
xPlug = mPlugManager.ResolvePlug(aMethod, xParamTypes);
if (xPlug != null)
{
//ScanMethod(xPlug, true, "Plug method");
if (inl == null)
{
Queue(xPlug, aMethod, "Plug method");
}
}
}
if (xPlug == null)
{
bool xNeedsPlug = false;
if ((aMethod.Attributes & MethodAttributes.PinvokeImpl) != 0)
{
// pinvoke methods dont have an embedded implementation
xNeedsPlug = true;
}
else
{
var xImplFlags = aMethod.GetMethodImplementationFlags();
// todo: prob even more
if (((xImplFlags & MethodImplAttributes.Native) != 0) ||
((xImplFlags & MethodImplAttributes.InternalCall) != 0))
{
// native implementations cannot be compiled
xNeedsPlug = true;
}
}
if (xNeedsPlug)
{
throw new Exception("Native code encountered, plug required. Please see https://github.com/CosmosOS/Cosmos/wiki/Plugs). " + LabelName.GenerateFullName(aMethod) + "." + Environment.NewLine + " Called from :" + Environment.NewLine + sourceItem);
}
//TODO: As we scan each method, we could update or put in a new list
// that has the resolved plug so we don't have to reresolve it again
// later for compilation.
// Scan the method body for more type and method refs
//TODO: Dont queue new items if they are plugged
// or do we need to queue them with a resolved ref in a new list?
if (inl != null)
{
return; // cancel inline
}
List<ILOpCode> xOpCodes;
xOpCodes = mReader.ProcessMethod(aMethod);
if (xOpCodes != null)
{
ProcessInstructions(xOpCodes);
foreach (var xOpCode in xOpCodes)
示例5: MethodDefinitionFor
private MethodDefinition MethodDefinitionFor(MethodBase method, TypeDefinition declaringType)
{
var method_definition = new MethodDefinition(
method.Name,
(MC.MethodAttributes)method.Attributes,
_module_definition.TypeSystem.Void);
method_definition.ImplAttributes = (MC.MethodImplAttributes)(int)method.GetMethodImplementationFlags();
declaringType.Methods.Add(method_definition);
var method_info = method as MethodInfo;
if (method_info != null) {
var generic_parameters = method_info.GetGenericArguments ();
for (int i = 0; i < generic_parameters.Length; i++)
method_definition.GenericParameters.Add (GenericParameterFor (generic_parameters [i], method_definition));
for (int i = 0; i < generic_parameters.Length; i++)
MapGenericParameterConstraints (generic_parameters [i], method_definition.GenericParameters [i], method_definition);
}
foreach (var parameter in method.GetParameters())
MapParameter(method_definition, parameter);
if (method_info != null)
method_definition.ReturnType = CreateReference(method_info.ReturnType, method_definition);
if (_options.MakePublic(method)) method_definition.IsPublic = true;
return method_definition;
}
示例6: CheckInstrumentationAvailability
private static void CheckInstrumentationAvailability(MethodBase value)
{
if (IsInterceptedAtTheCallSite(value))
{
return;
}
#if !PORTABLE
var methodImpl = value.GetMethodImplementationFlags();
if ((((methodImpl & MethodImplAttributes.InternalCall) != 0
|| (methodImpl & MethodImplAttributes.CodeTypeMask) != MethodImplAttributes.IL)
&& value.Module.Assembly == typeof(object).Assembly)
&& !value.IsInheritable())
throw new MockException("Cannot mock a method that is implemented internally by the CLR.");
#endif
if (!value.IsInheritable() && !ProfilerInterceptor.TypeSupportsInstrumentation(value.DeclaringType))
throw new MockException(String.Format("Cannot mock non-inheritable member '{0}' on type '{1}' due to CLR limitations.", value, value.DeclaringType));
if ((value.Attributes & MethodAttributes.PinvokeImpl) != 0)
{
if (!ProfilerInterceptor.IsProfilerAttached)
throw new MockException("The profiler must be enabled to mock DllImport methods.");
string fullName = value.DeclaringType.FullName + "." + value.Name;
if ((value.Attributes & MethodAttributes.HasSecurity) != 0)
throw new MockException(string.Format("DllImport method {0} cannot be mocked because it has security information attached.", fullName));
// method could be the profiler generated shadow method or is inside an assembly which doesn't contain managed code (valid RVA)
throw new MockException(string.Format("DllImport method {0} cannot be mocked due to internal limitation.", fullName));
}
if (uninterceptedMethods.Contains(value))
throw new MockException("Cannot mock Object..ctor, Object.Equals, Object.ReferenceEquals or Finalize");
var asMethodInfo = value as MethodInfo;
if (asMethodInfo != null)
{
if (uninterceptedMethods.Contains(asMethodInfo.GetBaseDefinition()))
throw new MockException("Cannot mock Object.Equals, Object.ReferenceEquals or Finalize");
}
}
示例7: AddCilAttributes
private void AddCilAttributes (StringBuilder sb, MethodBase m, bool newline)
{
MethodImplAttributes attr = m.GetMethodImplementationFlags ();
if ((attr & MethodImplAttributes.InternalCall) != 0) {
AddAttribute (sb, "MethodImplAttribute(MethodImplOptions.InternalCall)");
if (newline)
sb.Append ("\n");
}
}