/
FixAllProvider.cs
60 lines (54 loc) · 2.69 KB
/
FixAllProvider.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
namespace Microsoft.CodeAnalysis.CodeFixes
{
/// <summary>
/// Implement this abstract type to provide fix all/multiple occurrences code fixes for source code problems.
/// Alternatively, you can use any of the well known fix all providers from <see cref="WellKnownFixAllProviders"/>.
/// </summary>
public abstract class FixAllProvider
{
/// <summary>
/// Gets the supported scopes for fixing all occurrences of a diagnostic.
/// By default, it returns the following scopes:
/// (a) <see cref="FixAllScope.Document"/>
/// (b) <see cref="FixAllScope.Project"/> and
/// (c) <see cref="FixAllScope.Solution"/>
/// </summary>
public virtual IEnumerable<FixAllScope> GetSupportedFixAllScopes()
{
return ImmutableArray.Create(FixAllScope.Document, FixAllScope.Project, FixAllScope.Solution);
}
/// <summary>
/// Gets the diagnostic IDs for which fix all occurrences is supported.
/// By default, it returns <see cref="CodeFixProvider.FixableDiagnosticIds"/> for the given <paramref name="originalCodeFixProvider"/>.
/// </summary>
/// <param name="originalCodeFixProvider">Original code fix provider that returned this fix all provider from <see cref="CodeFixProvider.GetFixAllProvider"/> method.</param>
public virtual IEnumerable<string> GetSupportedFixAllDiagnosticIds(CodeFixProvider originalCodeFixProvider)
{
return originalCodeFixProvider.FixableDiagnosticIds;
}
/// <summary>
/// Gets fix all occurrences fix for the given fixAllContext.
/// </summary>
public abstract Task<CodeAction> GetFixAsync(FixAllContext fixAllContext);
internal virtual Task<CodeAction> GetFixAsync(
ImmutableDictionary<Document, ImmutableArray<Diagnostic>> documentsAndDiagnosticsToFixMap,
FixAllState fixAllState, CancellationToken cancellationToken)
{
return Task.FromResult<CodeAction>(null);
}
internal virtual Task<CodeAction> GetFixAsync(
ImmutableDictionary<Project, ImmutableArray<Diagnostic>> projectsAndDiagnosticsToFixMap,
FixAllState fixAllState, CancellationToken cancellationToken)
{
return Task.FromResult<CodeAction>(null);
}
}
}