Example #1
0
            public void Add(RuleViolation ruleViolation)
            {
                if (_collectViolations)
                {
                    _ruleViolations.Add(ruleViolation);
                }
                switch (ruleViolation.ViolationType)
                {
                case ViolationType.Warning:
                    _warningCount++;
                    break;

                case ViolationType.Error:
                    _errorCount++;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
Example #2
0
        private bool Check(IAssemblyContext assemblyContext, Dependency d)
        {
            bool ok = false;

            if (Log.IsVerboseEnabled)
            {
                Log.WriteInfo("Checking " + d);
            }
            if (_forbidden.Any(r => r.Matches(d)))
            {
                goto DONE;
            }
            if (_allowed.Any(r => r.Matches(d)))
            {
                ok = true;
                goto DONE;
            }
            if (_questionable.Any(r => r.Matches(d)))
            {
                var ruleViolation = new RuleViolation(d, ViolationType.Warning);
                Log.WriteViolation(ruleViolation);
                if (assemblyContext != null)
                {
                    assemblyContext.Add(ruleViolation);
                }
                ok = true;
            }
DONE:
            if (!ok)
            {
                var ruleViolation = new RuleViolation(d, ViolationType.Error);
                Log.WriteViolation(ruleViolation);
                if (assemblyContext != null)
                {
                    assemblyContext.Add(ruleViolation);
                }
            }
            return(ok);
        }
Example #3
0
 private bool Check(IAssemblyContext assemblyContext, Dependency d)
 {
     bool ok = false;
     if (Log.IsVerboseEnabled) {
         Log.WriteInfo("Checking " + d);
     }
     if (_forbidden.Any(r => r.Matches(d))) {
         goto DONE;
     }
     if (_allowed.Any(r => r.Matches(d))) {
         ok = true;
         goto DONE;
     }
     if (_questionable.Any(r => r.Matches(d))) {
         var ruleViolation = new RuleViolation(d, ViolationType.Warning);
         Log.WriteViolation(ruleViolation);
         if (assemblyContext != null) {
             assemblyContext.Add(ruleViolation);
         }
         ok = true;
     }
     DONE:
     if (!ok) {
         var ruleViolation = new RuleViolation(d, ViolationType.Error);
         Log.WriteViolation(ruleViolation);
         if (assemblyContext != null) {
             assemblyContext.Add(ruleViolation);
         }
     }
     return ok;
 }
Example #4
0
 public void Add(RuleViolation ruleViolation)
 {
     if (_collectViolations) {
         _ruleViolations.Add(ruleViolation);
     }
     switch (ruleViolation.ViolationType) {
         case ViolationType.Warning:
             _warningCount++;
             break;
         case ViolationType.Error:
             _errorCount++;
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
Example #5
0
 public void WriteViolation(RuleViolation ruleViolation)
 {
     Console.ForegroundColor = ruleViolation.ViolationType == ViolationType.Warning ? ConsoleColor.Yellow : ConsoleColor.Red;
     Console.Out.WriteLine(FormatMessage(ruleViolation.Dependency, ruleViolation.ViolationType));
     Console.ResetColor();
 }
Example #6
0
 public void WriteViolation(RuleViolation ruleViolation)
 {
     Console.ForegroundColor = ruleViolation.ViolationType == ViolationType.Warning ? ConsoleColor.Yellow : ConsoleColor.Red;
     Console.Out.WriteLine(FormatMessage(ruleViolation.Dependency, ruleViolation.ViolationType));
     Console.ResetColor();
 }