示例#1
0
        public static IReadOnlyCollection <SerializableDiagnostic> ExtractSerializableDiagnosticsFromSemanticModel(
            BufferId bufferId,
            Budget budget,
            SemanticModel semanticModel,
            Workspace workspace)
        {
            var diagnostics = workspace.MapDiagnostics(bufferId, semanticModel.GetDiagnostics().ToArray(), budget);

            return(diagnostics.DiagnosticsInActiveBuffer);
        }
示例#2
0
        private async Task <(IReadOnlyCollection <SerializableDiagnostic> DiagnosticsInActiveBuffer, IReadOnlyCollection <SerializableDiagnostic> AllDiagnostics)> ExtractDiagnostics(
            Workspace workspace,
            BufferId activeBufferId,
            ScriptOptions options)
        {
            workspace = await _transformer.TransformAsync(workspace);

            var sourceFile  = workspace.GetSourceFiles().Single();
            var code        = sourceFile.Text.ToString();
            var compilation = CSharpScript.Create(code, options).GetCompilation();

            return(workspace.MapDiagnostics(
                       activeBufferId,
                       compilation.GetDiagnostics()));
        }
示例#3
0
        private async Task <CompileWorkerResult> CompileWorker(
            Workspace workspace,
            BufferId activeBufferId,
            Budget budget)
        {
            var package = await _packageFinder.Find <Package>(workspace.WorkspaceType);

            workspace = await _transformer.TransformAsync(workspace);

            var compilation = await package.Compile(workspace, budget, activeBufferId);

            var(diagnosticsInActiveBuffer, allDiagnostics) = workspace.MapDiagnostics(activeBufferId, compilation.GetDiagnostics());

            budget.RecordEntryAndThrowIfBudgetExceeded();
            return(new CompileWorkerResult(
                       compilation,
                       diagnosticsInActiveBuffer,
                       allDiagnostics));
        }
示例#4
0
        private async Task <CompileWorkerResult> CompileWorker(
            Workspace workspace,
            BufferId activeBufferId,
            Budget budget)
        {
            var package = await _packageFinder.Find <ICreateWorkspace>(workspace.WorkspaceType);

            workspace = await workspace.InlineBuffersAsync();

            var sources = workspace.GetSourceFiles();

            var(compilation, documents) = await package.GetCompilation(sources, SourceCodeKind.Regular, workspace.Usings, () => package.CreateRoslynWorkspaceAsync(budget), budget);

            var(diagnosticsInActiveBuffer, allDiagnostics) = workspace.MapDiagnostics(activeBufferId, compilation.GetDiagnostics());

            budget.RecordEntryAndThrowIfBudgetExceeded();
            return(new CompileWorkerResult(
                       compilation,
                       diagnosticsInActiveBuffer,
                       allDiagnostics));
        }