diff --git a/src/EditorFeatures/CSharp/BlockCommentEditing/BlockCommentEditingCommandHandler.cs b/src/EditorFeatures/CSharp/BlockCommentEditing/BlockCommentEditingCommandHandler.cs index c4e2ab6822aff20cce774174582a663ca68ae6aa..68a2bb77ded067e19582dff011236bd6b1239ff6 100644 --- a/src/EditorFeatures/CSharp/BlockCommentEditing/BlockCommentEditingCommandHandler.cs +++ b/src/EditorFeatures/CSharp/BlockCommentEditing/BlockCommentEditingCommandHandler.cs @@ -6,13 +6,13 @@ using System; using System.ComponentModel.Composition; -using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Threading; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Editor.Shared.Extensions; using Microsoft.CodeAnalysis.Editor.Shared.Options; using Microsoft.CodeAnalysis.Formatting; +using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.Text.Shared.Extensions; @@ -37,7 +37,7 @@ internal sealed class BlockCommentEditingCommandHandler : ICommandHandler { [ImportingConstructor] - [SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] public CloseBlockCommentCommandHandler() { } diff --git a/src/EditorFeatures/CSharpTest/BlockCommentEditing/BlockCommentEditingTests.cs b/src/EditorFeatures/CSharpTest/BlockCommentEditing/BlockCommentEditingTests.cs index 27c9ff7395a80017a51a20cdf48057192ea06aaa..2d5b877e879dba4740878e1b05f4cbe5e251f5e7 100644 --- a/src/EditorFeatures/CSharpTest/BlockCommentEditing/BlockCommentEditingTests.cs +++ b/src/EditorFeatures/CSharpTest/BlockCommentEditing/BlockCommentEditingTests.cs @@ -10,7 +10,6 @@ using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; using Microsoft.VisualStudio.Text.Editor.Commanding.Commands; -using Microsoft.VisualStudio.Text.Operations; using Roslyn.Test.Utilities; using Xunit; @@ -726,7 +725,7 @@ protected override TestWorkspace CreateTestWorkspace(string initialMarkup) protected override (ReturnKeyCommandArgs, string insertionText) CreateCommandArgs(ITextView textView, ITextBuffer textBuffer) => (new ReturnKeyCommandArgs(textView, textBuffer), "\r\n"); - internal override ICommandHandler CreateCommandHandler(ITextUndoHistoryRegistry undoHistoryRegistry, IEditorOperationsFactoryService editorOperationsFactoryService) - => new BlockCommentEditingCommandHandler(undoHistoryRegistry, editorOperationsFactoryService); + internal override ICommandHandler GetCommandHandler(TestWorkspace workspace) + => Assert.IsType(workspace.GetService(ContentTypeNames.CSharpContentType, nameof(BlockCommentEditingCommandHandler))); } } diff --git a/src/EditorFeatures/CSharpTest/BlockCommentEditing/CloseBlockCommentTests.cs b/src/EditorFeatures/CSharpTest/BlockCommentEditing/CloseBlockCommentTests.cs index ba06c5aa90001a39890563ce4dd95eff4c370990..add484456d2333611679e35155fa8d5c55290561 100644 --- a/src/EditorFeatures/CSharpTest/BlockCommentEditing/CloseBlockCommentTests.cs +++ b/src/EditorFeatures/CSharpTest/BlockCommentEditing/CloseBlockCommentTests.cs @@ -11,7 +11,6 @@ using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; using Microsoft.VisualStudio.Text.Editor.Commanding.Commands; -using Microsoft.VisualStudio.Text.Operations; using Roslyn.Test.Utilities; using Xunit; @@ -369,7 +368,7 @@ protected override TestWorkspace CreateTestWorkspace(string initialMarkup) protected override (TypeCharCommandArgs, string insertionText) CreateCommandArgs(ITextView textView, ITextBuffer textBuffer) => (new TypeCharCommandArgs(textView, textBuffer, '/'), "/"); - internal override ICommandHandler CreateCommandHandler(ITextUndoHistoryRegistry undoHistoryRegistry, IEditorOperationsFactoryService editorOperationsFactoryService) - => new CloseBlockCommentCommandHandler(); + internal override ICommandHandler GetCommandHandler(TestWorkspace workspace) + => Assert.IsType(workspace.GetService(ContentTypeNames.CSharpContentType, nameof(CloseBlockCommentCommandHandler))); } } diff --git a/src/EditorFeatures/TestUtilities/AbstractTypingCommandHandlerTest.cs b/src/EditorFeatures/TestUtilities/AbstractTypingCommandHandlerTest.cs index f3b90d8a9185f4c967537d8a4756c03901b49320..d6bf0676bef318cf36376bb9d0f00a31869291f8 100644 --- a/src/EditorFeatures/TestUtilities/AbstractTypingCommandHandlerTest.cs +++ b/src/EditorFeatures/TestUtilities/AbstractTypingCommandHandlerTest.cs @@ -10,7 +10,6 @@ using Microsoft.VisualStudio.Commanding; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; -using Microsoft.VisualStudio.Text.Operations; using Roslyn.Test.Utilities; using Xunit; @@ -19,9 +18,7 @@ namespace Microsoft.CodeAnalysis.Editor.UnitTests [UseExportProvider] public abstract class AbstractTypingCommandHandlerTest where TCommandArgs : CommandArgs { - internal abstract ICommandHandler CreateCommandHandler( - ITextUndoHistoryRegistry undoHistoryRegistry, - IEditorOperationsFactoryService editorOperationsFactoryService); + internal abstract ICommandHandler GetCommandHandler(TestWorkspace workspace); protected abstract TestWorkspace CreateTestWorkspace(string initialMarkup); @@ -37,7 +34,7 @@ protected void Verify(string initialMarkup, string expectedMarkup, Action(), workspace.GetService()); + var commandHandler = GetCommandHandler(workspace); var (args, insertionText) = CreateCommandArgs(view, view.TextBuffer); var nextHandler = CreateInsertTextHandler(view, insertionText);