From d18ebedc0a982fb381e315622e24b8b8edd68825 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Thu, 6 Jun 2019 14:05:32 -0500 Subject: [PATCH] Remove unused interface IInProcessAnalyzer --- .../Portable/Diagnostics/AnalyzerHelper.cs | 4 -- ...alyzer.InProcOrRemoteHostAnalyzerRunner.cs | 38 +------------------ .../Diagnostics/IInProcessAnalyzer.cs | 15 -------- 3 files changed, 2 insertions(+), 55 deletions(-) delete mode 100644 src/Features/Core/Portable/Diagnostics/IInProcessAnalyzer.cs diff --git a/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs b/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs index 174347a286c..4aac4d75e06 100644 --- a/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs +++ b/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs @@ -67,10 +67,6 @@ public static bool IsOpenFileOnly(this DiagnosticAnalyzer analyzer, Workspace wo return false; } - [Obsolete("In-process analyzer restrictions are obsolete.")] - public static bool IsInProcessOnly(this DiagnosticAnalyzer analyzer) - => analyzer is IInProcessAnalyzer; - public static bool ContainsOpenFileOnlyAnalyzers(this CompilationWithAnalyzers analyzerDriverOpt, Workspace workspace) { if (analyzerDriverOpt == null) diff --git a/src/Features/Core/Portable/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer.InProcOrRemoteHostAnalyzerRunner.cs b/src/Features/Core/Portable/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer.InProcOrRemoteHostAnalyzerRunner.cs index a562f05afc9..196b786e0e0 100644 --- a/src/Features/Core/Portable/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer.InProcOrRemoteHostAnalyzerRunner.cs +++ b/src/Features/Core/Portable/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer.InProcOrRemoteHostAnalyzerRunner.cs @@ -60,29 +60,9 @@ public InProcOrRemoteHostAnalyzerRunner(DiagnosticAnalyzerService owner, Abstrac return await AnalyzeInProcAsync(analyzerDriver, project, cancellationToken).ConfigureAwait(false); } - // due to in-process only analyzers, we need to run inproc as well for such analyzers for fix all - // otherwise, we don't need to run open file only analyzers for closed files even if full solution analysis is on (perf improvement) - // - // we have this open file analyzers since some of our built in analyzers such as SimplifyTypeNamesDiagnosticAnalyzer are too - // slow to run for whole solution when full solution analysis is on. easily taking more than an hour to run whole solution. -#pragma warning disable CS0618 // Type or member is obsolete - var inProcResultTask = AnalyzeInProcAsync(CreateAnalyzerDriver(analyzerDriver, a => (forcedAnalysis || !a.IsOpenFileOnly(workspace)) && a.IsInProcessOnly()), project, remoteHostClient, cancellationToken); -#pragma warning restore CS0618 // Type or member is obsolete - // out of proc analysis will use 2 source of analyzers. one is AnalyzerReference from project (nuget). and the other is host analyzers (vsix) // that are not part of roslyn solution. these host analyzers must be sync to OOP before hand by the Host. - var outOfProcResultTask = AnalyzeOutOfProcAsync(remoteHostClient, analyzerDriver, project, forcedAnalysis, cancellationToken); - - // run them concurrently in vs and remote host - await Task.WhenAll(inProcResultTask, outOfProcResultTask).ConfigureAwait(false); - - // make sure things are not cancelled - cancellationToken.ThrowIfCancellationRequested(); - - // merge 2 results - return DiagnosticAnalysisResultMap.Create( - inProcResultTask.Result.AnalysisResult.AddRange(outOfProcResultTask.Result.AnalysisResult), - inProcResultTask.Result.TelemetryInfo.AddRange(outOfProcResultTask.Result.TelemetryInfo)); + return await AnalyzeOutOfProcAsync(remoteHostClient, analyzerDriver, project, forcedAnalysis, cancellationToken).ConfigureAwait(false); } private Task> AnalyzeInProcAsync( @@ -151,9 +131,7 @@ private async Task FireAndForgetReportAnalyzerPerformanceAsync(Project project, { var analyzerMap = pooledObject.Object; -#pragma warning disable CS0618 // Type or member is obsolete - analyzerMap.AppendAnalyzerMap(analyzerDriver.Analyzers.Where(a => !a.IsInProcessOnly() && (forcedAnalysis || !a.IsOpenFileOnly(solution.Workspace)))); -#pragma warning restore CS0618 // Type or member is obsolete + analyzerMap.AppendAnalyzerMap(analyzerDriver.Analyzers.Where(a => forcedAnalysis || !a.IsOpenFileOnly(solution.Workspace))); if (analyzerMap.Count == 0) { return DiagnosticAnalysisResultMap.Create(ImmutableDictionary.Empty, ImmutableDictionary.Empty); @@ -187,18 +165,6 @@ private async Task FireAndForgetReportAnalyzerPerformanceAsync(Project project, } } - private CompilationWithAnalyzers CreateAnalyzerDriver(CompilationWithAnalyzers analyzerDriver, Func predicate) - { - var analyzers = analyzerDriver.Analyzers.Where(predicate).ToImmutableArray(); - if (analyzers.Length == 0) - { - // return null since we can't create CompilationWithAnalyzers with 0 analyzers - return null; - } - - return analyzerDriver.Compilation.WithAnalyzers(analyzers, analyzerDriver.AnalysisOptions); - } - private CustomAsset GetOptionsAsset(Solution solution, string language, CancellationToken cancellationToken) { // TODO: we need better way to deal with options. optionSet itself is green node but diff --git a/src/Features/Core/Portable/Diagnostics/IInProcessAnalyzer.cs b/src/Features/Core/Portable/Diagnostics/IInProcessAnalyzer.cs deleted file mode 100644 index 10a19553055..00000000000 --- a/src/Features/Core/Portable/Diagnostics/IInProcessAnalyzer.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; - -namespace Microsoft.CodeAnalysis.Diagnostics -{ - /// - /// A marker interface for implementations that do not support out-of-process - /// execution. - /// - [Obsolete("Diagnostic analyzers must not be restricted in in-process analysis.", error: true)] - internal interface IInProcessAnalyzer - { - } -} -- GitLab