Example #1
0
        public IEnumerable <ISourceMappedItem> GetSourceInfo(IEnumerable <string> assemblyPaths, ReportingResult report)
        {
            var items = new List <ISourceMappedItem>();

            _textOutput.WriteLine();
            _textOutput.WriteLine(LocalizedStrings.FindingSourceLineInformationFor);

            foreach (var assembly in assemblyPaths)
            {
                using (var task = _progressReporter.StartTask(string.Format("\t{0}\b\b\b", Path.GetFileName(assembly))))
                {
                    try
                    {
                        var pdbPath = _fileSystem.ChangeFileExtension(assembly, "pdb");

                        if (!_fileSystem.FileExists(pdbPath))
                        {
                            _progressReporter.ReportIssue(string.Format(LocalizedStrings.PdbNotFoundFormat, assembly));
                            task.Abort();
                            continue;
                        }

                        items.AddRange(GetSourceInfo(assembly, pdbPath, report));
                    }
                    catch (PortabilityAnalyzerException)
                    {
                        task.Abort();
                    }
                }
            }

            return(items);
        }
        public IEnumerable <ISourceMappedItem> GetSourceInfo(IEnumerable <string> assemblyPaths, ReportingResult report)
        {
            var items = new List <ISourceMappedItem>();

            _textOutput.WriteLine();
            _textOutput.WriteLine(LocalizedStrings.FindingSourceLineInformationFor);

            int currentIssues = _progressReporter.Issues.Count;

            foreach (var assembly in assemblyPaths)
            {
                using (var task = _progressReporter.StartTask(string.Format(CultureInfo.InvariantCulture, "\t{0}\b\b\b", Path.GetFileName(assembly))))
                {
                    try
                    {
                        var pdbPath = _fileSystem.ChangeFileExtension(assembly, "pdb");

                        if (!_fileSystem.FileExists(pdbPath))
                        {
                            _progressReporter.ReportIssue(string.Format(CultureInfo.CurrentCulture, LocalizedStrings.PdbNotFoundFormat, assembly));
                            task.Abort();
                        }
                        else
                        {
                            try
                            {
                                var sourceItems = GetSourceInfo(assembly, pdbPath, report);
                                items.AddRange(sourceItems);
                            }
                            catch (OutOfMemoryException ex)
                            {
                                // TODO: Update Microsoft.CCI to support parsing portable pdbs.
                                // Due to an OutOfMemoryException thrown when trying to parse portable pdb files.
                                // https://github.com/icsharpcode/ILSpy/issues/789
                                // There is no public build for https://github.com/Microsoft/cci yet, which supports it.
                                Trace.TraceError("OOM while trying to parse pdb file." + Environment.NewLine + ex.ToString());

                                _progressReporter.ReportIssue(string.Format(CultureInfo.CurrentCulture, LocalizedStrings.SourceLineMappingNotSupportedPortablePdb, assembly));

                                task.Abort();
                            }
                        }
                    }
                    catch (PortabilityAnalyzerException)
                    {
                        task.Abort();
                    }
                }

                var issues = _progressReporter.Issues.ToArray();

                // There were more issues reported while running this current task.
                if (currentIssues < issues.Length)
                {
                    for (int i = currentIssues; i < issues.Length; i++)
                    {
                        _textOutput.WriteLine(issues[i]);
                    }

                    currentIssues = issues.Length;
                }
            }

            return(items);
        }