public static void AddMethod(CoverageReport.TypeDescriptor dType, CoverageReport.MethodDescriptor dMethod) { CoverageReport.MethodDescriptor[] newMethods = new CoverageReport.MethodDescriptor[dType.methods.Length + 1]; dType.methods.CopyTo(newMethods, 1); newMethods[0] = dMethod; dType.methods = newMethods; }
private static CoverageReport.MethodDescriptor FindExistingMethod(CoverageReport.TypeDescriptor dType, CoverageReport.MethodDescriptor dMethod) { foreach (CoverageReport.MethodDescriptor md in dType.methods) { if (md.methodName == dMethod.methodName && md.methodSig == dMethod.methodSig && md.flags == dMethod.flags && md.implFlags == dMethod.implFlags) { return(md); } } return(null); }
public static void AddType(CoverageReport report, CoverageReport.TypeDescriptor dType) { CoverageReport.TypeDescriptor existingType = FindExistingType(report, dType); if (existingType == null) { CoverageReport.TypeDescriptor[] newTypes = new CoverageReport.TypeDescriptor[report.types.Length + 1]; report.types.CopyTo(newTypes, 1); newTypes[0] = dType; report.types = newTypes; return; } foreach (CoverageReport.MethodDescriptor md in dType.methods) { CoverageReport.MethodDescriptor existingMethod = FindExistingMethod(existingType, md); if (existingMethod == null) { CoverageReport.MethodDescriptor[] newMethods = new CoverageReport.MethodDescriptor[existingType.methods.Length + 1]; existingType.methods.CopyTo(newMethods, 1); newMethods[0] = md; existingType.methods = newMethods; continue; } Debug.Assert(md.insBlocks.Length == 1); CoverageReport.InnerBlockData existingBlockData = FindExistingBlockData(existingMethod.insBlocks, md.insBlocks[0]); if (existingBlockData == null) { CoverageReport.InnerBlockData[] newBlocks = new CoverageReport.InnerBlockData[existingMethod.insBlocks.Length + 1]; existingMethod.insBlocks.CopyTo(newBlocks, 1); newBlocks[0] = md.insBlocks[0]; existingMethod.insBlocks = newBlocks; } else { for (int i = 0; i < existingBlockData.blocks.Length; ++i) { CoverageReport.InnerBlock existingBlock = existingBlockData.blocks[i]; CoverageReport.InnerBlock newBlock = FindBlock(md.insBlocks[0].blocks, existingBlock); Debug.Assert(newBlock != null); existingBlock.visitCount += newBlock.visitCount; } } } }
public static void AddType(CoverageReport report, CoverageReport.TypeDescriptor dType) { CoverageReport.TypeDescriptor existingType = FindExistingType(report, dType); if (existingType == null) { CoverageReport.TypeDescriptor[] newTypes = new CoverageReport.TypeDescriptor[report.types.Length + 1]; report.types.CopyTo(newTypes, 1); newTypes[0] = dType; report.types = newTypes; return; } foreach (CoverageReport.MethodDescriptor md in dType.methods) { CoverageReport.MethodDescriptor existingMethod = FindExistingMethod(existingType, md); if (existingMethod == null) { CoverageReport.MethodDescriptor[] newMethods = new CoverageReport.MethodDescriptor[existingType.methods.Length + 1]; existingType.methods.CopyTo(newMethods, 1); newMethods[0] = md; existingType.methods = newMethods; continue; } Debug.Assert(md.insBlocks.Length == 1); CoverageReport.InnerBlockData existingBlockData = FindExistingBlockData(existingMethod.insBlocks, md.insBlocks[0]); if (existingBlockData == null) { CoverageReport.InnerBlockData[] newBlocks = new CoverageReport.InnerBlockData[existingMethod.insBlocks.Length + 1]; existingMethod.insBlocks.CopyTo(newBlocks, 1); newBlocks[0] = md.insBlocks[0]; existingMethod.insBlocks = newBlocks; } else { for (int i = 0; i < existingBlockData.blocks.Length; ++i) { CoverageReport.InnerBlock existingBlock = existingBlockData.blocks[i]; CoverageReport.InnerBlock newBlock = FindBlock(md.insBlocks[0].blocks, existingBlock); Debug.Assert(newBlock != null); existingBlock.visitCount += newBlock.visitCount; } } } }
public ClassNode(CoverageReport.TypeDescriptor dType) : base(ReportHelper.GetTypeDefName(dType.typeName)) { this.dType = dType; }
private static CoverageReport.TypeDescriptor FindExistingType(CoverageReport report, CoverageReport.TypeDescriptor dType) { foreach (CoverageReport.TypeDescriptor td in report.types) { if (td.assemblyName == dType.assemblyName && td.typeName == dType.typeName && td.flags == dType.flags) { return(td); } } return(null); }
public static void ReadReport(CoverageReport report, TextReader reader) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(reader); //Get Main Element PartCoverReport... XmlNode root = xmlDocument.SelectSingleNode("/PartCoverReport"); if (root == null) { throw new Exception("Bad xml format"); } //Look for Main Element's ver attribute... XmlAttribute verAttribute = root.Attributes["ver"]; if (verAttribute == null) { throw new Exception("Bad xml format"); } //Main Element will have a bunch of file Nodes... foreach (XmlNode fileNode in xmlDocument.SelectNodes("/PartCoverReport/file")) { ReportHelper.AddFile ( report, ReportHelper.GetAttributeAsUInt32(fileNode, "id"), ReportHelper.GetAttributeAsString(fileNode, "url") ); } foreach (XmlNode typeNode in xmlDocument.SelectNodes("/PartCoverReport/type")) { CoverageReport.TypeDescriptor dType = new CoverageReport.TypeDescriptor(); dType.assemblyName = ReportHelper.GetAttributeAsString(typeNode, "asm"); dType.typeName = ReportHelper.GetAttributeAsString(typeNode, "name"); dType.flags = ReportHelper.GetAttributeAsUInt32(typeNode, "flags"); foreach (XmlNode methodNode in typeNode.SelectNodes("method")) { CoverageReport.MethodDescriptor dMethod = new CoverageReport.MethodDescriptor(0); dMethod.methodName = ReportHelper.GetAttributeAsString(methodNode, "name"); dMethod.methodSig = ReportHelper.GetAttributeAsString(methodNode, "sig"); dMethod.flags = ReportHelper.GetAttributeAsUInt32(methodNode, "flags"); dMethod.implFlags = ReportHelper.GetAttributeAsUInt32(methodNode, "iflags"); foreach (XmlNode blockNode in methodNode.SelectNodes("code")) { CoverageReport.InnerBlockData dBlock = new CoverageReport.InnerBlockData(); foreach (XmlNode pointNode in blockNode.SelectNodes("pt")) { CoverageReport.InnerBlock dPoint = new CoverageReport.InnerBlock(); dPoint.visitCount = ReportHelper.GetAttributeAsUInt32(pointNode, "visit"); dPoint.position = ReportHelper.GetAttributeAsUInt32(pointNode, "pos"); dPoint.blockLen = ReportHelper.GetAttributeAsUInt32(pointNode, "len"); if (pointNode.Attributes["fid"] != null) { dPoint.fileId = ReportHelper.GetAttributeAsUInt32(pointNode, "fid"); dPoint.startLine = ReportHelper.GetAttributeAsUInt32(pointNode, "sl"); dPoint.startColumn = ReportHelper.GetAttributeAsUInt32(pointNode, "sc"); dPoint.endLine = ReportHelper.GetAttributeAsUInt32(pointNode, "el"); dPoint.endColumn = ReportHelper.GetAttributeAsUInt32(pointNode, "ec"); } ReportHelper.AddBlock(dBlock, dPoint); } ReportHelper.AddBlockData(dMethod, dBlock); } ReportHelper.AddMethod(dType, dMethod); } ReportHelper.AddType(report, dType); } }
public ClassNode(CoverageReport.TypeDescriptor dType) : base(ReportHelper.GetTypeDefName(dType.typeName)) { this.dType = dType; }
public static void ReadReport(CoverageReport report, TextReader reader) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(reader); //Get Main Element PartCoverReport... XmlNode root = xmlDocument.SelectSingleNode("/PartCoverReport"); if (root == null) throw new Exception("Bad xml format"); //Look for Main Element's ver attribute... XmlAttribute verAttribute = root.Attributes["ver"]; if (verAttribute == null) throw new Exception("Bad xml format"); //Main Element will have a bunch of file Nodes... foreach (XmlNode fileNode in xmlDocument.SelectNodes("/PartCoverReport/file")) { ReportHelper.AddFile ( report, ReportHelper.GetAttributeAsUInt32(fileNode, "id"), ReportHelper.GetAttributeAsString(fileNode, "url") ); } foreach(XmlNode typeNode in xmlDocument.SelectNodes("/PartCoverReport/type")) { CoverageReport.TypeDescriptor dType = new CoverageReport.TypeDescriptor(); dType.assemblyName = ReportHelper.GetAttributeAsString(typeNode, "asm"); dType.typeName = ReportHelper.GetAttributeAsString(typeNode, "name"); dType.flags = ReportHelper.GetAttributeAsUInt32(typeNode, "flags"); foreach(XmlNode methodNode in typeNode.SelectNodes("method")) { CoverageReport.MethodDescriptor dMethod = new CoverageReport.MethodDescriptor(0); dMethod.methodName = ReportHelper.GetAttributeAsString(methodNode, "name"); dMethod.methodSig = ReportHelper.GetAttributeAsString(methodNode, "sig"); dMethod.flags = ReportHelper.GetAttributeAsUInt32(methodNode, "flags"); dMethod.implFlags = ReportHelper.GetAttributeAsUInt32(methodNode, "iflags"); foreach(XmlNode blockNode in methodNode.SelectNodes("code")) { CoverageReport.InnerBlockData dBlock = new CoverageReport.InnerBlockData(); foreach(XmlNode pointNode in blockNode.SelectNodes("pt")) { CoverageReport.InnerBlock dPoint = new CoverageReport.InnerBlock(); dPoint.visitCount = ReportHelper.GetAttributeAsUInt32(pointNode, "visit"); dPoint.position = ReportHelper.GetAttributeAsUInt32(pointNode, "pos"); dPoint.blockLen = ReportHelper.GetAttributeAsUInt32(pointNode, "len"); if (pointNode.Attributes["fid"] != null) { dPoint.fileId = ReportHelper.GetAttributeAsUInt32(pointNode, "fid"); dPoint.startLine = ReportHelper.GetAttributeAsUInt32(pointNode, "sl"); dPoint.startColumn = ReportHelper.GetAttributeAsUInt32(pointNode, "sc"); dPoint.endLine = ReportHelper.GetAttributeAsUInt32(pointNode, "el"); dPoint.endColumn = ReportHelper.GetAttributeAsUInt32(pointNode, "ec"); } ReportHelper.AddBlock(dBlock, dPoint); } ReportHelper.AddBlockData(dMethod, dBlock); } ReportHelper.AddMethod(dType, dMethod); } ReportHelper.AddType(report, dType); } }