// 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;
		}
		// 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;
		}
		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;
		}
Ejemplo n.º 4
0
 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
         };
 }
Ejemplo n.º 5
0
 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;
 }
        // 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;
        }
		private static bool UsedForComInterop (TypeDefinition type)
		{
			return (type.IsInterface && type.HasAttribute (GuidAttribute) &&
				type.HasAttribute (InterfaceTypeAttribute));
		}
		private static bool UsedForComInterop (TypeDefinition type)
		{
			return (type.IsInterface && type.HasAttribute ("System.Runtime.InteropServices", "GuidAttribute") &&
				type.HasAttribute ("System.Runtime.InteropServices", "InterfaceTypeAttribute"));
		}