Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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("&lt;unknown&gt;");
                }
                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\">");
        }