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

Feedback

上级 10422f72
......@@ -155,7 +155,7 @@ public bool TryGetTelemetryId(out Guid telemetryId)
ISuggestedActionCategorySet requestedActionCategories,
SnapshotSpan range,
CancellationToken cancellationToken)
=> GetSuggestedActions(requestedActionCategories, range, addOperationScope: _ => new NoOpDisposable(), cancellationToken);
=> GetSuggestedActions(requestedActionCategories, range, addOperationScope: _ => null, cancellationToken);
public IEnumerable<SuggestedActionSet>? GetSuggestedActions(
ISuggestedActionCategorySet requestedActionCategories,
......@@ -172,7 +172,7 @@ public bool TryGetTelemetryId(out Guid telemetryId)
public IEnumerable<SuggestedActionSet>? GetSuggestedActions(
ISuggestedActionCategorySet requestedActionCategories,
SnapshotSpan range,
Func<string, IDisposable> addOperationScope,
Func<string, IDisposable?> addOperationScope,
CancellationToken cancellationToken)
{
AssertIsForeground();
......@@ -345,7 +345,7 @@ private SuggestedActionSet InlineActions(SuggestedActionSet actionSet)
Workspace workspace,
Document document,
SnapshotSpan range,
Func<string, IDisposable> addOperationScope,
Func<string, IDisposable?> addOperationScope,
CancellationToken cancellationToken)
{
this.AssertIsForeground();
......@@ -734,7 +734,7 @@ private static SuggestedActionSetPriority GetSuggestedActionSetPriority(CodeActi
Workspace workspace,
Document document,
TextSpan? selectionOpt,
Func<string, IDisposable> addOperationScope,
Func<string, IDisposable?> addOperationScope,
CancellationToken cancellationToken)
{
this.AssertIsForeground();
......
......@@ -146,9 +146,9 @@ public Task<ImmutableArray<CodeFixCollection>> GetFixesAsync(Document document,
=> GetFixesAsync(document, range, includeConfigurationFixes, isBlocking: false, 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
// 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)
}
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
// https://github.com/dotnet/roslyn/issues/27066
......@@ -254,7 +254,7 @@ public async Task<Document> ApplyCodeFixesForSpecificDiagnosticIdAsync(Document
bool fixAllForInSpan,
bool isBlocking,
ArrayBuilder<CodeFixCollection> result,
Func<string, IDisposable> addOperationScope,
Func<string, IDisposable?> addOperationScope,
CancellationToken cancellationToken)
{
var hasAnySharedFixer = _workspaceFixersMap.TryGetValue(document.Project.Language, out var fixerMap);
......
......@@ -15,7 +15,7 @@ namespace Microsoft.CodeAnalysis.CodeFixes
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, 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<CodeFixCollection?> GetDocumentFixAllForIdInSpanAsync(Document document, TextSpan textSpan, string diagnosticId, CancellationToken cancellationToken);
Task<Document> ApplyCodeFixesForSpecificDiagnosticIdAsync(Document document, string diagnosticId, IProgressTracker progressTracker, CancellationToken cancellationToken);
......
......@@ -109,7 +109,7 @@ private IEnumerable<CodeRefactoringProvider> GetProviders(Document document)
Document document,
TextSpan state,
bool isBlocking,
Func<string, IDisposable> addOperationScope,
Func<string, IDisposable?> addOperationScope,
CancellationToken cancellationToken)
{
using (Logger.LogBlock(FunctionId.Refactoring_CodeRefactoringService_GetRefactoringsAsync, cancellationToken))
......
......@@ -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, 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
foreach (var stateSet in _stateSets)
{
IDisposable disposableScope = null;
RoslynEventSource.LogBlock? logBlock = null;
RoslynEventSource.LogBlock logBlock = default;
try
{
if (addOperationScopeOpt != null)
......@@ -153,7 +153,7 @@ public async Task<bool> TryGetAsync(List<DiagnosticData> list, Func<string, IDis
}
finally
{
logBlock?.Dispose();
logBlock.Dispose();
disposableScope?.Dispose();
}
}
......
......@@ -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.
/// If diagnosticIdOpt is not null, it gets diagnostics only for this given diagnosticIdOpt value
/// </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>
/// 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.
先完成此消息的编辑!
想要评论请 注册