Beispiel #1
0
        private static async Task GenerateFromCompilerInvocationAsync(
            FileInfo compilerInvocationFile,
            ILsifJsonWriter lsifWriter,
            TextWriter logFile
            )
        {
            await logFile.WriteLineAsync(
                $"Processing compiler invocation from {compilerInvocationFile.FullName}..."
                );

            var compilerInvocationLoadStopwatch = Stopwatch.StartNew();
            var compilerInvocation = await CompilerInvocation.CreateFromJsonAsync(
                File.ReadAllText(compilerInvocationFile.FullName)
                );

            await logFile.WriteLineAsync(
                $"Load of the project completed in {compilerInvocationLoadStopwatch.Elapsed.ToDisplayString()}."
                );

            var generationStopwatch = Stopwatch.StartNew();
            var lsifGenerator       = new Generator(lsifWriter);

            lsifGenerator.GenerateForCompilation(
                compilerInvocation.Compilation,
                compilerInvocation.ProjectFilePath,
                compilerInvocation.LanguageServices,
                compilerInvocation.Options
                );
            await logFile.WriteLineAsync(
                $"Generation for {compilerInvocation.ProjectFilePath} completed in {generationStopwatch.Elapsed.ToDisplayString()}."
                );
        }
Beispiel #2
0
        private static async Task GenerateFromBinaryLogAsync(FileInfo binLog, ILsifJsonWriter lsifWriter, TextWriter logFile)
        {
            await logFile.WriteLineAsync($"Reading binlog {binLog.FullName}...");

            var msbuildInvocations = CompilerInvocationsReader.ReadInvocations(binLog.FullName).ToImmutableArray();

            await logFile.WriteLineAsync($"Load of the binlog complete; {msbuildInvocations.Length} invocations were found.");

            var lsifGenerator = Generator.CreateAndWriteCapabilitiesVertex(lsifWriter);

            foreach (var msbuildInvocation in msbuildInvocations)
            {
                // Convert from the MSBuild "CompilerInvocation" type to our type that we use for our JSON-input mode already.
                var invocationInfo = new CompilerInvocation.CompilerInvocationInfo
                {
                    Arguments       = msbuildInvocation.CommandLineArguments,
                    ProjectFilePath = msbuildInvocation.ProjectFilePath,
                    Tool            = msbuildInvocation.Language == Microsoft.Build.Logging.StructuredLogger.CompilerInvocation.CSharp ? "csc" : "vbc"
                };

                var compilerInvocation = await CompilerInvocation.CreateFromInvocationInfoAsync(invocationInfo);

                var generationStopwatch = Stopwatch.StartNew();
                await lsifGenerator.GenerateForCompilationAsync(compilerInvocation.Compilation, compilerInvocation.ProjectFilePath, compilerInvocation.LanguageServices, compilerInvocation.Options);

                await logFile.WriteLineAsync($"Generation for {compilerInvocation.ProjectFilePath} completed in {generationStopwatch.Elapsed.ToDisplayString()}.");
            }
        }