Esempio n. 1
0
 void WriteItem(MetricGroup group, MetricCounter item, bool close)
 {
     WriteLine("<{0} name='{1}' sequencePoints='{2}' unvisitedPoints='{3}' coverage='{4}' acceptable='{5}'{6}>",
               group.Name,
               XmlEncode(item.Name),
               item.TotalSeqpnts,
               item.Unvisited,
               Math.Round(item.Coverage, 4),
               ACCEPTABLE,
               close ? " /" : String.Empty
               );
 }
Esempio n. 2
0
        public void StartItem(MetricGroup group, MetricCounter item)
        {
            Check.IsEqual("module", group.Name);
            CodeMetric info = item.Group;

            WriteLine("<module moduleId='{0}' name='{1}' assembly='{2}' assemblyIdentity='{3}'>",
                      _moduleId++,
                      XmlEncode(info.FileName),
                      XmlEncode(info.AssemblyName),
                      XmlEncode(info.AssemblyFullName)
                      );
        }
Esempio n. 3
0
        private void WriteHeader(XmlParser parser)
        {
            MetricGroup methods = parser.ByMethod;

            _writer.WriteLine("<?xml version='1.0' encoding='utf-8'?>");
            //_writer.WriteLine("<?xml-stylesheet href='coverage.xsl' type='text/xsl'?>");
            WriteLine("<coverage profilerVersion='{0}' driverVersion='{1}' startTime='{2}' measureTime='{3}'>",
                      parser.VersionInfo, parser.VersionDriver,
                      XmlConvert.ToString(parser.StartTime, XmlDateTimeSerializationMode.RoundtripKind),
                      XmlConvert.ToString(parser.StartTime, XmlDateTimeSerializationMode.RoundtripKind)
                      );
        }
Esempio n. 4
0
 public void StopItem(MetricGroup group, MetricCounter item)
 {
     Check.IsEqual("module", group.Name);
     WriteLine("</module>");
 }
Esempio n. 5
0
 public void StopGroup(MetricGroup group)
 {
 }
Esempio n. 6
0
 public void StartGroup(MetricGroup group)
 {
 }
Esempio n. 7
0
        void WriteItem(MetricGroup group, MetricCounter item, bool close)
        {
            CodeMetric info = item.Group;

            List <CodeMetric> seqpnts = item.Seqpnts;
            List <CodeMetric> unused  = new List <CodeMetric>();

            foreach (CodeMetric metric in seqpnts)
            {
                if (!metric.Excluded && metric.Instrumented && metric.VisitCount == 0)
                {
                    unused.Add(metric);
                }
            }

            if (unused.Count == 0)
            {
                return;
            }

            WriteLine("<method name='{0}' class='{1}{2}{3}'>",
                      XmlEncode(info.MethodName),
                      XmlEncode(info.Namespace),
                      String.IsNullOrEmpty(info.Namespace) ? String.Empty : ".",
                      XmlEncode(info.Class)
                      );

            unused.Sort();

            foreach (CodeMetric metric in unused)
            {
                int lineStart = metric.Line - 1;
                int lineEnd   = metric.EndLine - 1;

                int colStart = Math.Max(metric.Column - 1, 0);
                int colEnd   = Math.Max(metric.EndColumn - 1, 0);

                string[] src;
                if (!_sourceFiles.TryGetValue(metric.SrcFile, out src))
                {
                    try { src = File.ReadAllLines(metric.SrcFile); }
                    catch (FileNotFoundException) { src = new string[0]; }
                }

                StringBuilder sb = new StringBuilder();
                for (int ix = lineStart; ix < src.Length && ix < lineEnd; ix++)
                {
                    string line = src[ix];
                    if (ix == lineStart)
                    {
                        line = line.Substring(Math.Min(colStart, line.Length));
                    }
                    sb.AppendLine(line);
                }
                if (lineEnd < src.Length)
                {
                    string line  = src[lineEnd];
                    int    start = Math.Min(line.Length, lineStart == lineEnd ? colStart : 0);
                    int    end   = Math.Min(line.Length, Math.Max(start, colEnd));
                    sb.AppendLine(line.Substring(start, end - start));
                }

                WriteLine("<seqpnt src='{0}'/>", XmlEncode(sb.ToString().Trim()));
            }

            WriteLine("</method>");
        }
Esempio n. 8
0
 public void WriteItem(MetricGroup group, MetricCounter item)
 {
     WriteItem(group, item, true);
 }
Esempio n. 9
0
 public void StopItem(MetricGroup group, MetricCounter item)
 {
     WriteLine("</{0}>", group.Name);
 }
Esempio n. 10
0
 public void StartItem(MetricGroup group, MetricCounter item)
 {
     WriteItem(group, item, false);
 }
Esempio n. 11
0
 public void StopGroup(MetricGroup group)
 {
     WriteLine("</{0}s>", group.Name);
 }
Esempio n. 12
0
 public void StartGroup(MetricGroup group)
 {
     WriteLine("<{0}s>", group.Name);
 }