Esempio n. 1
0
        public IStyleCopRule GetRuleFor(Violation violation)
        {
            IStyleCopRule rule = null;

            this.handlers.TryGetValue(violation.Rule.CheckId, out rule);
            return(rule ?? this.emptyRule);
        }
        private void StyleCopIssueProvider_CheckCodeIssues(object sender, CheckCodeIssuesEventArgs ea)
        {
            if (this.checkForSuppressions && ea.IsSuppressed(ea.Scope))
            {
                return;
            }

            var scope = ea.Scope as SourceFile;

            if (scope == null)
            {
                return;
            }

            var project = scope.Project as ProjectElement;

            if (project == null)
            {
                return;
            }

            ISourceCode sourceCode = this.SetupSourceCode(scope);

            foreach (var violationList in this.styleCopRunner.GetViolations(project, sourceCode).Values)
            {
                foreach (var violation in violationList)
                {
                    IStyleCopRule rule = this.issuesFactory.GetRuleFor(violation);
                    rule.AddViolationIssue(ea, sourceCode, violation);
                }
            }
        }