private void BuildMethodBlocks(CoverageReport.MethodDescriptor md, MethodItem mdItem)
 {
     foreach (CoverageReport.InnerBlockData ibd in md.insBlocks)
     {
         CoveredVariantItem cvItem = new CoveredVariantItem();
         cvItem.Blocks = ibd.blocks;
         mdItem.AddBlock(cvItem);
     }
 }
 public void LoadFromFile(string fileName)
 {
     CoverageReport report = new CoverageReport();
     ReportReader reportReader = new ReportReader();
     using (StreamReader reader = new StreamReader(fileName))
     {
         reportReader.ReadReport(report, reader);
     }
     setReport(report);
     reportFileName = fileName;
 }
        public virtual void WriteReport(CoverageReport report, TextWriter writer)
        {
            XmlDocument xml = new XmlDocument();

            XmlNode root = xml.AppendChild(xml.CreateElement("coverage"));
            root.Attributes.Append(xml.CreateAttribute("profilerVersion")).Value = VersionString(GetHelperAssembly().GetName().Version);
            root.Attributes.Append(xml.CreateAttribute("driverVersion")).Value = VersionString(GetHelperAssembly().GetName().Version);

            // FIXME: Need start and end times
            root.Attributes.Append(xml.CreateAttribute("startTime")).Value = report.start.ToString(NCOVER_DATE_FORMAT);
            root.Attributes.Append(xml.CreateAttribute("measureTime")).Value = report.end.ToString(NCOVER_DATE_FORMAT);

            foreach (CoverageReport.AssemblyDescriptor assembly in report.assemblies)
            {
                XmlNode moduleNode = root.AppendChild(xml.CreateElement("module"));
                moduleNode.Attributes.Append(xml.CreateAttribute("name")).Value = assembly.assemblyPath;    // NCover calls the full path the 'name' and the assembly name the 'assembly'
                moduleNode.Attributes.Append(xml.CreateAttribute("assembly")).Value = assembly.name;
                moduleNode.Attributes.Append(xml.CreateAttribute("assemblyIdentity")).Value = assembly.assemblyIdentity;

                foreach (CoverageReport.TypeDescriptor dType in assembly.types)
                {
                    foreach (CoverageReport.MethodDescriptor dMethod in dType.methods)
                    {
                        XmlNode methodNode = moduleNode.AppendChild(xml.CreateElement("method"));
                        methodNode.Attributes.Append(xml.CreateAttribute("name")).Value = dMethod.methodName;
                        methodNode.Attributes.Append(xml.CreateAttribute("excluded")).Value = "false";
                        methodNode.Attributes.Append(xml.CreateAttribute("instruments")).Value = "true";
                        methodNode.Attributes.Append(xml.CreateAttribute("class")).Value = dType.typeName;

                        foreach (CoverageReport.InnerBlockData bData in dMethod.insBlocks)
                        {
                            foreach (CoverageReport.InnerBlock inner in bData.blocks)
                            {
                                if (inner.fileId != 0)
                                {
                                    XmlNode point = methodNode.AppendChild(xml.CreateElement("seqpnt"));
                                    point.Attributes.Append(xml.CreateAttribute("visitcount")).Value = inner.visitCount.ToString(CultureInfo.InvariantCulture);
                                    point.Attributes.Append(xml.CreateAttribute("excluded")).Value = "false";
                                    point.Attributes.Append(xml.CreateAttribute("line")).Value = inner.startLine.ToString(CultureInfo.InvariantCulture);
                                    point.Attributes.Append(xml.CreateAttribute("column")).Value = inner.startColumn.ToString(CultureInfo.InvariantCulture);
                                    point.Attributes.Append(xml.CreateAttribute("endline")).Value = inner.endLine.ToString(CultureInfo.InvariantCulture);
                                    point.Attributes.Append(xml.CreateAttribute("endcolumn")).Value = inner.endLine.ToString(CultureInfo.InvariantCulture);
                                    point.Attributes.Append(xml.CreateAttribute("document")).Value = report.GetFileUrl(inner.fileId);
                                }
                            }
                        }
                    }
                }
            }

            xml.Save(writer);
        }
 public void Add(CoverageReport.RunHistoryMessage runHistoryMessage)
 {
     SetMessage(runHistoryMessage.Message);
 }
 public void Add(CoverageReport.RunLogMessage runLogMessage)
 {
     PutLogEntry(runLogMessage);
 }
        private void PutLogEntry(CoverageReport.RunLogMessage item)
        {
            if (InvokeRequired)
            {
                Invoke(new PutLogEntryDelegate(PutLogEntry), item);
                return;
            }

            tbLog.AppendText(string.Format(CultureInfo.CurrentCulture,
                "[{0,6}][{1,6}]{2}{3}",
                item.ThreadId, item.MsOffset, item.Message, Environment.NewLine));
        }
Esempio n. 7
0
 public BlockStylizer(CoverageReport.InnerBlock[] points)
 {
     this.points = points;
 }
 public InstrumentedBlocksWalkerInner()
 {
     coverage = new CoverageReport();
 }
        private void setReport(CoverageReport report)
        {
            if (Report != null && ReportClosing != null)
                ReportClosing(this, EventArgs.Empty);

            CoverageReportWrapper wrapper = new CoverageReportWrapper(report);
            wrapper.Build();

            reportFileName = null;
            reportWrapper = wrapper;
            if (Report != null && ReportOpened != null)
                ReportOpened(this, EventArgs.Empty);
        }
 public void Load(CoverageReport report)
 {
     setReport(report);
 }
Esempio n. 11
0
 internal void OnLogMessage(CoverageReport.RunLogMessage message)
 {
     blockWalker.Report.runLog.Add(message);
     if (OnEventMessage != null) OnEventMessage(this, new EventArgs<CoverageReport.RunLogMessage>(message));
 }
Esempio n. 12
0
        public void ReadReport(CoverageReport report, TextReader reader)
        {
            XmlDocument xml = new XmlDocument();
            xml.Load(reader);

            XmlNode root = xml.SelectSingleNode("/PartCoverReport");
            if (root == null) throw new ReportException("Wrong report format");
            XmlAttribute verAttribute = root.Attributes["ver"];
            if (verAttribute == null) throw new ReportException("Wrong report format");
            XmlAttribute exitCodeAttribute = root.Attributes["exitCode"];
            if (exitCodeAttribute != null) report.ExitCode = GetIntAttribute(root, exitCodeAttribute.Name);

            foreach (XmlNode fileNode in xml.SelectNodes("/PartCoverReport/file"))
                report.AddFile(GetUInt32Attribute(fileNode, "id"), GetStringAttribute(fileNode, "url"));

            foreach (XmlNode typeNode in xml.SelectNodes("/PartCoverReport/type"))
            {
                CoverageReport.TypeDescriptor dType = new CoverageReport.TypeDescriptor();
                dType.assemblyName = GetStringAttribute(typeNode, "asm");
                dType.typeName = GetStringAttribute(typeNode, "name");
                dType.flags = GetUInt32Attribute(typeNode, "flags");

                foreach (XmlNode methodNode in typeNode.SelectNodes("method"))
                {
                    CoverageReport.MethodDescriptor dMethod = new CoverageReport.MethodDescriptor(0);
                    dMethod.methodName = GetStringAttribute(methodNode, "name");
                    dMethod.methodSig = GetStringAttribute(methodNode, "sig");
                    dMethod.flags = GetUInt32Attribute(methodNode, "flags");
                    dMethod.implFlags = GetUInt32Attribute(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 = GetUInt32Attribute(pointNode, "visit");
                            dPoint.position = GetUInt32Attribute(pointNode, "pos");
                            dPoint.blockLen = GetUInt32Attribute(pointNode, "len");
                            if (pointNode.Attributes["fid"] != null)
                            {
                                dPoint.fileId = GetUInt32Attribute(pointNode, "fid");
                                dPoint.startLine = GetUInt32Attribute(pointNode, "sl");
                                dPoint.startColumn = GetUInt32Attribute(pointNode, "sc");
                                dPoint.endLine = GetUInt32Attribute(pointNode, "el");
                                dPoint.endColumn = GetUInt32Attribute(pointNode, "ec");
                            }
                            dBlock.AddBlock(dPoint);
                        }
                        dMethod.AddBlockData(dBlock);
                    }
                    dType.AddMethod(dMethod);
                }
                report.AddType(dType);
            }

            foreach (XmlNode messageNode in xml.SelectNodes("/PartCoverReport/run/tracker/message"))
                report.AddTrackerMessage(messageNode);

            foreach (XmlNode messageNode in xml.SelectNodes("/PartCoverReport/run/log/message"))
                report.AddLogFileMessage(messageNode);
        }
        public virtual void WriteReport(CoverageReport report, TextWriter writer)
        {
            XmlDocument xml = new XmlDocument();

            XmlNode root = xml.AppendChild(xml.CreateElement("PartCoverReport"));
            root.Attributes.Append(xml.CreateAttribute("ver")).Value = VersionString(GetHelperAssembly().GetName().Version);

            if (report.ExitCode.HasValue)
                root.Attributes.Append(xml.CreateAttribute("exitCode")).Value = report.ExitCode.Value.ToString(CultureInfo.InvariantCulture);

            foreach (CoverageReport.FileDescriptor dFile in report.files)
            {
                XmlNode fileNode = root.AppendChild(xml.CreateElement("file"));
                fileNode.Attributes.Append(xml.CreateAttribute("id")).Value = dFile.fileId.ToString(CultureInfo.InvariantCulture);
                fileNode.Attributes.Append(xml.CreateAttribute("url")).Value = dFile.fileUrl;
            }
            foreach (CoverageReport.AssemblyDescriptor assembly in report.assemblies)
            {
                foreach (CoverageReport.TypeDescriptor dType in assembly.types)
                {
                    XmlNode typeNode = root.AppendChild(xml.CreateElement("type"));
                    typeNode.Attributes.Append(xml.CreateAttribute("asm")).Value = dType.assemblyName;
                    typeNode.Attributes.Append(xml.CreateAttribute("name")).Value = dType.typeName;
                    typeNode.Attributes.Append(xml.CreateAttribute("flags")).Value =
                        dType.flags.ToString(CultureInfo.InvariantCulture);

                    foreach (CoverageReport.MethodDescriptor dMethod in dType.methods)
                    {
                        XmlNode methodNode = typeNode.AppendChild(xml.CreateElement("method"));
                        methodNode.Attributes.Append(xml.CreateAttribute("name")).Value = dMethod.methodName;
                        methodNode.Attributes.Append(xml.CreateAttribute("sig")).Value = dMethod.methodSig;
                        methodNode.Attributes.Append(xml.CreateAttribute("flags")).Value =
                            dMethod.flags.ToString(CultureInfo.InvariantCulture);
                        methodNode.Attributes.Append(xml.CreateAttribute("iflags")).Value =
                            dMethod.implFlags.ToString(CultureInfo.InvariantCulture);

                        foreach (CoverageReport.InnerBlockData bData in dMethod.insBlocks)
                        {
                            XmlNode codeNode = methodNode.AppendChild(xml.CreateElement("code"));
                            foreach (CoverageReport.InnerBlock inner in bData.blocks)
                            {
                                XmlNode point = codeNode.AppendChild(xml.CreateElement("pt"));
                                point.Attributes.Append(xml.CreateAttribute("visit")).Value =
                                    inner.visitCount.ToString(CultureInfo.InvariantCulture);
                                point.Attributes.Append(xml.CreateAttribute("pos")).Value =
                                    inner.position.ToString(CultureInfo.InvariantCulture);
                                point.Attributes.Append(xml.CreateAttribute("len")).Value =
                                    inner.blockLen.ToString(CultureInfo.InvariantCulture);
                                if (inner.fileId != 0)
                                {
                                    point.Attributes.Append(xml.CreateAttribute("fid")).Value =
                                        inner.fileId.ToString(CultureInfo.InvariantCulture);
                                    point.Attributes.Append(xml.CreateAttribute("sl")).Value =
                                        inner.startLine.ToString(CultureInfo.InvariantCulture);
                                    point.Attributes.Append(xml.CreateAttribute("sc")).Value =
                                        inner.startColumn.ToString(CultureInfo.InvariantCulture);
                                    point.Attributes.Append(xml.CreateAttribute("el")).Value =
                                        inner.endLine.ToString(CultureInfo.InvariantCulture);
                                    point.Attributes.Append(xml.CreateAttribute("ec")).Value =
                                        inner.endColumn.ToString(CultureInfo.InvariantCulture);
                                }
                            }
                        }
                    }
                }
            }

            XmlNode runNode = root.AppendChild(xml.CreateElement("run"));

            XmlNode runTrackerNode = runNode.AppendChild(xml.CreateElement("tracker"));
            foreach (CoverageReport.RunHistoryMessage rhm in report.runHistory)
            {
                XmlNode messageNode = runTrackerNode.AppendChild(xml.CreateElement("message"));
                messageNode.Attributes.Append(xml.CreateAttribute("tm")).Value = rhm.Time.ToUniversalTime().Ticks.ToString(CultureInfo.InvariantCulture);
                messageNode.InnerText = rhm.Message;
            }

            XmlNode runLogNode = runNode.AppendChild(xml.CreateElement("log"));
            foreach (CoverageReport.RunLogMessage rlm in report.runLog)
            {
                XmlNode messageNode = runLogNode.AppendChild(xml.CreateElement("message"));
                messageNode.Attributes.Append(xml.CreateAttribute("tr")).Value = rlm.ThreadId.ToString(CultureInfo.InvariantCulture);
                messageNode.Attributes.Append(xml.CreateAttribute("ms")).Value = rlm.MsOffset.ToString(CultureInfo.InvariantCulture);
                messageNode.InnerText = rlm.Message;
            }

            xml.Save(writer);
        }
 private void BuildMethods(CoverageReport.MethodDescriptor[] mdList, ClassItem classItem)
 {
     foreach (CoverageReport.MethodDescriptor md in mdList)
     {
         MethodItem mdItem = new MethodItem(md, classItem);
         BuildMethodBlocks(md, mdItem);
         classItem.AddMethod(mdItem);
     }
 }
 public CoverageReportWrapper(CoverageReport report)
 {
     this.report = report;
 }