本文整理汇总了C#中Mono.Cecil.TypeDefinition.HasAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# TypeDefinition.HasAttribute方法的具体用法?C# TypeDefinition.HasAttribute怎么用?C# TypeDefinition.HasAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.TypeDefinition
的用法示例。
在下文中一共展示了TypeDefinition.HasAttribute方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckType
// The [SuppressUnmanagedCodeSecurity] attribute applies to
// Classes, Interfaces, Delegates (ITypeRule) and Methods (IMethodRule)
public RuleResult CheckType (TypeDefinition type)
{
if (type.IsEnum)
return RuleResult.DoesNotApply;
if (!type.HasAttribute (SUCS))
return RuleResult.Success;
Runner.Report (type, Severity.Audit, Confidence.Total);
return RuleResult.Failure;
}
示例2: CheckType
// The [SuppressUnmanagedCodeSecurity] attribute applies to
// Classes, Interfaces, Delegates (ITypeRule) and Methods (IMethodRule)
public RuleResult CheckType (TypeDefinition type)
{
if (type.IsEnum)
return RuleResult.DoesNotApply;
if (!type.HasAttribute ("System.Security", "SuppressUnmanagedCodeSecurityAttribute"))
return RuleResult.Success;
Runner.Report (type, Severity.Audit, Confidence.Total);
return RuleResult.Failure;
}
示例3: CheckType
public RuleResult CheckType (TypeDefinition type)
{
// rule applies only to attributes
if (!type.IsAttribute ())
return RuleResult.DoesNotApply;
if (type.HasAttribute ("System", "AttributeUsageAttribute")) // it's ok
return RuleResult.Success;
Runner.Report (type, Severity.High, Confidence.Total);
return RuleResult.Failure;
}
示例4: CreateTypeToRewrite
private TypeToRewrite CreateTypeToRewrite(TypeDefinition type)
{
var markedWithTrackChanges = type.HasAttribute<TrackChangesAttribute>();
var parent = type.BaseType.Name == "Object" || markedWithTrackChanges || parameters.IsForeign(type.BaseType)
? null
: GetTypeToRewrite(type.BaseType.Resolve());
return new TypeToRewrite
{
hierarchyMarkedWithTrackChangesAttribute = markedWithTrackChanges ||
parent != null && parent.hierarchyMarkedWithTrackChangesAttribute,
parent = parent,
type = type
};
}
示例5: NeedTrackType
public bool NeedTrackType(TypeDefinition typeDefinition)
{
if (typeDefinition.Name == "<Module>")
return false;
if (typeDefinition.IsValueType)
return false;
if (typeDefinition.IsNested && !parameters.ProcessNestedTypes)
return false;
if (typeDefinition.IsInterface)
return false;
if (typeDefinition.HasAttribute<CompilerGeneratedAttribute>())
return false;
return true;
}
示例6: CheckType
// Type Visible Non-Visible
// ------------------------------------------------
// BaseType* High Medium
// Interfaces* Medium Low
// Fields Medium Low
// Properties High Medium
// Events High Medium
// * type visibility
public RuleResult CheckType(TypeDefinition type)
{
// we're not interested in the details of [Obsolete] types
if (type.HasAttribute ("System", "ObsoleteAttribute"))
return RuleResult.DoesNotApply;
// check if we inherit from an [Obsolete] class / struct / enum
CheckBaseType (type);
// check if we implement an [Obsolete] interface
if (type.HasInterfaces)
CheckInterfaces (type);
// check fields types
if (type.HasFields)
CheckFields (type);
// check properties (not the getter / setter)
if (type.HasProperties)
CheckProperties (type);
// check events (not add / remove / invoke)
if (type.HasEvents)
CheckEvents (type);
return Runner.CurrentRuleResult;
}
示例7: UsedForComInterop
private static bool UsedForComInterop (TypeDefinition type)
{
return (type.IsInterface && type.HasAttribute (GuidAttribute) &&
type.HasAttribute (InterfaceTypeAttribute));
}
示例8: UsedForComInterop
private static bool UsedForComInterop (TypeDefinition type)
{
return (type.IsInterface && type.HasAttribute ("System.Runtime.InteropServices", "GuidAttribute") &&
type.HasAttribute ("System.Runtime.InteropServices", "InterfaceTypeAttribute"));
}