private static emma.report ConvertToEmma(dotcover.Root dc) { emma.report ret = new emma.report(); ret.stats = CreateStats(dc); ret.data = new emma.data(); ret.data.all = CreateAll(dc); return ret; }
private static emma.all CreateAll(dotcover.Root dc) { emma.all ret = new emma.all(); ret.name = "all classes"; ret.coverage = CreateCoverage(dc); List<emma.package> pkgs = new List<emma.package>(); foreach (var assembly in dc.Assembly) { if (assembly.Namespace != null) { foreach (var ns in assembly.Namespace) { emma.package pkg = new emma.package(); pkg.name = ns.Name; pkg.coverage = CreateCoverage(ns); CreateTypes(pkg, ns.Type); pkgs.Add(pkg); } } if (assembly.Type != null) { emma.package pkg = new emma.package(); pkg.name = assembly.Name; pkg.coverage = CreateCoverage(assembly); CreateTypes(pkg, assembly.Type); pkgs.Add(pkg); } } ret.package = pkgs.ToArray(); return ret; }
private static void ForEachMethod(dotcover.Member member, Action<Entry> callback) { callback(ToEntry(member)); }
private static void ForEachMethod(dotcover.Event evt, Action<Entry> callback) { foreach (dotcover.Method method in evt.Method) ForEachMethod(method, callback, evt.Name); }
private static void ForEachMethod(dotcover.Constructor constructor, Action<Entry> callback) { if (constructor.Items == null) callback(ToEntry(constructor)); else ForEachMethodWithAnonymous(constructor.Items, callback, constructor.Name); }
private static emma.coverage[] CreateCoverage(dotcover.Type type) { DotCoverage cls = new DotCoverage(); ForEachClass(type, cls.CountElements); DotCoverage method = new DotCoverage(); ForEachMethod(type, method.CountElements); DotCoverage cov = new DotCoverage(); cov.Add(int.Parse(type.CoveredStatements), int.Parse(type.TotalStatements)); return Utils.CreateCoverage(cls, method, cov, cov); }
private static List<dotcover.Type> GetTypes(dotcover.Assembly assembly) { List<dotcover.Type> types = new List<dotcover.Type>(); if (assembly.Namespace != null) foreach (var ns in assembly.Namespace) types.AddRange(ns.Type); if (assembly.Type != null) types.AddRange(assembly.Type); return types; }
private static void ForEachMethod(dotcover.AnonymousMethod method, Action<Entry> callback, String parent) { if (method.Items == null) callback(ToEntry(method, parent)); else ForEachMethodWithAnonymous(method.Items, callback, JoinName(parent, method.Name)); }
private static void ForEachMethod(dotcover.Root dc, Action<Entry> callback) { foreach (dotcover.Assembly assembly in dc.Assembly) ForEachMethod(assembly, callback); }
private static void ForEachClass(dotcover.Type type, Action<dotcover.Type> callback) { callback(type); foreach (object inner in type.Items) { if (inner is dotcover.Type) ForEachClass((dotcover.Type) inner, callback); } }
private static void ForEachClass(dotcover.Namespace ns, Action<dotcover.Type> callback) { foreach (var type in ns.Type) ForEachClass(type, callback); }
private static void ForEachClass(dotcover.Root dc, Action<dotcover.Type> callback) { foreach (dotcover.Assembly assembly in dc.Assembly) ForEachClass(assembly, callback); }
private static void Fix(dotcover.Root dc) { if (dc.Assembly == null) dc.Assembly = new dotcover.Assembly[0]; ForEachClass(dc, type => { if (type.Items == null) type.Items = new object[0]; }); }
private static void CreateTypes(emma.package pkg, dotcover.Type[] types) { List<emma.srcfile> files = new List<emma.srcfile>(); foreach (var type in types) { emma.srcfile file = new emma.srcfile(); file.name = type.Name + ".cs_guess"; file.coverage = CreateCoverage(type); file.@class = new emma.@class[1]; file.@class[0] = CreateClass(type); files.Add(file); } pkg.srcfile = files.ToArray(); }
private static emma.stats CreateStats(dotcover.Root dc) { emma.stats ret = new emma.stats(); int[] count = {0}; ForEachPackage(dc, _ => count[0]++); ret.packages = new emma.packages(); ret.packages.value = count[0].ToString(); count[0] = 0; ForEachClass(dc, _ => count[0]++); ret.classes = new emma.classes(); ret.classes.value = count[0].ToString(); count[0] = 0; ForEachMethod(dc, _ => count[0]++); ret.methods = new emma.methods(); ret.methods.value = count[0].ToString(); ret.srcfiles = new emma.srcfiles(); ret.srcfiles.value = ret.classes.value; ret.srclines = new emma.srclines(); ret.srclines.value = dc.TotalStatements; return ret; }
private static void ForEachMethod(dotcover.Property property, Action<Entry> callback) { if (property.Method == null) { callback(ToEntry(property)); return; } else { foreach (dotcover.Method method in property.Method) ForEachMethod(method, callback, property.Name); } }
private static void ForEachMethod(dotcover.OwnCoverage ownCoverage, Action<Entry> callback, String parent) { callback(ToEntry(ownCoverage, parent)); }
private static void ForEachMethod(dotcover.Assembly assembly, Action<Entry> callback) { if (assembly.Namespace != null) foreach (var ns in assembly.Namespace) ForEachMethod(ns, callback); if (assembly.Type != null) foreach (var type in assembly.Type) ForEachMethod(type, callback); }
private static void ForEachPackage(dotcover.Root dc, Action<dotcover.Assembly> callback) { foreach (dotcover.Assembly assembly in dc.Assembly) callback(assembly); }
private static void ForEachMethod(dotcover.Namespace ns, Action<Entry> callback) { foreach (var type in ns.Type) ForEachMethod(type, callback); }
public void CountElements(dotcover.Type type) { Add(int.Parse(type.CoveredStatements) > 0 ? 1 : 0, 1); }
private static void ForEachMethod(dotcover.Type type, Action<Entry> callback) { ForEachMethod(type, false, callback); }
private static void ForEachMethod(dotcover.Type type, Boolean skipInnerTypes, Action<Entry> callback) { foreach (object inner in type.Items) { if (inner is dotcover.Type) { if (!skipInnerTypes) ForEachMethod((dotcover.Type)inner, false, callback); } else if (inner is dotcover.Constructor) ForEachMethod((dotcover.Constructor)inner, callback); else if (inner is dotcover.Event) ForEachMethod((dotcover.Event)inner, callback); else if (inner is dotcover.Member) ForEachMethod((dotcover.Member)inner, callback); else if (inner is dotcover.Method) ForEachMethod((dotcover.Method)inner, callback); else if (inner is dotcover.Property) ForEachMethod((dotcover.Property)inner, callback); } }
private static emma.@class CreateClass(dotcover.Type type) { emma.@class result = new emma.@class(); result.name = type.Name; var objects = new List<object>(); objects.AddRange(CreateCoverage(type)); foreach (object inner in type.Items) { if (inner is dotcover.Type) objects.Add(CreateClass((dotcover.Type)inner)); } result.Items = objects.ToArray(); List<emma.method> methods = new List<emma.method>(); ForEachMethod(type, true, entry => { emma.method m = new emma.method(); m.name = entry.Name; m.coverage = CreateCoverate(entry); methods.Add(m); }); result.method = methods.ToArray(); return result; }