Пример #1
0
 public void AddLine(LineElement e)
 {
     _lines.Add(e);
 }
Пример #2
0
        public ProjectElement Parse(String[] inputfiles) {
            ProjectElement PROJECT = new ProjectElement("new_project", 123323230);
            // Open file
            using (CoverageInfo info = JoinCoverageFiles(inputfiles))
            {
                CoverageDS dataSet = info.BuildDataSet();
                
                Dictionary<String, PackageElement> packages = new Dictionary<String, PackageElement>();
                Dictionary<uint, FileElement> files = new Dictionary<uint, FileElement>();
                
                // Namespaces
                DataTable namespacesTable = dataSet.Tables["NameSpaceTable"];
                DataTable classesTable = dataSet.Tables["Class"];
                DataTable filesTable = dataSet.Tables["SourceFileNames"];
                
                CreateIndexPackages(PROJECT, namespacesTable, packages);
                CreateIndexFiles(filesTable, files);
                
                foreach(DataRow iclass in classesTable.Rows)
                {
                    DataRow[] childRows = iclass.GetChildRows("Class_Method");

                    // Since it's one class per file (at least) declare
                    // file here and add it to the class.
                    uint fileid = 0;
                    // uint classlocs = 0;
                    uint covered_methods = 0;
                    FileElement fe = null;
                    
                    foreach(DataRow imethod in childRows)
                    {
                        // Method starting line
                        uint linenum = 0;
                        // Get First Line in class
                        DataRow[] childRows2 = imethod.GetChildRows("Method_Lines");
                        //if(childRows2.Length > 0)
                        foreach(DataRow iline in childRows2)
                        {
                            LineElement le = null;
                            uint coverage = iline.Field<uint>("Coverage");
                            if (linenum == 0)
                            {
                                fileid = iline.Field<uint>("SourceFileID");
                                string methodname = System.Security.SecurityElement.Escape((string)imethod["MethodName"]);
                                linenum = iline.Field<uint>("LnStart");
                                le = new LineElement(linenum, "method", methodname, coverage);
                            } else {
                                linenum = iline.Field<uint>("LnStart");
                                le = new LineElement(linenum, "stmt", "", coverage);
                            }
                            
                            // If the file doesn't exists in our report, we'll
                            // just ignore this information
                            if (files.ContainsKey(fileid))
                            {
                                fe = files[fileid];
                                fe.AddLine(le);
                            }
                        }
                        
                        // Count how many methods covered we have
                        if ((uint)imethod["LinesCovered"] > 0) covered_methods++;
                    }
                    
                    uint totallines = (uint)iclass["LinesCovered"] + (uint)iclass["LinesNotCovered"] + (uint)iclass["LinesPartiallyCovered"];
                    uint complexity = 1;
                    uint methods = (uint)childRows.Length;
                    uint statements = totallines - methods;
                    uint covered_statements = (uint)iclass["LinesCovered"] - covered_methods;
                    uint conditionals = 0;
                    uint covered_conditionals = 0;
                    
                    ClassElement ce = new ClassElement (System.Security.SecurityElement.Escape((string)iclass["ClassName"]));
                    ce.Metrics = new ClassMetrics(complexity, statements, covered_statements, conditionals, covered_conditionals, methods, covered_methods);
                    
                    if (fe != null)
                    {
                        if (!fe.GetClasses().Contains(ce))
                        {
                            fe.AddClass(ce);
                        }

                        if (packages.ContainsKey((string)iclass["NamespaceKeyName"]))
                        {
                            PackageElement pe = packages[(string)iclass["NamespaceKeyName"]];
                            if (!pe.GetFiles().Contains(fe))
                            {
                                pe.AddFile(fe);
                            }
                        }
                    }
                }
            }
            return PROJECT;
        }
Пример #3
0
 public void AddLine(LineElement e)
 {
     _lines.Add(e);
 }