提交 28621ea9 编写于 作者: M Manish Vasani

Feedback

上级 10422f72
...@@ -155,7 +155,7 @@ public bool TryGetTelemetryId(out Guid telemetryId) ...@@ -155,7 +155,7 @@ public bool TryGetTelemetryId(out Guid telemetryId)
ISuggestedActionCategorySet requestedActionCategories, ISuggestedActionCategorySet requestedActionCategories,
SnapshotSpan range, SnapshotSpan range,
CancellationToken cancellationToken) CancellationToken cancellationToken)
=> GetSuggestedActions(requestedActionCategories, range, addOperationScope: _ => new NoOpDisposable(), cancellationToken); => GetSuggestedActions(requestedActionCategories, range, addOperationScope: _ => null, cancellationToken);
public IEnumerable<SuggestedActionSet>? GetSuggestedActions( public IEnumerable<SuggestedActionSet>? GetSuggestedActions(
ISuggestedActionCategorySet requestedActionCategories, ISuggestedActionCategorySet requestedActionCategories,
...@@ -172,7 +172,7 @@ public bool TryGetTelemetryId(out Guid telemetryId) ...@@ -172,7 +172,7 @@ public bool TryGetTelemetryId(out Guid telemetryId)
public IEnumerable<SuggestedActionSet>? GetSuggestedActions( public IEnumerable<SuggestedActionSet>? GetSuggestedActions(
ISuggestedActionCategorySet requestedActionCategories, ISuggestedActionCategorySet requestedActionCategories,
SnapshotSpan range, SnapshotSpan range,
Func<string, IDisposable> addOperationScope, Func<string, IDisposable?> addOperationScope,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
AssertIsForeground(); AssertIsForeground();
...@@ -345,7 +345,7 @@ private SuggestedActionSet InlineActions(SuggestedActionSet actionSet) ...@@ -345,7 +345,7 @@ private SuggestedActionSet InlineActions(SuggestedActionSet actionSet)
Workspace workspace, Workspace workspace,
Document document, Document document,
SnapshotSpan range, SnapshotSpan range,
Func<string, IDisposable> addOperationScope, Func<string, IDisposable?> addOperationScope,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
this.AssertIsForeground(); this.AssertIsForeground();
...@@ -734,7 +734,7 @@ private static SuggestedActionSetPriority GetSuggestedActionSetPriority(CodeActi ...@@ -734,7 +734,7 @@ private static SuggestedActionSetPriority GetSuggestedActionSetPriority(CodeActi
Workspace workspace, Workspace workspace,
Document document, Document document,
TextSpan? selectionOpt, TextSpan? selectionOpt,
Func<string, IDisposable> addOperationScope, Func<string, IDisposable?> addOperationScope,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
this.AssertIsForeground(); this.AssertIsForeground();
......
...@@ -146,9 +146,9 @@ public Task<ImmutableArray<CodeFixCollection>> GetFixesAsync(Document document, ...@@ -146,9 +146,9 @@ public Task<ImmutableArray<CodeFixCollection>> GetFixesAsync(Document document,
=> GetFixesAsync(document, range, includeConfigurationFixes, isBlocking: false, cancellationToken); => GetFixesAsync(document, range, includeConfigurationFixes, isBlocking: false, cancellationToken);
public Task<ImmutableArray<CodeFixCollection>> GetFixesAsync(Document document, TextSpan range, bool includeConfigurationFixes, bool isBlocking, CancellationToken cancellationToken) public Task<ImmutableArray<CodeFixCollection>> GetFixesAsync(Document document, TextSpan range, bool includeConfigurationFixes, bool isBlocking, CancellationToken cancellationToken)
=> GetFixesAsync(document, range, includeConfigurationFixes, isBlocking, addOperationScope: _ => new NoOpDisposable(), cancellationToken); => GetFixesAsync(document, range, includeConfigurationFixes, isBlocking, addOperationScope: _ => null, cancellationToken);
public async Task<ImmutableArray<CodeFixCollection>> GetFixesAsync(Document document, TextSpan range, bool includeConfigurationFixes, bool isBlocking, Func<string, IDisposable> addOperationScope, CancellationToken cancellationToken) public async Task<ImmutableArray<CodeFixCollection>> GetFixesAsync(Document document, TextSpan range, bool includeConfigurationFixes, bool isBlocking, Func<string, IDisposable?> addOperationScope, CancellationToken cancellationToken)
{ {
// REVIEW: this is the first and simplest design. basically, when ctrl+. is pressed, it asks diagnostic service to give back // REVIEW: this is the first and simplest design. basically, when ctrl+. is pressed, it asks diagnostic service to give back
// current diagnostics for the given span, and it will use that to get fixes. internally diagnostic service will either return cached information // current diagnostics for the given span, and it will use that to get fixes. internally diagnostic service will either return cached information
...@@ -220,7 +220,7 @@ int GetValue(CodeFixCollection c) ...@@ -220,7 +220,7 @@ int GetValue(CodeFixCollection c)
} }
using var resultDisposer = ArrayBuilder<CodeFixCollection>.GetInstance(out var result); using var resultDisposer = ArrayBuilder<CodeFixCollection>.GetInstance(out var result);
await AppendFixesAsync(document, range, diagnostics, fixAllForInSpan: true, isBlocking: false, result, addOperationScope: _ => new NoOpDisposable(), cancellationToken).ConfigureAwait(false); await AppendFixesAsync(document, range, diagnostics, fixAllForInSpan: true, isBlocking: false, result, addOperationScope: _ => null, cancellationToken).ConfigureAwait(false);
// TODO: Just get the first fix for now until we have a way to config user's preferred fix // TODO: Just get the first fix for now until we have a way to config user's preferred fix
// https://github.com/dotnet/roslyn/issues/27066 // https://github.com/dotnet/roslyn/issues/27066
...@@ -254,7 +254,7 @@ public async Task<Document> ApplyCodeFixesForSpecificDiagnosticIdAsync(Document ...@@ -254,7 +254,7 @@ public async Task<Document> ApplyCodeFixesForSpecificDiagnosticIdAsync(Document
bool fixAllForInSpan, bool fixAllForInSpan,
bool isBlocking, bool isBlocking,
ArrayBuilder<CodeFixCollection> result, ArrayBuilder<CodeFixCollection> result,
Func<string, IDisposable> addOperationScope, Func<string, IDisposable?> addOperationScope,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
var hasAnySharedFixer = _workspaceFixersMap.TryGetValue(document.Project.Language, out var fixerMap); var hasAnySharedFixer = _workspaceFixersMap.TryGetValue(document.Project.Language, out var fixerMap);
......
...@@ -15,7 +15,7 @@ namespace Microsoft.CodeAnalysis.CodeFixes ...@@ -15,7 +15,7 @@ namespace Microsoft.CodeAnalysis.CodeFixes
internal interface ICodeFixService internal interface ICodeFixService
{ {
Task<ImmutableArray<CodeFixCollection>> GetFixesAsync(Document document, TextSpan textSpan, bool includeSuppressionFixes, bool isBlocking, CancellationToken cancellationToken); Task<ImmutableArray<CodeFixCollection>> GetFixesAsync(Document document, TextSpan textSpan, bool includeSuppressionFixes, bool isBlocking, CancellationToken cancellationToken);
Task<ImmutableArray<CodeFixCollection>> GetFixesAsync(Document document, TextSpan textSpan, bool includeSuppressionFixes, bool isBlocking, Func<string, IDisposable> addOperationScope, CancellationToken cancellationToken); Task<ImmutableArray<CodeFixCollection>> GetFixesAsync(Document document, TextSpan textSpan, bool includeSuppressionFixes, bool isBlocking, Func<string, IDisposable?> addOperationScope, CancellationToken cancellationToken);
Task<ImmutableArray<CodeFixCollection>> GetFixesAsync(Document document, TextSpan textSpan, bool includeSuppressionFixes, CancellationToken cancellationToken); Task<ImmutableArray<CodeFixCollection>> GetFixesAsync(Document document, TextSpan textSpan, bool includeSuppressionFixes, CancellationToken cancellationToken);
Task<CodeFixCollection?> GetDocumentFixAllForIdInSpanAsync(Document document, TextSpan textSpan, string diagnosticId, CancellationToken cancellationToken); Task<CodeFixCollection?> GetDocumentFixAllForIdInSpanAsync(Document document, TextSpan textSpan, string diagnosticId, CancellationToken cancellationToken);
Task<Document> ApplyCodeFixesForSpecificDiagnosticIdAsync(Document document, string diagnosticId, IProgressTracker progressTracker, CancellationToken cancellationToken); Task<Document> ApplyCodeFixesForSpecificDiagnosticIdAsync(Document document, string diagnosticId, IProgressTracker progressTracker, CancellationToken cancellationToken);
......
...@@ -109,7 +109,7 @@ private IEnumerable<CodeRefactoringProvider> GetProviders(Document document) ...@@ -109,7 +109,7 @@ private IEnumerable<CodeRefactoringProvider> GetProviders(Document document)
Document document, Document document,
TextSpan state, TextSpan state,
bool isBlocking, bool isBlocking,
Func<string, IDisposable> addOperationScope, Func<string, IDisposable?> addOperationScope,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
using (Logger.LogBlock(FunctionId.Refactoring_CodeRefactoringService_GetRefactoringsAsync, cancellationToken)) using (Logger.LogBlock(FunctionId.Refactoring_CodeRefactoringService_GetRefactoringsAsync, cancellationToken))
......
...@@ -18,6 +18,6 @@ internal interface ICodeRefactoringService ...@@ -18,6 +18,6 @@ internal interface ICodeRefactoringService
Task<ImmutableArray<CodeRefactoring>> GetRefactoringsAsync(Document document, TextSpan textSpan, bool isBlocking, CancellationToken cancellationToken); Task<ImmutableArray<CodeRefactoring>> GetRefactoringsAsync(Document document, TextSpan textSpan, bool isBlocking, CancellationToken cancellationToken);
Task<ImmutableArray<CodeRefactoring>> GetRefactoringsAsync(Document document, TextSpan textSpan, bool isBlocking, Func<string, IDisposable> addOperationScope, CancellationToken cancellationToken); Task<ImmutableArray<CodeRefactoring>> GetRefactoringsAsync(Document document, TextSpan textSpan, bool isBlocking, Func<string, IDisposable?> addOperationScope, CancellationToken cancellationToken);
} }
} }
...@@ -114,7 +114,7 @@ public async Task<bool> TryGetAsync(List<DiagnosticData> list, Func<string, IDis ...@@ -114,7 +114,7 @@ public async Task<bool> TryGetAsync(List<DiagnosticData> list, Func<string, IDis
foreach (var stateSet in _stateSets) foreach (var stateSet in _stateSets)
{ {
IDisposable disposableScope = null; IDisposable disposableScope = null;
RoslynEventSource.LogBlock? logBlock = null; RoslynEventSource.LogBlock logBlock = default;
try try
{ {
if (addOperationScopeOpt != null) if (addOperationScopeOpt != null)
...@@ -153,7 +153,7 @@ public async Task<bool> TryGetAsync(List<DiagnosticData> list, Func<string, IDis ...@@ -153,7 +153,7 @@ public async Task<bool> TryGetAsync(List<DiagnosticData> list, Func<string, IDis
} }
finally finally
{ {
logBlock?.Dispose(); logBlock.Dispose();
disposableScope?.Dispose(); disposableScope?.Dispose();
} }
} }
......
...@@ -75,7 +75,7 @@ internal interface IDiagnosticAnalyzerService ...@@ -75,7 +75,7 @@ internal interface IDiagnosticAnalyzerService
/// This can be expensive since it is force analyzing diagnostics if it doesn't have up-to-date one yet. /// This can be expensive since it is force analyzing diagnostics if it doesn't have up-to-date one yet.
/// If diagnosticIdOpt is not null, it gets diagnostics only for this given diagnosticIdOpt value /// If diagnosticIdOpt is not null, it gets diagnostics only for this given diagnosticIdOpt value
/// </summary> /// </summary>
Task<IEnumerable<DiagnosticData>> GetDiagnosticsForSpanAsync(Document document, TextSpan range, string? diagnosticIdOpt = null, bool includeSuppressedDiagnostics = false, Func<string, IDisposable>? addOperationScopeOpt = null, CancellationToken cancellationToken = default); Task<IEnumerable<DiagnosticData>> GetDiagnosticsForSpanAsync(Document document, TextSpan range, string? diagnosticIdOpt = null, bool includeSuppressedDiagnostics = false, Func<string, IDisposable?>? addOperationScopeOpt = null, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Gets a list of <see cref="DiagnosticAnalyzer"/>s for the given <see cref="Project"/> /// Gets a list of <see cref="DiagnosticAnalyzer"/>s for the given <see cref="Project"/>
......
// 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 Roslyn.Utilities
{
/// <summary>
/// Dummy no-op disposable.
/// </summary>
internal struct NoOpDisposable : IDisposable
{
public void Dispose()
{
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册