当前位置: 首页>>代码示例>>C#>>正文


C# TypeDefinition.HasAttribute方法代码示例

本文整理汇总了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;
		}
开发者ID:boothead,项目名称:mono-tools,代码行数:14,代码来源:ReviewSuppressUnmanagedCodeSecurityUsageRule.cs

示例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;
		}
开发者ID:FreeBSD-DotNet,项目名称:mono-tools,代码行数:14,代码来源:ReviewSuppressUnmanagedCodeSecurityUsageRule.cs

示例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;
		}
开发者ID:FreeBSD-DotNet,项目名称:mono-tools,代码行数:12,代码来源:MissingAttributeUsageOnCustomAttributeRule.cs

示例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
         };
 }
开发者ID:gusev-p,项目名称:Aop,代码行数:14,代码来源:ChangeTrackingRewriter.cs

示例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;
 }
开发者ID:gusev-p,项目名称:Aop,代码行数:14,代码来源:ChangeTrackingScheme.cs

示例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;
        }
开发者ID:alfredodev,项目名称:mono-tools,代码行数:35,代码来源:RemoveDependenceOnObsoleteCodeRule.cs

示例7: UsedForComInterop

		private static bool UsedForComInterop (TypeDefinition type)
		{
			return (type.IsInterface && type.HasAttribute (GuidAttribute) &&
				type.HasAttribute (InterfaceTypeAttribute));
		}
开发者ID:nolanlum,项目名称:mono-tools,代码行数:5,代码来源:DetectNonAlphaNumericsInTypeNamesRule.cs

示例8: UsedForComInterop

		private static bool UsedForComInterop (TypeDefinition type)
		{
			return (type.IsInterface && type.HasAttribute ("System.Runtime.InteropServices", "GuidAttribute") &&
				type.HasAttribute ("System.Runtime.InteropServices", "InterfaceTypeAttribute"));
		}
开发者ID:col42dev,项目名称:mono-tools,代码行数:5,代码来源:DetectNonAlphaNumericsInTypeNamesRule.cs


注:本文中的Mono.Cecil.TypeDefinition.HasAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。