Exemplo n.º 1
0
            /// <inheritdoc/>
            public Dictionary <string, FileCoverage> ConvertToLineCoverage(ParsedTraceFile traceFile, string symbolDirectory, GlobPatternList assemblyPatterns)
            {
                if (!shouldProduceCoverage)
                {
                    return(null);
                }

                // Return some arbitrary coverage
                FileCoverage fileCoverage = new FileCoverage();

                fileCoverage.CoveredLineRanges.Add((12, 33));
                return(new Dictionary <string, FileCoverage>()
                {
                    { "file1.cs", fileCoverage }
                });
            }
Exemplo n.º 2
0
        /// <summary>
        /// Tries to read and convert the trace file. Logs and returns null if this fails.
        /// Empty trace files are archived and null is returned as well.
        /// </summary>
        private Dictionary <string, FileCoverage> ConvertTraceFileToLineCoverage(TraceFile trace, Archive archive, Config.ConfigForProcess processConfig)
        {
            ParsedTraceFile parsedTraceFile = new ParsedTraceFile(trace.Lines, trace.FilePath);
            Dictionary <string, FileCoverage> lineCoverage;

            try
            {
                lineCoverage = lineCoverageSynthesizer.ConvertToLineCoverage(parsedTraceFile, processConfig.PdbDirectory, processConfig.AssemblyPatterns);
            }
            catch (Exception e)
            {
                logger.Error(e, "Failed to convert {traceFile} to line coverage. Will retry later", trace.FilePath);
                return(null);
            }

            if (lineCoverage == null)
            {
                logger.Info("Archiving {trace} because it did not produce any line coverage after conversion", trace.FilePath);
                archive.ArchiveFileWithoutLineCoverage(trace.FilePath);
                return(null);
            }

            return(lineCoverage);
        }