private static void DoViolation(XmlWriter writer, Violation violation) { writer.WriteStartElement("Violation"); writer.WriteAttributeString("checkID", violation.CheckID); writer.WriteAttributeString("typeName", violation.TypeName); writer.WriteAttributeString("category", violation.Category); writer.WriteAttributeString("severity", violation.Severity.ToString()); writer.WriteAttributeString("breaking", violation.Breaking ? "true" : "false"); writer.WriteStartElement("Cause"); writer.WriteString(BaseReport.Expand(Reformat.Text(violation.Cause))); writer.WriteEndElement(); writer.WriteStartElement("Description"); writer.WriteString(BaseReport.Expand(Reformat.Text(violation.Description))); writer.WriteEndElement(); writer.WriteStartElement("Fix"); writer.WriteString(BaseReport.Expand(Reformat.Text(violation.Fix))); writer.WriteEndElement(); writer.WriteStartElement("CSharp"); writer.WriteString(Reformat.Code(violation.Csharp)); writer.WriteEndElement(); writer.WriteEndElement(); }
private static string DoMungeCode(string text) { string result; result = Reformat.Code(text); // result = Break.Lines(result, ms_consoleWidth); result = result.TrimEnd(' ', '\r', '\n'); return(result); }
private static string DoMungeText(string text) { string result; result = Reformat.Text(text); result = Break.Lines(result, ms_consoleWidth); result = DoBulletedList(result); result = DoTable(result); result = BaseReport.Expand(result); return(result); }
private static string DoMungeText(string text) { string result; result = Reformat.Text(text); // don't have to do this for html, but it makes the html source look better result = Escape(result); result = DoParagraph(result); result = DoBulletedList(result); result = DoTable(result); result = ProcessLinks(result); return(result); }
private static void DoWriteViolation(TextWriter stream, Violation violation) { stream.WriteLine("<a name = \"{0}\">", violation.TypeName); stream.WriteLine("<h2 class = \"category\">{0}</h2>", violation.TypeName); stream.WriteLine("</a>"); HtmlHelpers.WriteText(stream, "CheckId", violation.CheckID); HtmlHelpers.WriteSeverity(stream, "Severity", violation.Severity.ToString()); HtmlHelpers.WriteText(stream, "Breaking", violation.Breaking ? "Yes" : "No"); HtmlHelpers.WriteText(stream, "Cause", violation.Cause); HtmlHelpers.WriteText(stream, "Description", violation.Description); HtmlHelpers.WriteText(stream, "Fix", violation.Fix); if (violation.Csharp.Length > 0) { string code = Reformat.Code(violation.Csharp); code = HtmlHelpers.Escape(code); code = HtmlHelpers.ProcessLinks(code); code = HtmlHelpers.ColorizeCode(code); stream.WriteLine("<pre class = \"code\">{0}</pre>", code); } }
private static void DoWriteViolation(TextWriter stream, int counter, Violation violation, List <Location> locations) { string countStr = DoGetCounter(counter, locations.Count); stream.WriteLine("<h2 class = \"category\">{0} {1}</h2>", countStr, violation.TypeName); HtmlHelpers.WriteSeverity(stream, "Severity", violation.Severity.ToString()); HtmlHelpers.WriteText(stream, "Breaking", violation.Breaking ? "Yes" : "No"); HtmlHelpers.WriteText(stream, "CheckId", violation.CheckID); foreach (Location loc in locations) { stream.WriteLine("<table border = \"2\" rules = \"none\" class = \"location\">"); stream.WriteLine("<tr>"); stream.WriteLine("<td>File:</td>"); stream.WriteLine("<td>"); if (loc.Line >= 0) { stream.WriteLine("{0}:{1}", HtmlHelpers.Escape(loc.File), loc.Line); } else if (loc.File != null && loc.File.Length > 0) { stream.WriteLine(HtmlHelpers.Escape(loc.File)); } else { stream.WriteLine("<unknown>"); } stream.WriteLine("</td>"); stream.WriteLine("</tr>"); stream.WriteLine("<tr>"); stream.WriteLine("<td>Name:</td>"); stream.WriteLine("<td>"); stream.WriteLine(HtmlHelpers.Escape(loc.Name)); stream.WriteLine("</td>"); stream.WriteLine("</tr>"); if (loc.Details != null && loc.Details.Length > 0) { stream.WriteLine("<tr>"); stream.WriteLine("<td>Details:</td>"); stream.WriteLine("<td>"); stream.WriteLine(HtmlHelpers.Escape(loc.Details)); stream.WriteLine("</td>"); stream.WriteLine("</tr>"); } stream.WriteLine("</table>"); } HtmlHelpers.WriteText(stream, "Cause", BaseReport.Expand(violation.Cause)); HtmlHelpers.WriteText(stream, "Description", BaseReport.Expand(violation.Description)); HtmlHelpers.WriteText(stream, "Fix", violation.Fix); if (violation.Csharp.Length > 0) { string code = Reformat.Code(violation.Csharp); code = HtmlHelpers.Escape(code); code = HtmlHelpers.ProcessLinks(code); code = HtmlHelpers.ColorizeCode(code); stream.WriteLine("<pre class = \"code\">{0}</pre>", code); } stream.WriteLine("<hr class = \"separator\">"); }