예제 #1
0
 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;
 }
예제 #2
0
 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;
 }
예제 #3
0
 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);
 }
예제 #4
0
 public static string GetFileUrl(CoverageReport report, UInt32 fileId)
 {
     foreach (CoverageReport.FileDescriptor fd in report.files)
     {
         if (fd.fileId == fileId)
         {
             return(fd.fileUrl);
         }
     }
     return(null);
 }
예제 #5
0
      public static void AddFile(CoverageReport report, UInt32 id, String url)
      {
         CoverageReport.FileDescriptor[] newFiles = new CoverageReport.FileDescriptor[report.files.Length + 1];
         report.files.CopyTo(newFiles, 1);

         newFiles[0] = new CoverageReport.FileDescriptor();
         newFiles[0].fileId = id;
         newFiles[0].fileUrl = url;

         report.files = newFiles;
      }
예제 #6
0
      public static void AddMethodNode(ClassNode classNode, CoverageReport.MethodDescriptor md)
      {
         MethodNode mNode = new MethodNode(md);
         classNode.Nodes.Add(mNode);

         if (md.insBlocks.Length > 1)
         {
            foreach (CoverageReport.InnerBlockData bData in md.insBlocks)
               mNode.Nodes.Add(new BlockVariantTreeNode(bData));
         }
      }
예제 #7
0
        public static void AddFile(CoverageReport report, UInt32 id, String url)
        {
            CoverageReport.FileDescriptor[] newFiles = new CoverageReport.FileDescriptor[report.files.Length + 1];
            report.files.CopyTo(newFiles, 1);

            newFiles[0]         = new CoverageReport.FileDescriptor();
            newFiles[0].fileId  = id;
            newFiles[0].fileUrl = url;

            report.files = newFiles;
        }
예제 #8
0
        public static string[] GetAssemblies(CoverageReport report)
        {
            SortedList list = new SortedList();

            foreach (CoverageReport.TypeDescriptor dType in report.types)
            {
                list[dType.assemblyName] = true;
            }
            string[] res = new string[list.Count];
            list.Keys.CopyTo(res, 0);
            return(res);
        }
예제 #9
0
        public static ICollection GetTypes(CoverageReport report, string assembly)
        {
            ArrayList res = new ArrayList();

            foreach (CoverageReport.TypeDescriptor dType in report.types)
            {
                if (dType.assemblyName == assembly)
                {
                    res.Add(dType);
                }
            }
            return(res);
        }
예제 #10
0
 private static CoverageReport.InnerBlock FindBlock(CoverageReport.InnerBlock[] blocks, CoverageReport.InnerBlock block)
 {
    foreach (CoverageReport.InnerBlock dataBlock in blocks)
    {
       if (dataBlock.position != block.position || dataBlock.blockLen != block.blockLen)
          continue;
       if (dataBlock.fileId == block.fileId &&
           dataBlock.startLine == block.startLine && dataBlock.startColumn == block.startColumn &&
           dataBlock.endLine == block.endLine && dataBlock.endColumn == block.endColumn)
          return dataBlock;
    }
    return null;
 }
예제 #11
0
        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;
                    }
                }
            }
        }
예제 #12
0
      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;
               }
            }
         }
      }
예제 #13
0
 private static CoverageReport.InnerBlockData FindExistingBlockData(CoverageReport.InnerBlockData[] datas, CoverageReport.InnerBlockData bData)
 {
    foreach (CoverageReport.InnerBlockData dataBlock in datas)
    {
       if (dataBlock.blocks.Length != bData.blocks.Length)
          continue;
       bool validBlock = true;
       for (int i = 0; validBlock && i < dataBlock.blocks.Length; ++i)
       {
          CoverageReport.InnerBlock existingBlock = dataBlock.blocks[i];
          CoverageReport.InnerBlock newBlock = FindBlock(bData.blocks, existingBlock);
          validBlock = newBlock != null;
       }
       if (validBlock)
          return dataBlock;
    }
    return null;
 }
예제 #14
0
      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;
      }
예제 #15
0
      public static void AddMethodBlock(CoverageReport.MethodDescriptor dMethod, CoverageReport.InnerBlock inner)
      {
         CoverageReport.InnerBlockData bData = dMethod.insBlocks[0];

         CoverageReport.InnerBlock[] newBlocks = new CoverageReport.InnerBlock[bData.blocks.Length + 1];
         bData.blocks.CopyTo(newBlocks, 1);

         newBlocks[0] = inner;

         bData.blocks = newBlocks;
      }
예제 #16
0
        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);
            }
        }
예제 #17
0
 public static void AddBlock(CoverageReport.InnerBlockData bData, CoverageReport.InnerBlock inner)
 {
    CoverageReport.InnerBlock[] newBlocks = new CoverageReport.InnerBlock[bData.blocks.Length + 1];
    bData.blocks.CopyTo(newBlocks, 1);
    newBlocks[0] = inner;
    bData.blocks = newBlocks;
 }
예제 #18
0
 public static void AddBlockData(CoverageReport.MethodDescriptor dMethod, CoverageReport.InnerBlockData bData)
 {
    CoverageReport.InnerBlockData[] newBlocks = new CoverageReport.InnerBlockData[dMethod.insBlocks.Length + 1];
    dMethod.insBlocks.CopyTo(newBlocks, 1);
    newBlocks[0] = bData;
    dMethod.insBlocks = newBlocks;
 }
예제 #19
0
 public static string GetFileUrl(CoverageReport report, UInt32 fileId)
 {
    foreach (CoverageReport.FileDescriptor fd in report.files)
       if (fd.fileId == fileId) return fd.fileUrl;
    return null;
 }
예제 #20
0
 public static ICollection GetTypes(CoverageReport report, string assembly)
 {
    ArrayList res = new ArrayList();
    foreach (CoverageReport.TypeDescriptor dType in report.types)
       if (dType.assemblyName == assembly)
          res.Add(dType);
    return res;
 }
예제 #21
0
 public static string[] GetAssemblies(CoverageReport report)
 {
    SortedList list = new SortedList();
    foreach (CoverageReport.TypeDescriptor dType in report.types)
       list[dType.assemblyName] = true;
    string[] res = new string[list.Count];
    list.Keys.CopyTo(res, 0);
    return res;
 }
예제 #22
0
파일: Node.cs 프로젝트: codemonkies/UTGV1.0
 public MethodNode(CoverageReport.MethodDescriptor md)
    : base(md.methodName)
 {
    this.md = md;
 }
예제 #23
0
      public static TreeView ShowReport(CoverageReport report, TreeView tvItems)
      {
         tvItems.BeginUpdate();

         if (report == null)
            return tvItems;

         foreach (string assemblyName in ReportHelper.GetAssemblies(report))
         {
            AssemblyNode asmNode = new AssemblyNode(assemblyName);

            tvItems.Nodes.Add(asmNode);

            foreach (CoverageReport.TypeDescriptor dType in ReportHelper.GetTypes(report, assemblyName))
            {
               TreeNode namespaceNode = ReportTreeHelper.GetNamespaceNode(asmNode, dType.typeName);
               ClassNode classNode = new ClassNode(dType);

               namespaceNode.Nodes.Add(classNode);

               Dictionary<string, PropertyTreeNode> props = new Dictionary<string, PropertyTreeNode>();

               foreach (CoverageReport.MethodDescriptor md in dType.methods)
               {
                  if ((md.flags & 0x0800) == 0)
                  {
                     ReportTreeHelper.AddMethodNode(classNode, md);
                     continue;
                  }

                  //has special meaning
                  MdSpecial mdSpecial = DefineMdSpecial(md.methodName);
                  string propName = ExtractProperty(mdSpecial, md.methodName);

                  if (mdSpecial == MdSpecial.Unknown)
                  {
                     ReportTreeHelper.AddMethodNode(classNode, md);
                     continue;
                  }

                  PropertyTreeNode propertyNode;
                  if (!props.TryGetValue(propName, out propertyNode))
                  {
                     propertyNode = new PropertyTreeNode(propName);
                     props[propName] = propertyNode;
                     classNode.Nodes.Add(propertyNode);
                  }

                  MethodNode mdNode = new MethodNode(md);
                  switch (mdSpecial)
                  {
                     case MdSpecial.Get:
                     case MdSpecial.Remove:
                        propertyNode.Getter = mdNode;
                        break;
                     case MdSpecial.Set:
                     case MdSpecial.Add:
                        propertyNode.Setter = mdNode;
                        break;
                  }
               }

               foreach (KeyValuePair<string, PropertyTreeNode> kv in props)
               {
                  if (kv.Value.Getter != null) kv.Value.Nodes.Add(kv.Value.Getter);
                  if (kv.Value.Setter != null) kv.Value.Nodes.Add(kv.Value.Setter);
               }
            }

            asmNode.UpdateCoverageInfo();
         }

         tvItems.EndUpdate();


         return tvItems;

      }
예제 #24
0
 public static UInt32 GetBlockCoveredCodeSize(CoverageReport.InnerBlockData bData)
 {
    UInt32 codeSize = 0;
    foreach (CoverageReport.InnerBlock ib in bData.blocks)
       if (ib.visitCount > 0) codeSize += ib.blockLen;
    return codeSize;
 }
예제 #25
0
        public static TreeView ShowReport(CoverageReport report, TreeView tvItems)
        {
            tvItems.BeginUpdate();

            if (report == null)
            {
                return(tvItems);
            }

            foreach (string assemblyName in ReportHelper.GetAssemblies(report))
            {
                AssemblyNode asmNode = new AssemblyNode(assemblyName);

                tvItems.Nodes.Add(asmNode);

                foreach (CoverageReport.TypeDescriptor dType in ReportHelper.GetTypes(report, assemblyName))
                {
                    TreeNode  namespaceNode = ReportTreeHelper.GetNamespaceNode(asmNode, dType.typeName);
                    ClassNode classNode     = new ClassNode(dType);

                    namespaceNode.Nodes.Add(classNode);

                    Dictionary <string, PropertyTreeNode> props = new Dictionary <string, PropertyTreeNode>();

                    foreach (CoverageReport.MethodDescriptor md in dType.methods)
                    {
                        if ((md.flags & 0x0800) == 0)
                        {
                            ReportTreeHelper.AddMethodNode(classNode, md);
                            continue;
                        }

                        //has special meaning
                        MdSpecial mdSpecial = DefineMdSpecial(md.methodName);
                        string    propName  = ExtractProperty(mdSpecial, md.methodName);

                        if (mdSpecial == MdSpecial.Unknown)
                        {
                            ReportTreeHelper.AddMethodNode(classNode, md);
                            continue;
                        }

                        PropertyTreeNode propertyNode;
                        if (!props.TryGetValue(propName, out propertyNode))
                        {
                            propertyNode    = new PropertyTreeNode(propName);
                            props[propName] = propertyNode;
                            classNode.Nodes.Add(propertyNode);
                        }

                        MethodNode mdNode = new MethodNode(md);
                        switch (mdSpecial)
                        {
                        case MdSpecial.Get:
                        case MdSpecial.Remove:
                            propertyNode.Getter = mdNode;
                            break;

                        case MdSpecial.Set:
                        case MdSpecial.Add:
                            propertyNode.Setter = mdNode;
                            break;
                        }
                    }

                    foreach (KeyValuePair <string, PropertyTreeNode> kv in props)
                    {
                        if (kv.Value.Getter != null)
                        {
                            kv.Value.Nodes.Add(kv.Value.Getter);
                        }
                        if (kv.Value.Setter != null)
                        {
                            kv.Value.Nodes.Add(kv.Value.Setter);
                        }
                    }
                }

                asmNode.UpdateCoverageInfo();
            }

            tvItems.EndUpdate();


            return(tvItems);
        }
예제 #26
0
파일: Node.cs 프로젝트: codemonkies/UTGV1.0
 public ClassNode(CoverageReport.TypeDescriptor dType)
    : base(ReportHelper.GetTypeDefName(dType.typeName))
 {
    this.dType = dType;
 }
예제 #27
0
 internal static float GetBlockCoverage(CoverageReport.InnerBlock ib)
 {
    return ib.visitCount > 0 ? 100 : 0;
 }
예제 #28
0
파일: Node.cs 프로젝트: codemonkies/UTGV1.0
 public BlockVariantTreeNode(CoverageReport.InnerBlockData bData)
    : base("Block Data")
 {
    this.bData = bData;
 }
예제 #29
0
      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);
         }
     }