WriteResult() public method

Writes a result to the log.
This function makes a copy of the data stored in result; if a client wishes to reuse the result instance to avoid allocations they can do so. (This function may invoke an internal copy of the result or serialize it in place to disk, etc.)
/// A file IO error occured. Clients implementing /// should allow these exceptions to propagate. /// /// Thrown if the tool info is not yet written. ///
public WriteResult ( System.Result result ) : void
result System.Result /// The result to write. ///
return void
Exemplo n.º 1
0
        public void Log(IRule rule, Result result)
        {
            if (rule == null)
            {
                throw new ArgumentNullException(nameof(rule));
            }

            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            if (rule.Id != result.RuleId)
            {
                //The rule id '{0}' specified by the result does not match the actual id of the rule '{1}'
                string message = string.Format(CultureInfo.InvariantCulture, SdkResources.ResultRuleIdDoesNotMatchRule,
                                               result.RuleId.ToString(),
                                               rule.Id.ToString());

                throw new ArgumentException(message);
            }

            if (!ShouldLog(result.Level))
            {
                return;
            }

            Rules[result.RuleId] = rule;

            CaptureFilesInResult(result);
            _issueLogJsonWriter.WriteResult(result);
        }
Exemplo n.º 2
0
        public void Log(ReportingDescriptor rule, Result result)
        {
            if (rule == null)
            {
                throw new ArgumentNullException(nameof(rule));
            }

            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            if (!result.RuleId.IsEqualToOrHierarchicalDescendantOf(rule.Id))
            {
                //The rule id '{0}' specified by the result does not match the actual id of the rule '{1}'
                string message = string.Format(CultureInfo.InvariantCulture, SdkResources.ResultRuleIdDoesNotMatchRule,
                                               result.RuleId,
                                               rule.Id);

                throw new ArgumentException(message);
            }

            if (!ShouldLog(result.Level))
            {
                return;
            }

            result.RuleIndex = LogRule(rule);

            CaptureFilesInResult(result);
            _issueLogJsonWriter.WriteResult(result);
        }
 public void ResultLogJsonWriter_CannotWriteResultsToDisposedWriter()
 {
     using (var str = new StringWriter())
         using (var json = new JsonTextWriter(str))
             using (var uut = new ResultLogJsonWriter(json))
             {
                 uut.WriteTool(DefaultTool);
                 uut.Dispose();
                 Assert.Throws <InvalidOperationException>(() => uut.WriteResult(DefaultResult));
             }
 }
 public void ResultLogJsonWriter_CannotWriteResultsToDisposedWriter()
 {
     using (var str = new StringWriter())
         using (var json = new JsonTextWriter(str))
             using (var uut = new ResultLogJsonWriter(json))
             {
                 uut.WriteTool(s_defaultTool);
                 uut.Dispose();
                 uut.WriteResult(s_defaultResult);
             }
 }
Exemplo n.º 5
0
 public void ResultLogJsonWriter_CannotWriteIssuesToDisposedWriter()
 {
     using (var str = new StringWriter())
         using (var json = new JsonTextWriter(str))
             using (var uut = new ResultLogJsonWriter(json))
             {
                 uut.WriteToolAndRunInfo(s_defaultToolInfo, s_defaultRunInfo);
                 uut.Dispose();
                 uut.WriteResult(s_defaultIssue);
             }
 }
 public void ResultLogJsonWriter_CannotWriteResultsToDisposedWriter()
 {
     using (var str = new StringWriter())
     using (var json = new JsonTextWriter(str))
     using (var uut = new ResultLogJsonWriter(json))
     {
         uut.WriteTool(DefaultTool);
         uut.Dispose();
         uut.WriteResult(DefaultResult);
     }
 }