protected override void Run(ICSharpFunctionDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer) { var preconditions = CodeContractBlockValidator.ValidateLegacyRequires(element.GetLegacyContractBlockStatements()); foreach (var vr in preconditions.ValidationResults) { var highlighting = vr.Match( error => (IHighlighting)null, warning => null, customWarning => LegacyContractCustomWarningHighlighting.Create(element, customWarning, preconditions), _ => null); if (highlighting != null) { consumer.AddHighlighting(highlighting, vr.Statement.GetDocumentRange(), element.GetContainingFile()); } } }
protected override void Run(ICSharpFunctionDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer) { // Right now there is two different rule sets for Code Contract statements and for any preconditions. var validateContractBlock = CodeContractBlockValidator.ValidateCodeContractBlock(element.GetCodeContractBlockStatements()); foreach (var vr in validateContractBlock.ValidationResults) { var highlighting = vr.Match( error => (IHighlighting) new CodeContractErrorHighlighting(vr.Statement, error, validateContractBlock), warning => new CodeContractWarningHighlighting(vr.Statement, warning, validateContractBlock), customWarning => ContractCustomWarningHighlighting.Create(vr.Statement, customWarning, validateContractBlock), _ => null); if (highlighting != null) { consumer.AddHighlighting(highlighting, vr.Statement.GetDocumentRange(), element.GetContainingFile()); } } }