提交 2def347f 编写于 作者: S Sam Harwell

Add marker interface IInProcessAnalyzer, separate from OpenFileOnly

上级 95bdf728
......@@ -7,7 +7,7 @@
namespace Microsoft.CodeAnalysis.Editor.Implementation.RenameTracking
{
[DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)]
internal sealed class RenameTrackingDiagnosticAnalyzer : DiagnosticAnalyzer, IBuiltInAnalyzer
internal sealed class RenameTrackingDiagnosticAnalyzer : DiagnosticAnalyzer, IBuiltInAnalyzer, IInProcessAnalyzer
{
public const string DiagnosticId = "RenameTracking";
public static DiagnosticDescriptor DiagnosticDescriptor = new DiagnosticDescriptor(
......
......@@ -67,6 +67,9 @@ public static bool IsOpenFileOnly(this DiagnosticAnalyzer analyzer, Workspace wo
return false;
}
public static bool IsInProcessOnly(this DiagnosticAnalyzer analyzer)
=> analyzer is IInProcessAnalyzer;
public static bool ContainsOpenFileOnlyAnalyzers(this CompilationWithAnalyzers analyzerDriverOpt, Workspace workspace)
{
if (analyzerDriverOpt == null)
......
......@@ -13,8 +13,9 @@
namespace Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles
{
internal abstract class NamingStyleDiagnosticAnalyzerBase<TLanguageKindEnum> :
AbstractBuiltInCodeStyleDiagnosticAnalyzer where TLanguageKindEnum : struct
internal abstract class NamingStyleDiagnosticAnalyzerBase<TLanguageKindEnum>
: AbstractBuiltInCodeStyleDiagnosticAnalyzer, IInProcessAnalyzer
where TLanguageKindEnum : struct
{
private static readonly LocalizableString s_localizableMessageFormat = new LocalizableResourceString(nameof(FeaturesResources.Naming_rule_violation_0), FeaturesResources.ResourceManager, typeof(FeaturesResources));
private static readonly LocalizableString s_localizableTitleNamingStyle = new LocalizableResourceString(nameof(FeaturesResources.Naming_Styles), FeaturesResources.ResourceManager, typeof(FeaturesResources));
......
......@@ -60,12 +60,12 @@ public InProcOrRemoteHostAnalyzerRunner(DiagnosticAnalyzerService owner, Abstrac
return await AnalyzeInProcAsync(analyzerDriver, project, cancellationToken).ConfigureAwait(false);
}
// due to OpenFileOnly analyzer, we need to run inproc as well for such analyzers for fix all
// 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.
var inProcResultTask = AnalyzeInProcAsync(CreateAnalyzerDriver(analyzerDriver, a => forcedAnalysis && a.IsOpenFileOnly(project.Solution.Workspace)), project, remoteHostClient, cancellationToken);
var inProcResultTask = AnalyzeInProcAsync(CreateAnalyzerDriver(analyzerDriver, a => (forcedAnalysis || !a.IsOpenFileOnly(workspace)) && a.IsInProcessOnly()), project, remoteHostClient, cancellationToken);
// 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.
......@@ -149,7 +149,7 @@ private async Task FireAndForgetReportAnalyzerPerformanceAsync(Project project,
{
var analyzerMap = pooledObject.Object;
analyzerMap.AppendAnalyzerMap(analyzerDriver.Analyzers.Where(a => !a.IsOpenFileOnly(project.Solution.Workspace)));
analyzerMap.AppendAnalyzerMap(analyzerDriver.Analyzers.Where(a => !a.IsInProcessOnly() && (forcedAnalysis || !a.IsOpenFileOnly(solution.Workspace))));
if (analyzerMap.Count == 0)
{
return DiagnosticAnalysisResultMap.Create(ImmutableDictionary<DiagnosticAnalyzer, DiagnosticAnalysisResult>.Empty, ImmutableDictionary<DiagnosticAnalyzer, AnalyzerTelemetryInfo>.Empty);
......
......@@ -22,8 +22,6 @@ internal interface IBuiltInAnalyzer
/// <summary>
/// This indicates whether this builtin analyzer will only run on opened files.
///
/// all analyzers that want to run on closed files must be able to run in remote host.
/// </summary>
bool OpenFileOnly(Workspace workspace);
}
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.CodeAnalysis.Diagnostics
{
/// <summary>
/// A marker interface for <see cref="DiagnosticAnalyzer"/> implementations that do not support out-of-process
/// execution.
/// </summary>
internal interface IInProcessAnalyzer
{
}
}
......@@ -13,8 +13,8 @@
namespace Microsoft.CodeAnalysis.RemoveUnnecessaryImports
{
internal abstract class AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer :
DiagnosticAnalyzer, IBuiltInAnalyzer
internal abstract class AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer
: DiagnosticAnalyzer, IBuiltInAnalyzer, IInProcessAnalyzer
{
// NOTE: This is a trigger diagnostic, which doesn't show up in the ruleset editor and hence doesn't need a conventional IDE Diagnostic ID string.
internal const string DiagnosticFixableId = "RemoveUnnecessaryImportsFixable";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册