Esempio n. 1
0
        public List <CoverageFile> GenerateSourceFiles(XDocument document, bool useRelativePaths)
        {
            var sourceFiles = new List <CoverageFile> ();

            if (document.Root == null)
            {
                return(sourceFiles);
            }

            var filesUsed = document.Root.Elements("method").Where(m => !string.IsNullOrEmpty(m.Attribute("filename").Value)).Select(m => (m.Attribute("filename").Value));

            foreach (var fullpath in filesUsed)
            {
                var path = fullpath;
                if (useRelativePaths)
                {
                    path = _pathProcessor.ConvertPath(path);
                }
                path = _pathProcessor.UnixifyPath(path);

                var coverageBuilder = new CoverageFileBuilder(path);

                foreach (var method in document.Root.Elements("method").Where(m => (m.Attribute("filename").Value == fullpath)))
                {
                    foreach (var sequencePoint in method.Elements("statement"))
                    {
                        var line  = int.Parse(sequencePoint.Attribute("line").Value);
                        var count = int.Parse(sequencePoint.Attribute("counter").Value);

                        coverageBuilder.RecordCoverage(line, count);
                    }
                }

                var readAllText = _fileSystem.TryLoadFile(fullpath);
                if (readAllText != null)
                {
                    Console.WriteLine("{0}", readAllText);
                    coverageBuilder.AddSource(readAllText);
                }
                var coverageFile = coverageBuilder.CreateFile();
                sourceFiles.Add(coverageFile);
            }

            return(sourceFiles);
        }
Esempio n. 2
0
		public List<CoverageFile> GenerateSourceFiles(XDocument document, bool useRelativePaths)
		{
			var sourceFiles = new List<CoverageFile> ();

			if (document.Root == null) {
				return sourceFiles;
			}

			var filesUsed = document.Root.Elements ("method").Where (m => !string.IsNullOrEmpty(m.Attribute("filename").Value)).Select (m => (m.Attribute ("filename").Value));
			foreach (var fullpath in filesUsed) {
				var path = fullpath;
				if (useRelativePaths)
				{
					path = _pathProcessor.ConvertPath(path);
				}
				path = _pathProcessor.UnixifyPath (path);

				var coverageBuilder = new CoverageFileBuilder (path);

				foreach (var method in document.Root.Elements ("method").Where (m => (m.Attribute ("filename").Value == fullpath))) {
					foreach (var sequencePoint in method.Elements ("statement")) {
						var line = int.Parse (sequencePoint.Attribute ("line").Value);
						var count = int.Parse (sequencePoint.Attribute ("counter").Value);

						coverageBuilder.RecordCoverage (line, count);
					}
				}

				var readAllText = _fileSystem.TryLoadFile(fullpath);
				if (readAllText != null)
				{
					Console.WriteLine ("{0}", readAllText);
					coverageBuilder.AddSource(readAllText);
				}
				var coverageFile = coverageBuilder.CreateFile();
				sourceFiles.Add (coverageFile);
			}

			return sourceFiles;
		}
        public List<CoverageFile> GenerateSourceFiles(XDocument document, bool useRelativePaths)
        {
            var files = new List<CoverageFile>();
            if (document.Root != null)
            {
                var xElement = document.Root.Element("modules");
                if (xElement != null)
                    foreach (var module in xElement.Elements("module"))
                    {
                        var filesElement = module.Element("source_files");
                        if (filesElement != null)
                        {
                            foreach (var file in filesElement.Elements("source_file"))
                            {
                                var fileid = file.Attribute("id").Value;
                                var fullPath = file.Attribute("path").Value;
                                var path = fullPath;
                                if (useRelativePaths)
                                {
                                    path = _pathProcessor.ConvertPath(fullPath);
                                }
                                path = _pathProcessor.UnixifyPath(path);
                                var coverageBuilder = new CoverageFileBuilder(path);

                                var classesElement = module.Element("functions");
                                if (classesElement != null)
                                {
                                    foreach (var @class in classesElement.Elements("function"))
                                    {
                                        var ranges = @class.Element("ranges");
                                        if (ranges != null)
                                        {
                                            foreach (var range in ranges.Elements("range"))
                                            {
                                                var rangeFileId = range.Attribute("source_id").Value;
                                                if (fileid == rangeFileId)
                                                {
                                                    var sourceStartLine = int.Parse(range.Attribute("start_line").Value);
                                                    var sourceEndLine = int.Parse(range.Attribute("end_line").Value);
                                                    var covered = range.Attribute("covered").Value == "yes";

                                                    foreach (
                                                        var lineNumber in
                                                            Enumerable.Range(sourceStartLine,
                                                                sourceEndLine - sourceStartLine + 1))
                                                    {
                                                        coverageBuilder.RecordCoverage(lineNumber, covered ? 1 : 0);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }

                                var readAllText = _fileSystem.TryLoadFile(fullPath);
                                if (readAllText != null)
                                {
                                    coverageBuilder.AddSource(readAllText);
                                }
                                var coverageFile = coverageBuilder.CreateFile();
                                files.Add(coverageFile);
                            }
                        }
                    }
            }
            return files;
        }
Esempio n. 4
0
        public List <CoverageFile> GenerateSourceFiles(XDocument document, bool useRelativePaths)
        {
            var files = new List <CoverageFile>();

            if (document.Root != null)
            {
                var xElement = document.Root.Element("modules");
                if (xElement != null)
                {
                    foreach (var module in xElement.Elements("module"))
                    {
                        var filesElement = module.Element("source_files");
                        if (filesElement != null)
                        {
                            foreach (var file in filesElement.Elements("source_file"))
                            {
                                var fileid   = file.Attribute("id").Value;
                                var fullPath = file.Attribute("path").Value;
                                var path     = fullPath;
                                if (useRelativePaths)
                                {
                                    path = _pathProcessor.ConvertPath(fullPath);
                                }
                                path = _pathProcessor.UnixifyPath(path);
                                var coverageBuilder = new CoverageFileBuilder(path);

                                var classesElement = module.Element("functions");
                                if (classesElement != null)
                                {
                                    foreach (var @class in classesElement.Elements("function"))
                                    {
                                        var ranges = @class.Element("ranges");
                                        if (ranges != null)
                                        {
                                            foreach (var range in ranges.Elements("range"))
                                            {
                                                var rangeFileId = range.Attribute("source_id").Value;
                                                if (fileid == rangeFileId)
                                                {
                                                    var sourceStartLine = int.Parse(range.Attribute("start_line").Value);
                                                    var sourceEndLine   = int.Parse(range.Attribute("end_line").Value);
                                                    var covered         = range.Attribute("covered").Value == "yes";

                                                    foreach (
                                                        var lineNumber in
                                                        Enumerable.Range(sourceStartLine,
                                                                         sourceEndLine - sourceStartLine + 1))
                                                    {
                                                        coverageBuilder.RecordCoverage(lineNumber, covered ? 1 : 0);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }

                                var readAllText = _fileSystem.TryLoadFile(fullPath);
                                if (readAllText != null)
                                {
                                    coverageBuilder.AddSource(readAllText);
                                }
                                var coverageFile = coverageBuilder.CreateFile();
                                files.Add(coverageFile);
                            }
                        }
                    }
                }
            }
            return(files);
        }
Esempio n. 5
0
        public List <CoverageFile> GenerateSourceFiles(XDocument document)
        {
            var files = new List <CoverageFile>();

            if (document.Root != null)
            {
                var xElement = document.Root.Element("Modules");
                if (xElement != null)
                {
                    foreach (var module in xElement.Elements("Module"))
                    {
                        var attribute = module.Attribute("skippedDueTo");
                        if (attribute == null || string.IsNullOrEmpty(attribute.Value))
                        {
                            var filesElement = module.Element("Files");
                            if (filesElement != null)
                            {
                                foreach (var file in filesElement.Elements("File"))
                                {
                                    var fileid             = file.Attribute("uid").Value;
                                    var fullPath           = file.Attribute("fullPath").Value;
                                    var compatibleFilePath = UnixifyPath(fullPath);
                                    var coverageBuilder    = new CoverageFileBuilder(compatibleFilePath);

                                    var classesElement = module.Element("Classes");
                                    if (classesElement != null)
                                    {
                                        foreach (var @class in classesElement.Elements("Class"))
                                        {
                                            var methods = @class.Element("Methods");
                                            if (methods != null)
                                            {
                                                foreach (var method in methods.Elements("Method"))
                                                {
                                                    var sequencePointsElement = method.Element("SequencePoints");
                                                    if (sequencePointsElement != null)
                                                    {
                                                        foreach (var sequencePoint in sequencePointsElement.Elements("SequencePoint"))
                                                        {
                                                            var sequenceFileid = sequencePoint.Attribute("fileid").Value;
                                                            if (fileid == sequenceFileid)
                                                            {
                                                                var sourceLine = int.Parse(sequencePoint.Attribute("sl").Value);
                                                                var visitCount = int.Parse(sequencePoint.Attribute("vc").Value);

                                                                coverageBuilder.RecordCoverage(sourceLine, visitCount);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }

                                    var readAllText = _fileSystem.TryLoadFile(fullPath);
                                    if (readAllText != null)
                                    {
                                        coverageBuilder.AddSource(readAllText);
                                    }
                                    var coverageFile = coverageBuilder.CreateFile();
                                    files.Add(coverageFile);
                                }
                            }
                        }
                    }
                }
            }
            return(files);
        }
Esempio n. 6
0
        public List<CoverageFile> GenerateSourceFiles(XDocument document, bool useRelativePaths)
        {
            var files = new List<CoverageFile>();
            if (document.Root != null)
            {
                var xElement = document.Root.Element("Modules");
                if (xElement != null)
                    foreach (var module in xElement.Elements("Module"))
                    {
                        var attribute = module.Attribute("skippedDueTo");
                        if (attribute == null || string.IsNullOrEmpty(attribute.Value))
                        {
                            var filesElement = module.Element("Files");
                            if (filesElement != null)
                            {
                                foreach (var file in filesElement.Elements("File"))
                                {
                                    var fileid = file.Attribute("uid").Value;
                                    var fullPath = file.Attribute("fullPath").Value;
                                    var path = fullPath;
                                    if (useRelativePaths)
                                    {
                                        path = _pathProcessor.ConvertPath(fullPath);
                                    }
                                    path = _pathProcessor.UnixifyPath(path);
                                    var coverageBuilder = new CoverageFileBuilder(path);

                                    var classesElement = module.Element("Classes");
                                    if (classesElement != null)
                                    {
                                        foreach (var @class in classesElement.Elements("Class"))
                                        {
                                            var methods = @class.Element("Methods");
                                            if (methods != null)
                                                foreach (var method in methods.Elements("Method"))
                                                {
                                                    var sequencePointsElement = method.Element("SequencePoints");
                                                    if (sequencePointsElement != null)
                                                        foreach (var sequencePoint in sequencePointsElement.Elements("SequencePoint"))
                                                        {
                                                            var sequenceFileid = sequencePoint.Attribute("fileid").Value;
                                                            if (fileid == sequenceFileid)
                                                            {
                                                                var sourceLine = int.Parse(sequencePoint.Attribute("sl").Value);
                                                                var visitCount = int.Parse(sequencePoint.Attribute("vc").Value);

                                                                coverageBuilder.RecordCoverage(sourceLine, visitCount);
                                                            }

                                                        }
                                                }
                                        }
                                    }

                                    var readAllText = _fileSystem.TryLoadFile(fullPath);
                                    if (readAllText != null)
                                    {
                                        coverageBuilder.AddSource(readAllText);
                                    }
                                    var coverageFile = coverageBuilder.CreateFile();
                                    files.Add(coverageFile);
                                }
                            }
                        }
                    }
            }
            return files;
        }