From 0512fd58726da1f948ffee94fab9ba5afeadcb07 Mon Sep 17 00:00:00 2001 From: Tanay Parikh Date: Fri, 9 Oct 2020 16:31:50 -0700 Subject: [PATCH 1/6] WIP --- .../AbstractAddAwaitCodeRefactoringProvider.cs | 2 +- .../Handler/CodeActions/CodeActionHelpers.cs | 2 +- .../Handler/CodeActions/CodeActionResolveData.cs | 11 ++++++++++- .../Core/Portable/CodeActions/CodeAction.cs | 16 +++++++++++++--- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/Features/Core/Portable/CodeRefactorings/AddAwait/AbstractAddAwaitCodeRefactoringProvider.cs b/src/Features/Core/Portable/CodeRefactorings/AddAwait/AbstractAddAwaitCodeRefactoringProvider.cs index be1977c9faa77..5d19a0c9c7e0d 100644 --- a/src/Features/Core/Portable/CodeRefactorings/AddAwait/AbstractAddAwaitCodeRefactoringProvider.cs +++ b/src/Features/Core/Portable/CodeRefactorings/AddAwait/AbstractAddAwaitCodeRefactoringProvider.cs @@ -107,7 +107,7 @@ private static async Task AddAwaitAsync( private class MyCodeAction : CodeAction.DocumentChangeAction { public MyCodeAction(string title, Func> createChangedDocument) - : base(title, createChangedDocument) + : base(title, createChangedDocument, providerName: nameof(AbstractAddAwaitCodeRefactoringProvider)) { } } diff --git a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionHelpers.cs b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionHelpers.cs index 149935d35de89..dd993d6a83baa 100644 --- a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionHelpers.cs +++ b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionHelpers.cs @@ -92,7 +92,7 @@ private static VSCodeAction GenerateVSCodeAction( Kind = codeActionKind, Diagnostics = request.Context.Diagnostics, Children = nestedActions.ToArray(), - Data = new CodeActionResolveData(currentTitle, request.Range, request.TextDocument) + Data = new CodeActionResolveData(currentTitle, codeAction.ProviderName, request.Range, request.TextDocument) }; } diff --git a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveData.cs b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveData.cs index 26820d56a6c88..c2e2601128026 100644 --- a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveData.cs +++ b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveData.cs @@ -25,13 +25,22 @@ internal class CodeActionResolveData /// public string UniqueIdentifier { get; } + /// + /// Identifies the Code Action Provider which produced this Code Action. + /// + /// + /// e.g. 'Add Await Code Action Provider' + /// + public string ProviderName { get; } + public LSP.Range Range { get; } public LSP.TextDocumentIdentifier TextDocument { get; } - public CodeActionResolveData(string uniqueIdentifier, LSP.Range range, LSP.TextDocumentIdentifier textDocument) + public CodeActionResolveData(string uniqueIdentifier, string providerName, LSP.Range range, LSP.TextDocumentIdentifier textDocument) { UniqueIdentifier = uniqueIdentifier; + ProviderName = providerName; Range = range; TextDocument = textDocument; } diff --git a/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs b/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs index 3123491d9b499..2c8e1f1d669bd 100644 --- a/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs +++ b/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs @@ -52,6 +52,14 @@ public abstract class CodeAction /// public virtual string? EquivalenceKey => null; + /// + /// Identifies the Code Action Provider which produced this Code Action. + /// + /// + /// e.g. 'Add Await Code Action Provider' + /// + public virtual string? ProviderName => null; + internal virtual bool IsInlinable => false; internal virtual CodeActionPriority Priority => CodeActionPriority.Medium; @@ -358,14 +366,16 @@ public static CodeAction Create(string title, ImmutableArray nestedA internal abstract class SimpleCodeAction : CodeAction { - public SimpleCodeAction(string title, string? equivalenceKey) + public SimpleCodeAction(string title, string? equivalenceKey, string? providerName = null) { Title = title; EquivalenceKey = equivalenceKey; + ProviderName = providerName; } public sealed override string Title { get; } public sealed override string? EquivalenceKey { get; } + public sealed override string? ProviderName { get; } } internal class CodeActionWithNestedActions : SimpleCodeAction @@ -410,8 +420,8 @@ internal class DocumentChangeAction : SimpleCodeAction { private readonly Func> _createChangedDocument; - public DocumentChangeAction(string title, Func> createChangedDocument, string? equivalenceKey = null) - : base(title, equivalenceKey) + public DocumentChangeAction(string title, Func> createChangedDocument, string? equivalenceKey = null, string? providerName = null) + : base(title, equivalenceKey, providerName) { _createChangedDocument = createChangedDocument; } From a637d1737890f75099712e01104fa4e2018ebc19 Mon Sep 17 00:00:00 2001 From: Tanay Parikh Date: Tue, 27 Oct 2020 11:13:14 -0700 Subject: [PATCH 2/6] Provider, Implementation --- .../AbstractLanguageServerProtocolTests.cs | 4 ++-- .../AbstractAddAwaitCodeRefactoringProvider.cs | 10 ++++++---- .../Handler/CodeActions/CodeActionResolveData.cs | 4 +++- src/Workspaces/Core/Portable/CodeActions/CodeAction.cs | 8 ++++++++ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs b/src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs index 1f595d1157f3e..0248ff894ded6 100644 --- a/src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs +++ b/src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs @@ -261,8 +261,8 @@ protected static LSP.VSCompletionItem CreateCompletionItem( return item; } - private protected static CodeActionResolveData CreateCodeActionResolveData(string uniqueIdentifier, LSP.Location location) - => new CodeActionResolveData(uniqueIdentifier, location.Range, CreateTextDocumentIdentifier(location.Uri)); + private protected static CodeActionResolveData CreateCodeActionResolveData(string uniqueIdentifier, LSP.Location location, string providerName = null) + => new CodeActionResolveData(uniqueIdentifier, providerName ?? string.Empty, location.Range, CreateTextDocumentIdentifier(location.Uri)); /// /// Creates a solution with a document. diff --git a/src/Features/Core/Portable/CodeRefactorings/AddAwait/AbstractAddAwaitCodeRefactoringProvider.cs b/src/Features/Core/Portable/CodeRefactorings/AddAwait/AbstractAddAwaitCodeRefactoringProvider.cs index 5d19a0c9c7e0d..e694ef4c66fd4 100644 --- a/src/Features/Core/Portable/CodeRefactorings/AddAwait/AbstractAddAwaitCodeRefactoringProvider.cs +++ b/src/Features/Core/Portable/CodeRefactorings/AddAwait/AbstractAddAwaitCodeRefactoringProvider.cs @@ -46,13 +46,15 @@ public sealed override async Task ComputeRefactoringsAsync(CodeRefactoringContex context.RegisterRefactoring( new MyCodeAction( GetTitle(), - c => AddAwaitAsync(document, awaitable, withConfigureAwait: false, c)), + c => AddAwaitAsync(document, awaitable, withConfigureAwait: false, c), + CodeAction.CreateProviderName(PredefinedCodeRefactoringProviderNames.AddAwait, nameof(GetTitle))), awaitable.Span); context.RegisterRefactoring( new MyCodeAction( GetTitleWithConfigureAwait(), - c => AddAwaitAsync(document, awaitable, withConfigureAwait: true, c)), + c => AddAwaitAsync(document, awaitable, withConfigureAwait: true, c), + CodeAction.CreateProviderName(PredefinedCodeRefactoringProviderNames.AddAwait, nameof(GetTitleWithConfigureAwait))), awaitable.Span); } @@ -106,8 +108,8 @@ private static async Task AddAwaitAsync( private class MyCodeAction : CodeAction.DocumentChangeAction { - public MyCodeAction(string title, Func> createChangedDocument) - : base(title, createChangedDocument, providerName: nameof(AbstractAddAwaitCodeRefactoringProvider)) + public MyCodeAction(string title, Func> createChangedDocument, string providerName) + : base(title, createChangedDocument, providerName: providerName) { } } diff --git a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveData.cs b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveData.cs index c2e2601128026..95dc57274368d 100644 --- a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveData.cs +++ b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveData.cs @@ -29,7 +29,9 @@ internal class CodeActionResolveData /// Identifies the Code Action Provider which produced this Code Action. /// /// - /// e.g. 'Add Await Code Action Provider' + /// The unique identifier is currently set as: + /// name of top level code action provider + '|' + name of code action provider implementation + /// e.g. 'Add Await Code Action Provider | GetTitleWithConfigureAwait' /// public string ProviderName { get; } diff --git a/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs b/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs index 2c8e1f1d669bd..73077ac2e87b0 100644 --- a/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs +++ b/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs @@ -364,6 +364,14 @@ public static CodeAction Create(string title, ImmutableArray nestedA return new CodeActionWithNestedActions(title, nestedActions, isInlinable); } + /// + /// Creates a code action provider name. + /// + /// Specific Code Action Provider ( or implementation) of the group. + /// Specific Code Action implementation from the Code Action Provider. + public static string CreateProviderName(string provider, string implementation) + => string.Join("|", provider, implementation); + internal abstract class SimpleCodeAction : CodeAction { public SimpleCodeAction(string title, string? equivalenceKey, string? providerName = null) From a52b3c0885d5aadfe7d8a2242f54c7dd89786e9d Mon Sep 17 00:00:00 2001 From: Tanay Parikh Date: Thu, 12 Nov 2020 15:54:02 -0500 Subject: [PATCH 3/6] Feedback --- .../Portable/Microsoft.CodeAnalysis.Features.csproj | 1 + .../Handler/CodeActions/CodeActionResolveData.cs | 4 ++-- .../CSharpPredefinedCodeRefactoringProviderNames.cs | 13 +++++++++++++ .../Core/Portable/CodeActions/CodeAction.cs | 10 +--------- 4 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 src/Tools/ExternalAccess/Razor/CSharpPredefinedCodeRefactoringProviderNames.cs diff --git a/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj b/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj index 2f6152cf06398..47ccac7fafcf8 100644 --- a/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj +++ b/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj @@ -25,6 +25,7 @@ + diff --git a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveData.cs b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveData.cs index 41c866c3da5bf..022904c17bc70 100644 --- a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveData.cs +++ b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveData.cs @@ -28,8 +28,8 @@ internal class CodeActionResolveData /// /// /// The unique identifier is currently set as: - /// name of top level code action provider + '|' + name of code action provider implementation - /// e.g. 'Add Await Code Action Provider | GetTitleWithConfigureAwait' + /// name of the code action provider + /// e.g. 'Add Await Code Action Provider' /// public string ProviderName { get; } diff --git a/src/Tools/ExternalAccess/Razor/CSharpPredefinedCodeRefactoringProviderNames.cs b/src/Tools/ExternalAccess/Razor/CSharpPredefinedCodeRefactoringProviderNames.cs new file mode 100644 index 0000000000000..dc7ab99120789 --- /dev/null +++ b/src/Tools/ExternalAccess/Razor/CSharpPredefinedCodeRefactoringProviderNames.cs @@ -0,0 +1,13 @@ +// 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 Microsoft.CodeAnalysis.CodeRefactorings; + +namespace Microsoft.CodeAnalysis.ExternalAccess.Razor +{ + internal static class CSharpPredefinedCodeRefactoringProviderNames + { + public static string AddAwait => PredefinedCodeRefactoringProviderNames.AddAwait; + } +} diff --git a/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs b/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs index 73077ac2e87b0..50942c7713f02 100644 --- a/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs +++ b/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs @@ -58,7 +58,7 @@ public abstract class CodeAction /// /// e.g. 'Add Await Code Action Provider' /// - public virtual string? ProviderName => null; + internal virtual string? ProviderName => null; internal virtual bool IsInlinable => false; @@ -364,14 +364,6 @@ public static CodeAction Create(string title, ImmutableArray nestedA return new CodeActionWithNestedActions(title, nestedActions, isInlinable); } - /// - /// Creates a code action provider name. - /// - /// Specific Code Action Provider ( or implementation) of the group. - /// Specific Code Action implementation from the Code Action Provider. - public static string CreateProviderName(string provider, string implementation) - => string.Join("|", provider, implementation); - internal abstract class SimpleCodeAction : CodeAction { public SimpleCodeAction(string title, string? equivalenceKey, string? providerName = null) From f477ac0bd9386325c09a20edcd2de7a7657b9cae Mon Sep 17 00:00:00 2001 From: Tanay Parikh Date: Thu, 12 Nov 2020 15:58:29 -0500 Subject: [PATCH 4/6] Fix missing func --- .../AbstractAddAwaitCodeRefactoringProvider.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Features/Core/Portable/CodeRefactorings/AddAwait/AbstractAddAwaitCodeRefactoringProvider.cs b/src/Features/Core/Portable/CodeRefactorings/AddAwait/AbstractAddAwaitCodeRefactoringProvider.cs index e694ef4c66fd4..a4c229a296042 100644 --- a/src/Features/Core/Portable/CodeRefactorings/AddAwait/AbstractAddAwaitCodeRefactoringProvider.cs +++ b/src/Features/Core/Portable/CodeRefactorings/AddAwait/AbstractAddAwaitCodeRefactoringProvider.cs @@ -46,15 +46,13 @@ public sealed override async Task ComputeRefactoringsAsync(CodeRefactoringContex context.RegisterRefactoring( new MyCodeAction( GetTitle(), - c => AddAwaitAsync(document, awaitable, withConfigureAwait: false, c), - CodeAction.CreateProviderName(PredefinedCodeRefactoringProviderNames.AddAwait, nameof(GetTitle))), + c => AddAwaitAsync(document, awaitable, withConfigureAwait: false, c)), awaitable.Span); context.RegisterRefactoring( new MyCodeAction( GetTitleWithConfigureAwait(), - c => AddAwaitAsync(document, awaitable, withConfigureAwait: true, c), - CodeAction.CreateProviderName(PredefinedCodeRefactoringProviderNames.AddAwait, nameof(GetTitleWithConfigureAwait))), + c => AddAwaitAsync(document, awaitable, withConfigureAwait: true, c)), awaitable.Span); } @@ -108,8 +106,8 @@ private static async Task AddAwaitAsync( private class MyCodeAction : CodeAction.DocumentChangeAction { - public MyCodeAction(string title, Func> createChangedDocument, string providerName) - : base(title, createChangedDocument, providerName: providerName) + public MyCodeAction(string title, Func> createChangedDocument) + : base(title, createChangedDocument, providerName: PredefinedCodeRefactoringProviderNames.AddAwait) { } } From a16be50f92645feae7415105e8cd9666c1db776c Mon Sep 17 00:00:00 2001 From: Tanay Parikh Date: Mon, 16 Nov 2020 13:31:19 -0500 Subject: [PATCH 5/6] WIP --- ...oringProvider.ConstructorDelegatingCodeAction.cs | 3 +++ ...RefactoringProvider.FieldDelegatingCodeAction.cs | 3 +++ ...vider.GenerateConstructorWithDialogCodeAction.cs | 3 +++ ...AbstractImplementAbstractClassCodeFixProvider.cs | 2 +- .../AbstractImplementInterfaceService.CodeAction.cs | 3 ++- .../CSharpPredefinedCodeRefactoringProviderNames.cs | 13 ------------- .../Core/Portable/CodeActions/CodeAction.cs | 2 +- 7 files changed, 13 insertions(+), 16 deletions(-) delete mode 100644 src/Tools/ExternalAccess/Razor/CSharpPredefinedCodeRefactoringProviderNames.cs diff --git a/src/Features/Core/Portable/GenerateConstructorFromMembers/AbstractGenerateConstructorFromMembersCodeRefactoringProvider.ConstructorDelegatingCodeAction.cs b/src/Features/Core/Portable/GenerateConstructorFromMembers/AbstractGenerateConstructorFromMembersCodeRefactoringProvider.ConstructorDelegatingCodeAction.cs index 4b8e245cd866e..61e3ceeefb3e1 100644 --- a/src/Features/Core/Portable/GenerateConstructorFromMembers/AbstractGenerateConstructorFromMembersCodeRefactoringProvider.ConstructorDelegatingCodeAction.cs +++ b/src/Features/Core/Portable/GenerateConstructorFromMembers/AbstractGenerateConstructorFromMembersCodeRefactoringProvider.ConstructorDelegatingCodeAction.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.CodeGeneration; +using Microsoft.CodeAnalysis.CodeRefactorings; using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; @@ -25,6 +26,8 @@ private class ConstructorDelegatingCodeAction : CodeAction private readonly State _state; private readonly bool _addNullChecks; + internal override string ProviderName => PredefinedCodeRefactoringProviderNames.GenerateConstructorFromMembers; + public ConstructorDelegatingCodeAction( AbstractGenerateConstructorFromMembersCodeRefactoringProvider service, Document document, diff --git a/src/Features/Core/Portable/GenerateConstructorFromMembers/AbstractGenerateConstructorFromMembersCodeRefactoringProvider.FieldDelegatingCodeAction.cs b/src/Features/Core/Portable/GenerateConstructorFromMembers/AbstractGenerateConstructorFromMembersCodeRefactoringProvider.FieldDelegatingCodeAction.cs index beecbfcfc1634..312f7745ce90a 100644 --- a/src/Features/Core/Portable/GenerateConstructorFromMembers/AbstractGenerateConstructorFromMembersCodeRefactoringProvider.FieldDelegatingCodeAction.cs +++ b/src/Features/Core/Portable/GenerateConstructorFromMembers/AbstractGenerateConstructorFromMembersCodeRefactoringProvider.FieldDelegatingCodeAction.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.CodeGeneration; +using Microsoft.CodeAnalysis.CodeRefactorings; using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.Shared.Extensions; @@ -24,6 +25,8 @@ private class FieldDelegatingCodeAction : CodeAction private readonly State _state; private readonly bool _addNullChecks; + internal override string ProviderName => PredefinedCodeRefactoringProviderNames.GenerateConstructorFromMembers; + public FieldDelegatingCodeAction( AbstractGenerateConstructorFromMembersCodeRefactoringProvider service, Document document, diff --git a/src/Features/Core/Portable/GenerateConstructorFromMembers/AbstractGenerateConstructorFromMembersCodeRefactoringProvider.GenerateConstructorWithDialogCodeAction.cs b/src/Features/Core/Portable/GenerateConstructorFromMembers/AbstractGenerateConstructorFromMembersCodeRefactoringProvider.GenerateConstructorWithDialogCodeAction.cs index 475e45e50cc64..8fd0bfbd4954a 100644 --- a/src/Features/Core/Portable/GenerateConstructorFromMembers/AbstractGenerateConstructorFromMembersCodeRefactoringProvider.GenerateConstructorWithDialogCodeAction.cs +++ b/src/Features/Core/Portable/GenerateConstructorFromMembers/AbstractGenerateConstructorFromMembersCodeRefactoringProvider.GenerateConstructorWithDialogCodeAction.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.GenerateFromMembers; +using Microsoft.CodeAnalysis.CodeRefactorings; using Microsoft.CodeAnalysis.PickMembers; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; @@ -29,6 +30,8 @@ private class GenerateConstructorWithDialogCodeAction : CodeActionWithOptions private bool? _addNullCheckOptionValue; + internal override string ProviderName => PredefinedCodeRefactoringProviderNames.GenerateConstructorFromMembers; + public override string Title => FeaturesResources.Generate_constructor; public GenerateConstructorWithDialogCodeAction( diff --git a/src/Features/Core/Portable/ImplementAbstractClass/AbstractImplementAbstractClassCodeFixProvider.cs b/src/Features/Core/Portable/ImplementAbstractClass/AbstractImplementAbstractClassCodeFixProvider.cs index ae201af95dac2..c0f17b5966972 100644 --- a/src/Features/Core/Portable/ImplementAbstractClass/AbstractImplementAbstractClassCodeFixProvider.cs +++ b/src/Features/Core/Portable/ImplementAbstractClass/AbstractImplementAbstractClassCodeFixProvider.cs @@ -73,7 +73,7 @@ private static string GetCodeActionId(string assemblyName, string abstractTypeFu private class MyCodeAction : CodeAction.DocumentChangeAction { public MyCodeAction(string title, Func> createChangedDocument, string id) - : base(title, createChangedDocument, id) + : base(title, createChangedDocument, id, providerName: PredefinedCodeFixProviderNames.ImplementAbstractClass) { } } diff --git a/src/Features/Core/Portable/ImplementInterface/AbstractImplementInterfaceService.CodeAction.cs b/src/Features/Core/Portable/ImplementInterface/AbstractImplementInterfaceService.CodeAction.cs index 7d1ba6154ece9..1d7691fe935ea 100644 --- a/src/Features/Core/Portable/ImplementInterface/AbstractImplementInterfaceService.CodeAction.cs +++ b/src/Features/Core/Portable/ImplementInterface/AbstractImplementInterfaceService.CodeAction.cs @@ -12,6 +12,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeActions; +using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.CodeGeneration; using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.ImplementType; @@ -35,7 +36,7 @@ internal partial class ImplementInterfaceCodeAction : CodeAction protected readonly State State; protected readonly AbstractImplementInterfaceService Service; private readonly string _equivalenceKey; - + internal override string ProviderName => PredefinedCodeFixProviderNames.ImplementInterface; internal ImplementInterfaceCodeAction( AbstractImplementInterfaceService service, Document document, diff --git a/src/Tools/ExternalAccess/Razor/CSharpPredefinedCodeRefactoringProviderNames.cs b/src/Tools/ExternalAccess/Razor/CSharpPredefinedCodeRefactoringProviderNames.cs deleted file mode 100644 index dc7ab99120789..0000000000000 --- a/src/Tools/ExternalAccess/Razor/CSharpPredefinedCodeRefactoringProviderNames.cs +++ /dev/null @@ -1,13 +0,0 @@ -// 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 Microsoft.CodeAnalysis.CodeRefactorings; - -namespace Microsoft.CodeAnalysis.ExternalAccess.Razor -{ - internal static class CSharpPredefinedCodeRefactoringProviderNames - { - public static string AddAwait => PredefinedCodeRefactoringProviderNames.AddAwait; - } -} diff --git a/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs b/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs index 50942c7713f02..411815c93b016 100644 --- a/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs +++ b/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs @@ -375,7 +375,7 @@ public SimpleCodeAction(string title, string? equivalenceKey, string? providerNa public sealed override string Title { get; } public sealed override string? EquivalenceKey { get; } - public sealed override string? ProviderName { get; } + internal sealed override string? ProviderName { get; } } internal class CodeActionWithNestedActions : SimpleCodeAction From c109013b648387f7b9d22ae90e374e26bad82551 Mon Sep 17 00:00:00 2001 From: Tanay Parikh Date: Mon, 16 Nov 2020 15:48:10 -0500 Subject: [PATCH 6/6] External Access --- .../RazorPredefinedCodeFixProviderNames.cs | 17 +++++++++++++++++ ...zorPredefinedCodeRefactoringProviderNames.cs | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/Tools/ExternalAccess/Razor/RazorPredefinedCodeFixProviderNames.cs create mode 100644 src/Tools/ExternalAccess/Razor/RazorPredefinedCodeRefactoringProviderNames.cs diff --git a/src/Tools/ExternalAccess/Razor/RazorPredefinedCodeFixProviderNames.cs b/src/Tools/ExternalAccess/Razor/RazorPredefinedCodeFixProviderNames.cs new file mode 100644 index 0000000000000..2962083e49ecf --- /dev/null +++ b/src/Tools/ExternalAccess/Razor/RazorPredefinedCodeFixProviderNames.cs @@ -0,0 +1,17 @@ +// 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 Microsoft.CodeAnalysis.CodeFixes; + +namespace Microsoft.CodeAnalysis.ExternalAccess.Razor +{ + internal static class CSharpPredefinedCodefixProviderNames + { + public static string ImplementAbstractClass => PredefinedCodeFixProviderNames.ImplementAbstractClass; + public static string ImplementInterface => PredefinedCodeFixProviderNames.ImplementInterface; + public static string SpellCheck => PredefinedCodeFixProviderNames.SpellCheck; + public static string FullyQualify => PredefinedCodeFixProviderNames.FullyQualify; + public static string AddImport => PredefinedCodeFixProviderNames.AddImport; + } +} diff --git a/src/Tools/ExternalAccess/Razor/RazorPredefinedCodeRefactoringProviderNames.cs b/src/Tools/ExternalAccess/Razor/RazorPredefinedCodeRefactoringProviderNames.cs new file mode 100644 index 0000000000000..2019f28e03d9d --- /dev/null +++ b/src/Tools/ExternalAccess/Razor/RazorPredefinedCodeRefactoringProviderNames.cs @@ -0,0 +1,17 @@ +// 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 Microsoft.CodeAnalysis.CodeRefactorings; + +namespace Microsoft.CodeAnalysis.ExternalAccess.Razor +{ + internal static class CSharpPredefinedCodeRefactoringProviderNames + { + public static string AddAwait => PredefinedCodeRefactoringProviderNames.AddAwait; + public static string GenerateConstructorFromMembers => PredefinedCodeRefactoringProviderNames.GenerateConstructorFromMembers; + public static string GenerateDefaultConstructors => PredefinedCodeRefactoringProviderNames.GenerateDefaultConstructors; + public static string GenerateEqualsAndGetHashCodeFromMembers => PredefinedCodeRefactoringProviderNames.GenerateEqualsAndGetHashCodeFromMembers; + + } +}