private void WriteItem(IReportWriter writer, MetricCounter counter) { CodeMetric current = counter.Group; int ixDiff = 0; while (ixDiff < _groupings.Length && _opened[ixDiff] != null && _groupings[ixDiff].Equals(current, _opened[ixDiff].Group)) { ixDiff++; } //close open for (int ix = _groupings.Length - 1; ix >= ixDiff; ix--) { if (_opened[ix] != null) { writer.StopItem(_heirarchy[ix], _opened[ix]); } _opened[ix] = null; } //open new for (int ix = ixDiff; ix < _opened.Length - 1 && _opened[ix] == null; ix++) { writer.StartItem(_heirarchy[ix], _opened[ix] = _heirarchy[ix][counter.Group]); } writer.WriteItem(_heirarchy[_heirarchy.Length - 1], counter); }
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) ); }
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 ); }
public void StopItem(MetricGroup group, MetricCounter item) { Check.IsEqual("module", group.Name); WriteLine("</module>"); }
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>"); }
public void WriteItem(MetricGroup group, MetricCounter item) { WriteItem(group, item, true); }
public void StopItem(MetricGroup group, MetricCounter item) { WriteLine("</{0}>", group.Name); }
public void StartItem(MetricGroup group, MetricCounter item) { WriteItem(group, item, false); }