Пример #1
0
        /// <summary>
        /// Logs detailed information about this invocation,
        /// in the event that errors were detected.
        /// </summary>
        /// <returns>A Boolean indicating whether to proceed with extraction.</returns>
        public void LogDiagnostics()
        {
            foreach (var error in FilteredDiagnostics)
            {
                Logger.Log(Severity.Error, "  Compilation error: {0}", error);
            }

            if (FilteredDiagnostics.Any())
            {
                foreach (var reference in compilation.References)
                {
                    Logger.Log(Severity.Info, "  Resolved reference {0}", reference.Display);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Initialize the analyser.
        /// </summary>
        /// <param name="commandLineArguments">Arguments passed to csc.</param>
        /// <param name="compilationIn">The Roslyn compilation.</param>
        /// <param name="options">Extractor options.</param>
        /// <param name="roslynArgs">The arguments passed to Roslyn.</param>
        public void Initialize(
            CSharpCommandLineArguments commandLineArguments,
            CSharpCompilation compilationIn,
            Options options,
            string[] roslynArgs)
        {
            compilation = compilationIn;

            layout       = new Layout();
            this.options = options;

            extractor = new Extraction.Extractor(false, GetOutputName(compilation, commandLineArguments), Logger);

            LogDiagnostics(roslynArgs);
            SetReferencePaths();

            CompilationErrors += FilteredDiagnostics.Count();
        }
Пример #3
0
        /// <summary>
        /// End initialization of the analyser.
        /// </summary>
        /// <param name="commandLineArguments">Arguments passed to csc.</param>
        /// <param name="options">Extractor options.</param>
        /// <param name="compilation">The Roslyn compilation.</param>
        /// <returns>A Boolean indicating whether to proceed with extraction.</returns>
        public void EndInitialize(
            CSharpCommandLineArguments commandLineArguments,
            CommonOptions options,
            CSharpCompilation compilation)
        {
            if (!init)
            {
                throw new InternalError("EndInitialize called without BeginInitialize returning true");
            }
            this.options     = options;
            this.compilation = compilation;
            this.extractor   = new TracingExtractor(GetOutputName(compilation, commandLineArguments), Logger, PathTransformer, options);
            LogDiagnostics();

            SetReferencePaths();

            CompilationErrors += FilteredDiagnostics.Count();
        }
Пример #4
0
        /// <summary>
        /// End initialization of the analyser.
        /// </summary>
        /// <param name="commandLineArguments">Arguments passed to csc.</param>
        /// <param name="options">Extractor options.</param>
        /// <param name="compilation">The Roslyn compilation.</param>
        /// <returns>A Boolean indicating whether to proceed with extraction.</returns>
        public void EndInitialize(
            CSharpCommandLineArguments commandLineArguments,
            Options options,
            CSharpCompilation compilation)
        {
            if (!init)
            {
                throw new InternalError("EndInitialize called without BeginInitialize returning true");
            }
            layout           = new Layout();
            this.options     = options;
            this.compilation = compilation;
            extractor        = new Extraction.Extractor(false, GetOutputName(compilation, commandLineArguments), Logger);
            LogDiagnostics();

            SetReferencePaths();

            CompilationErrors += FilteredDiagnostics.Count();
        }
Пример #5
0
        /// <summary>
        /// Logs detailed information about this invocation,
        /// in the event that errors were detected.
        /// </summary>
        /// <param name="roslynArgs">The arguments passed to Roslyn.</param>
        public void LogDiagnostics(string[] roslynArgs)
        {
            Logger.Log(Severity.Info, "  Extractor: {0}", Environment.GetCommandLineArgs().First());
            if (extractor != null)
            {
                Logger.Log(Severity.Info, "  Extractor version: {0}", extractor.Version);
            }

            Logger.Log(Severity.Info, "  Current working directory: {0}", Directory.GetCurrentDirectory());

            if (roslynArgs != null)
            {
                Logger.Log(Severity.Info, $"  Arguments to Roslyn: {string.Join(' ', roslynArgs)}");

                // Create a new file in the log folder.
                var argsFile = Path.Combine(Extractor.GetCSharpLogDirectory(), $"csharp.{Path.GetRandomFileName()}.txt");

                if (roslynArgs.ArchiveCommandLine(argsFile))
                {
                    Logger.Log(Severity.Info, $"  Arguments have been written to {argsFile}");
                }
            }

            foreach (var error in FilteredDiagnostics)
            {
                Logger.Log(Severity.Error, "  Compilation error: {0}", error);
            }

            if (FilteredDiagnostics.Any())
            {
                foreach (var reference in compilation.References)
                {
                    Logger.Log(Severity.Info, "  Resolved reference {0}", reference.Display);
                }
            }
        }