Example #1
0
        private static void AnalyseStandalone(
            StandaloneAnalyser analyser,
            IEnumerable <string> sources,
            IEnumerable <string> referencePaths,
            CommonOptions options,
            IProgressMonitor progressMonitor,
            Stopwatch stopwatch)
        {
            CSharp.Extractor.Analyse(stopwatch, analyser, options,
                                     references => GetResolvedReferencesStandalone(referencePaths, references),
                                     (analyser, syntaxTrees) => CSharp.Extractor.ReadSyntaxTrees(sources, analyser, null, null, syntaxTrees),
                                     (syntaxTrees, references) => CSharpCompilation.Create("csharp.dll", syntaxTrees, references),
                                     (compilation, options) => analyser.Initialize(compilation, options),
                                     () => { },
                                     _ => { },
                                     () =>
            {
                foreach (var type in analyser.MissingNamespaces)
                {
                    progressMonitor.MissingNamespace(type);
                }

                foreach (var type in analyser.MissingTypes)
                {
                    progressMonitor.MissingType(type);
                }

                progressMonitor.MissingSummary(analyser.MissingTypes.Count(), analyser.MissingNamespaces.Count());
            });
        }
Example #2
0
        private static void ExtractStandalone(
            IEnumerable <string> sources,
            IEnumerable <string> referencePaths,
            IProgressMonitor pm,
            ILogger logger,
            CommonOptions options)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            var canonicalPathCache = CanonicalPathCache.Create(logger, 1000);
            var pathTransformer    = new PathTransformer(canonicalPathCache);

            using var analyser = new StandaloneAnalyser(pm, logger, false, pathTransformer);
            try
            {
                AnalyseStandalone(analyser, sources, referencePaths, options, pm, stopwatch);
            }
            catch (Exception ex)  // lgtm[cs/catch-of-all-exceptions]
            {
                analyser.Logger.Log(Severity.Error, "  Unhandled exception: {0}", ex);
            }
        }