提交 82182f46 编写于 作者: S Sam Harwell

Ban the ongoing use of IInProcessAnalyzer

RenameTrackingDiagnosticAnalyzer is the only remaining in-process
analyzer, which is tracked by #35808. Use of IInProcessAnalyzer in new
locations is not allowed.
上级 0e8e4601
...@@ -29,7 +29,9 @@ internal abstract class AbstractRenameTrackingCodeFixProvider : CodeFixProvider ...@@ -29,7 +29,9 @@ internal abstract class AbstractRenameTrackingCodeFixProvider : CodeFixProvider
public sealed override ImmutableArray<string> FixableDiagnosticIds public sealed override ImmutableArray<string> FixableDiagnosticIds
{ {
#pragma warning disable CS0618 // Type or member is obsolete
get { return ImmutableArray.Create(RenameTrackingDiagnosticAnalyzer.DiagnosticId); } get { return ImmutableArray.Create(RenameTrackingDiagnosticAnalyzer.DiagnosticId); }
#pragma warning restore CS0618 // Type or member is obsolete
} }
public sealed override Task RegisterCodeFixesAsync(CodeFixContext context) public sealed override Task RegisterCodeFixesAsync(CodeFixContext context)
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // 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;
using System.Collections.Immutable; using System.Collections.Immutable;
using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Diagnostics;
using Roslyn.Utilities; using Roslyn.Utilities;
...@@ -7,6 +8,7 @@ ...@@ -7,6 +8,7 @@
namespace Microsoft.CodeAnalysis.Editor.Implementation.RenameTracking namespace Microsoft.CodeAnalysis.Editor.Implementation.RenameTracking
{ {
[DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)]
[Obsolete("https://github.com/dotnet/roslyn/issues/35808")]
internal sealed class RenameTrackingDiagnosticAnalyzer : DiagnosticAnalyzer, IBuiltInAnalyzer, IInProcessAnalyzer internal sealed class RenameTrackingDiagnosticAnalyzer : DiagnosticAnalyzer, IBuiltInAnalyzer, IInProcessAnalyzer
{ {
public const string DiagnosticId = "RenameTracking"; public const string DiagnosticId = "RenameTracking";
......
...@@ -298,8 +298,10 @@ internal async Task<IEnumerable<Diagnostic>> GetDiagnostic(SyntaxTree tree, Diag ...@@ -298,8 +298,10 @@ internal async Task<IEnumerable<Diagnostic>> GetDiagnostic(SyntaxTree tree, Diag
var textSpan = snapshotSpan.Span.ToTextSpan(); var textSpan = snapshotSpan.Span.ToTextSpan();
var builder = ImmutableDictionary.CreateBuilder<string, string>(); var builder = ImmutableDictionary.CreateBuilder<string, string>();
#pragma warning disable CS0618 // Type or member is obsolete
builder.Add(RenameTrackingDiagnosticAnalyzer.RenameFromPropertyKey, trackingSession.OriginalName); builder.Add(RenameTrackingDiagnosticAnalyzer.RenameFromPropertyKey, trackingSession.OriginalName);
builder.Add(RenameTrackingDiagnosticAnalyzer.RenameToPropertyKey, snapshotSpan.GetText()); builder.Add(RenameTrackingDiagnosticAnalyzer.RenameToPropertyKey, snapshotSpan.GetText());
#pragma warning restore CS0618 // Type or member is obsolete
var properties = builder.ToImmutable(); var properties = builder.ToImmutable();
var diagnostic = Diagnostic.Create(diagnosticDescriptor, var diagnostic = Diagnostic.Create(diagnosticDescriptor,
......
...@@ -144,8 +144,10 @@ internal static async Task<IEnumerable<Diagnostic>> GetDiagnosticsAsync(SyntaxTr ...@@ -144,8 +144,10 @@ internal static async Task<IEnumerable<Diagnostic>> GetDiagnosticsAsync(SyntaxTr
var message = string.Format( var message = string.Format(
EditorFeaturesResources.Rename_0_to_1, EditorFeaturesResources.Rename_0_to_1,
#pragma warning disable CS0618 // Type or member is obsolete
diagnostic.Properties[RenameTrackingDiagnosticAnalyzer.RenameFromPropertyKey], diagnostic.Properties[RenameTrackingDiagnosticAnalyzer.RenameFromPropertyKey],
diagnostic.Properties[RenameTrackingDiagnosticAnalyzer.RenameToPropertyKey]); diagnostic.Properties[RenameTrackingDiagnosticAnalyzer.RenameToPropertyKey]);
#pragma warning restore CS0618 // Type or member is obsolete
return new RenameTrackingCodeAction(document, message, refactorNotifyServices, undoHistoryRegistry); return new RenameTrackingCodeAction(document, message, refactorNotifyServices, undoHistoryRegistry);
} }
......
...@@ -176,7 +176,9 @@ public async Task AssertNoTag() ...@@ -176,7 +176,9 @@ public async Task AssertNoTag()
public async Task<IList<Diagnostic>> GetDocumentDiagnosticsAsync(Document document = null) public async Task<IList<Diagnostic>> GetDocumentDiagnosticsAsync(Document document = null)
{ {
document = document ?? this.Workspace.CurrentSolution.GetDocument(_hostDocument.Id); document = document ?? this.Workspace.CurrentSolution.GetDocument(_hostDocument.Id);
#pragma warning disable CS0618 // Type or member is obsolete
var analyzer = new RenameTrackingDiagnosticAnalyzer(); var analyzer = new RenameTrackingDiagnosticAnalyzer();
#pragma warning restore CS0618 // Type or member is obsolete
return (await DiagnosticProviderTestUtilities.GetDocumentDiagnosticsAsync(analyzer, document, return (await DiagnosticProviderTestUtilities.GetDocumentDiagnosticsAsync(analyzer, document,
(await document.GetSyntaxRootAsync()).FullSpan)).ToList(); (await document.GetSyntaxRootAsync()).FullSpan)).ToList();
} }
...@@ -197,7 +199,9 @@ public async Task AssertTag(string expectedFromName, string expectedToName, bool ...@@ -197,7 +199,9 @@ public async Task AssertTag(string expectedFromName, string expectedToName, bool
// There should be a single rename tracking diagnostic // There should be a single rename tracking diagnostic
Assert.Equal(1, diagnostics.Count); Assert.Equal(1, diagnostics.Count);
#pragma warning disable CS0618 // Type or member is obsolete
Assert.Equal(RenameTrackingDiagnosticAnalyzer.DiagnosticId, diagnostics[0].Id); Assert.Equal(RenameTrackingDiagnosticAnalyzer.DiagnosticId, diagnostics[0].Id);
#pragma warning restore CS0618 // Type or member is obsolete
var actions = new List<CodeAction>(); var actions = new List<CodeAction>();
var context = new CodeFixContext(document, diagnostics[0], (a, d) => actions.Add(a), CancellationToken.None); var context = new CodeFixContext(document, diagnostics[0], (a, d) => actions.Add(a), CancellationToken.None);
......
...@@ -67,6 +67,7 @@ public static bool IsOpenFileOnly(this DiagnosticAnalyzer analyzer, Workspace wo ...@@ -67,6 +67,7 @@ public static bool IsOpenFileOnly(this DiagnosticAnalyzer analyzer, Workspace wo
return false; return false;
} }
[Obsolete("In-process analyzer restrictions are obsolete.")]
public static bool IsInProcessOnly(this DiagnosticAnalyzer analyzer) public static bool IsInProcessOnly(this DiagnosticAnalyzer analyzer)
=> analyzer is IInProcessAnalyzer; => analyzer is IInProcessAnalyzer;
......
...@@ -65,7 +65,9 @@ public InProcOrRemoteHostAnalyzerRunner(DiagnosticAnalyzerService owner, Abstrac ...@@ -65,7 +65,9 @@ public InProcOrRemoteHostAnalyzerRunner(DiagnosticAnalyzerService owner, Abstrac
// //
// we have this open file analyzers since some of our built in analyzers such as SimplifyTypeNamesDiagnosticAnalyzer are too // 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. // 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); 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) // 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. // that are not part of roslyn solution. these host analyzers must be sync to OOP before hand by the Host.
...@@ -149,7 +151,9 @@ private async Task FireAndForgetReportAnalyzerPerformanceAsync(Project project, ...@@ -149,7 +151,9 @@ private async Task FireAndForgetReportAnalyzerPerformanceAsync(Project project,
{ {
var analyzerMap = pooledObject.Object; 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)))); analyzerMap.AppendAnalyzerMap(analyzerDriver.Analyzers.Where(a => !a.IsInProcessOnly() && (forcedAnalysis || !a.IsOpenFileOnly(solution.Workspace))));
#pragma warning restore CS0618 // Type or member is obsolete
if (analyzerMap.Count == 0) if (analyzerMap.Count == 0)
{ {
return DiagnosticAnalysisResultMap.Create(ImmutableDictionary<DiagnosticAnalyzer, DiagnosticAnalysisResult>.Empty, ImmutableDictionary<DiagnosticAnalyzer, AnalyzerTelemetryInfo>.Empty); return DiagnosticAnalysisResultMap.Create(ImmutableDictionary<DiagnosticAnalyzer, DiagnosticAnalysisResult>.Empty, ImmutableDictionary<DiagnosticAnalyzer, AnalyzerTelemetryInfo>.Empty);
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // 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 namespace Microsoft.CodeAnalysis.Diagnostics
{ {
/// <summary> /// <summary>
/// A marker interface for <see cref="DiagnosticAnalyzer"/> implementations that do not support out-of-process /// A marker interface for <see cref="DiagnosticAnalyzer"/> implementations that do not support out-of-process
/// execution. /// execution.
/// </summary> /// </summary>
[Obsolete("Diagnostic analyzers must not be restricted in in-process analysis.", error: true)]
internal interface IInProcessAnalyzer internal interface IInProcessAnalyzer
{ {
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册