コード例 #1
0
ファイル: CheckerContext.cs プロジェクト: ndung/NDepCheck
            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();
                }
            }
コード例 #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);
        }
コード例 #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;
 }
コード例 #4
0
ファイル: CheckerContext.cs プロジェクト: ndung/NDepCheck
 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();
     }
 }
コード例 #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();
 }
コード例 #6
0
ファイル: ConsoleLogger.cs プロジェクト: ndung/NDepCheck
 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();
 }