Пример #1
0
 public static void ForEachBlock(Report report, Action<MethodBlock> blockVisitor)
 {
     report.Assemblies.ForEach(a =>
         a.Types.ForEach(t =>
             t.Methods.ForEach(m =>
                 m.Blocks.ForEach(blockVisitor))));
 }
Пример #2
0
        public Report Copy()
        {
            var copy = new Report { Date = Date };

            copy.Files.AddRange(Files.ConvertAll(x => x.Copy()));
            copy.Assemblies.AddRange(Assemblies.ConvertAll(x => x.Copy()));

            return copy;
        }
 private void SetReport(Report report)
 {
     if (Report != null && ReportClosing != null)
         ReportClosing(this, EventArgs.Empty);
     ReportFileName = null;
     Report = report;
     if (Report != null && ReportOpened != null)
         ReportOpened(this, EventArgs.Empty);
 }
 public void LoadFromFile(string fileName)
 {
     var report = new Report();
     using (var reader = new XmlTextReader(fileName))
     {
         ReportSerializer.Load(reader, report);
     }
     SetReport(report);
     ReportFileName = fileName;
 }
Пример #5
0
 public static void Save(XmlTextWriter writer, Report report)
 {
     var xmlDoc = new XmlDocument();
     var el = xmlDoc.CreateElement("PartCoverReport");
     var at = xmlDoc.CreateAttribute("version");
     at.Value = "4.0";
     el.Attributes.Append(at);
     var doc = (XmlElement)xmlDoc.AppendChild(el);
     Save(doc, report);
     doc.WriteTo(writer);
 }
Пример #6
0
 public static bool Load(XmlTextReader reader, Report report)
 {
     var xmlDoc = new XmlDocument();
     XmlNode el;
     while ((el = xmlDoc.ReadNode(reader)) != null)
     {
         if (el.NodeType != XmlNodeType.Element)
             continue;
         Load((XmlElement)el, report);
         return true;
     }
     return false;
 }
 public void Open(Report report)
 {
     SetReport(report);
 }
Пример #8
0
 private void ProcessReportReceived(Report report)
 {
     if (runTargetForm.OutputToFile)
     {
         using (var writer = new XmlTextWriter(dlgSave.FileName, Encoding.UTF8))
         {
             writer.Formatting = Formatting.Indented;
             writer.Indentation = 1;
             writer.IndentChar = ' ';
             ReportSerializer.Save(writer, report);
         }
     }
     else
     {
         ServiceContainer.getService<IReportService>().Open(report);
     }
 }
Пример #9
0
 private void ShowSkippedItems(Report report)
 {
     using (var dlg = new SkippedItemsReport())
     {
         dlg.Items = report.SkippedItems;
         dlg.RuleReceiver = runTargetForm.AddIncludeRule;
         dlg.ShowDialog(this);
     }
 }
Пример #10
0
        private void ShowEmptyReportDialog(Report report)
        {
            DialogResult dlgResult;
            using (var dialog = new RunEmptyReport())
            {
                dlgResult = dialog.ShowDialog(this);
            }

            switch (dlgResult)
            {
            case DialogResult.Cancel:
                return;
            case DialogResult.Retry:
                mmRunTarget.PerformClick();
                return;
            case DialogResult.OK:
                ShowSkippedItems(report);
                return;
            }
        }
Пример #11
0
 private static void WriteListOfSkippedItems(Report report)
 {
     report.SkippedItems.ForEach(x =>
         Console.Error.WriteLine("Skipped item [{0}]{1}", x.AssemblyName, x.TypedefName));
 }
 public ReportDomainFlattener(Report report)
 {
     Report = report;
 }
Пример #13
0
        public static void Save(XmlElement node, Report report)
        {
            AddAttribute(node, "date").Value = report.Date.ToString("O", CultureInfo.InvariantCulture);

            foreach (var dFile in report.Files)
            {
                var fileNode = AddElement(node, "File");
                AddAttribute(fileNode, "id").Value = dFile.Id.ToString(CultureInfo.InvariantCulture);
                AddAttribute(fileNode, "url").Value = dFile.PathUri;
            }

            var typeList = new List<TypedefEntry>();

            new List<AssemblyEntry>(report.Assemblies).ForEach(x =>
            {
                var asmNode = AddElement(node, "Assembly");
                AddAttribute(asmNode, "id").Value = x.AssemblyRef.ToString(CultureInfo.InvariantCulture);
                AddAttribute(asmNode, "name").Value = x.Name;
                AddAttribute(asmNode, "module").Value = x.Module;
                AddAttribute(asmNode, "domain").Value = x.Domain;
                AddAttribute(asmNode, "domainIdx").Value = x.DomainIndex.ToString(CultureInfo.InvariantCulture);

                typeList.AddRange(x.Types);
            });

            typeList.ForEach(x =>
            {
                var typeNode = AddElement(node, "Type");
                AddAttribute(typeNode, "asmref").Value = x.Assembly.AssemblyRef.ToString(CultureInfo.InvariantCulture);
                AddAttribute(typeNode, "name").Value = x.Name;
                AddAttribute(typeNode, "flags").Value = ((long)x.Attributes).ToString(CultureInfo.InvariantCulture);

                new List<MethodEntry>(x.Methods).ForEach(m =>
                {
                    var metNode = AddElement(typeNode, "Method");
                    AddAttribute(metNode, "methoddef").Value = m.MethodDef.ToString(CultureInfo.InvariantCulture);
                    AddAttribute(metNode, "name").Value = m.Name;
                    AddAttribute(metNode, "sig").Value = m.Signature;
                    AddAttribute(metNode, "bodysize").Value = m.BodySize.ToString(CultureInfo.InvariantCulture);
                    AddAttribute(metNode, "flags").Value = ((long)m.Flags).ToString(CultureInfo.InvariantCulture);
                    AddAttribute(metNode, "iflags").Value = ((long)m.ImplFlags).ToString(CultureInfo.InvariantCulture);

                    new List<MethodBlock>(m.Blocks).ForEach(b =>
                    {
                        var blockNode = AddElement(metNode, "pt");
                        AddAttribute(blockNode, "visit").Value = b.VisitCount.ToString(CultureInfo.InvariantCulture);
                        AddAttribute(blockNode, "pos").Value = b.Offset.ToString(CultureInfo.InvariantCulture);
                        AddAttribute(blockNode, "len").Value = b.Length.ToString(CultureInfo.InvariantCulture);

                        if (b.File > 0)
                        {
                            AddAttribute(blockNode, "fid").Value = b.File.ToString(CultureInfo.InvariantCulture);
                            AddAttribute(blockNode, "sl").Value = b.Start.Line.ToString(CultureInfo.InvariantCulture);
                            AddAttribute(blockNode, "sc").Value = b.Start.Column.ToString(CultureInfo.InvariantCulture);
                            AddAttribute(blockNode, "el").Value = b.End.Line.ToString(CultureInfo.InvariantCulture);
                            AddAttribute(blockNode, "ec").Value = b.End.Column.ToString(CultureInfo.InvariantCulture);
                        }
                    });
                });
            });
        }
Пример #14
0
        public static void Load(XmlElement node, Report report)
        {
            report.Date = ReadAttributeDate(node, "date");

            foreach (var dFile in SelectChildNodes(node, "file"))
            {
                report.Files.Add(new FileEntry
                {
                    Id = ReadAttributeInt(dFile, "id"),
                    PathUri = ReadAttribute(dFile, "url")
                });
            }

            foreach (var asmNode in SelectChildNodes(node, "assembly"))
            {
                report.Assemblies.Add(new AssemblyEntry
                {
                    AssemblyRef = ReadAttributeInt(asmNode, "id"),
                    Name = ReadAttribute(asmNode, "name"),
                    Module = ReadAttribute(asmNode, "module"),
                    Domain = ReadAttribute(asmNode, "domain"),
                    DomainIndex = ReadAttributeInt(asmNode, "domainIdx")
                });
            }

            foreach (var typeNode in SelectChildNodes(node, "type"))
            {
                var assmRef = ReadAttributeInt(typeNode, "asmref");
                var assemblyEntry = report.Assemblies.Find(x => x.AssemblyRef == assmRef);
                if (assemblyEntry == null)
                {
                    continue;
                }

                var typedefEntry = new TypedefEntry
                {
                    Name = ReadAttribute(typeNode, "name"),
                    Attributes = (TypeAttributes)ReadAttributeLong(typeNode, "flags"),
                    Assembly = assemblyEntry
                };
                assemblyEntry.Types.Add(typedefEntry);

                foreach (var methodNode in SelectChildNodes(typeNode, "method"))
                {
                    var methodEntry = new MethodEntry
                    {
                        Name = ReadAttribute(methodNode, "name"),
                        Signature = ReadAttribute(methodNode, "sig"),
                        BodySize = ReadAttributeInt(methodNode, "bodysize"),
                        Flags = (MethodAttributes)ReadAttributeLong(methodNode, "flags"),
                        ImplFlags = (MethodImplAttributes)ReadAttributeLong(methodNode, "iflags")
                    };
                    typedefEntry.Methods.Add(methodEntry);


                    foreach (var pointNode in SelectChildNodes(methodNode, "pt"))
                    {
                        methodEntry.Blocks.Add(new MethodBlock
                        {
                            VisitCount = ReadAttributeInt(pointNode, "visit"),
                            Offset = ReadAttributeInt(pointNode, "pos"),
                            Length = ReadAttributeInt(pointNode, "len"),
                            File = ReadAttributeInt(pointNode, "fid"),
                            Start = new Position
                            {
                                Column = ReadAttributeInt(pointNode, "sc"),
                                Line = ReadAttributeInt(pointNode, "sl")
                            },
                            End = new Position
                            {
                                Column = ReadAttributeInt(pointNode, "ec"),
                                Line = ReadAttributeInt(pointNode, "el")
                            }
                        });
                    }
                }
            }
        }