diff --git a/src/Features/LanguageServer/ProtocolUnitTests/HandlerTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/HandlerTests.cs index b729b70efa43f..5b811b7126bae 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/HandlerTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/HandlerTests.cs @@ -135,16 +135,12 @@ internal record TestRequestTypeThree([property: DataMember(Name = "someValue")] [ExportCSharpVisualBasicStatelessLspService(typeof(TestDocumentHandler)), PartNotDiscoverable, Shared] [LanguageServerEndpoint(MethodName, LanguageServerConstants.DefaultLanguageName)] - internal sealed class TestDocumentHandler : ILspServiceDocumentRequestHandler + [method: ImportingConstructor] + [method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + internal sealed class TestDocumentHandler() : ILspServiceDocumentRequestHandler { public const string MethodName = nameof(TestDocumentHandler); - [ImportingConstructor] - [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public TestDocumentHandler() - { - } - public bool MutatesSolutionState => true; public bool RequiresLSPSolution => true; @@ -161,16 +157,12 @@ public Task HandleRequestAsync(TestRequestTypeOne request, RequestContex [ExportCSharpVisualBasicStatelessLspService(typeof(TestRequestHandlerWithNoParams)), PartNotDiscoverable, Shared] [LanguageServerEndpoint(MethodName, LanguageServerConstants.DefaultLanguageName)] - internal sealed class TestRequestHandlerWithNoParams : ILspServiceRequestHandler + [method: ImportingConstructor] + [method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + internal sealed class TestRequestHandlerWithNoParams() : ILspServiceRequestHandler { public const string MethodName = nameof(TestRequestHandlerWithNoParams); - [ImportingConstructor] - [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public TestRequestHandlerWithNoParams() - { - } - public bool MutatesSolutionState => true; public bool RequiresLSPSolution => true; @@ -181,15 +173,10 @@ public Task HandleRequestAsync(RequestContext context, CancellationToken } [LanguageServerEndpoint(MethodName, LanguageServerConstants.DefaultLanguageName)] - internal sealed class TestNotificationHandler : ILspServiceNotificationHandler + internal sealed class TestNotificationHandler() : ILspServiceNotificationHandler { public const string MethodName = nameof(TestNotificationHandler); - public readonly TaskCompletionSource ResultSource; - - public TestNotificationHandler() - { - ResultSource = new TaskCompletionSource(); - } + public readonly TaskCompletionSource ResultSource = new(); public bool MutatesSolutionState => true; public bool RequiresLSPSolution => true; @@ -205,14 +192,10 @@ public Task HandleNotificationAsync(TestRequestTypeOne request, RequestContext c /// Exported via a factory as we need a new instance for each server (the task completion result should be unique per server). /// [ExportCSharpVisualBasicLspServiceFactory(typeof(TestNotificationHandler)), PartNotDiscoverable, Shared] - internal sealed class TestNotificationHandlerFactory : ILspServiceFactory + [method: ImportingConstructor] + [method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + internal sealed class TestNotificationHandlerFactory() : ILspServiceFactory { - [ImportingConstructor] - [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public TestNotificationHandlerFactory() - { - } - public ILspService CreateILspService(LspServices lspServices, WellKnownLspServerKinds serverKind) { return new TestNotificationHandler(); @@ -220,15 +203,10 @@ public ILspService CreateILspService(LspServices lspServices, WellKnownLspServer } [LanguageServerEndpoint(MethodName, LanguageServerConstants.DefaultLanguageName)] - internal sealed class TestNotificationWithoutParamsHandler : ILspServiceNotificationHandler + internal sealed class TestNotificationWithoutParamsHandler() : ILspServiceNotificationHandler { public const string MethodName = nameof(TestNotificationWithoutParamsHandler); - public readonly TaskCompletionSource ResultSource; - - public TestNotificationWithoutParamsHandler() - { - ResultSource = new TaskCompletionSource(); - } + public readonly TaskCompletionSource ResultSource = new(); public bool MutatesSolutionState => true; public bool RequiresLSPSolution => true; @@ -244,14 +222,10 @@ public Task HandleNotificationAsync(RequestContext context, CancellationToken ca /// Exported via a factory as we need a new instance for each server (the task completion result should be unique per server). /// [ExportCSharpVisualBasicLspServiceFactory(typeof(TestNotificationWithoutParamsHandler)), PartNotDiscoverable, Shared] - internal sealed class TestNotificationWithoutParamsHandlerFactory : ILspServiceFactory + [method: ImportingConstructor] + [method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + internal sealed class TestNotificationWithoutParamsHandlerFactory() : ILspServiceFactory { - [ImportingConstructor] - [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public TestNotificationWithoutParamsHandlerFactory() - { - } - public ILspService CreateILspService(LspServices lspServices, WellKnownLspServerKinds serverKind) { return new TestNotificationWithoutParamsHandler(); @@ -263,14 +237,10 @@ public ILspService CreateILspService(LspServices lspServices, WellKnownLspServer /// [ExportCSharpVisualBasicStatelessLspService(typeof(TestLanguageSpecificHandler)), PartNotDiscoverable, Shared] [LanguageServerEndpoint(TestDocumentHandler.MethodName, LanguageNames.FSharp)] - internal sealed class TestLanguageSpecificHandler : ILspServiceDocumentRequestHandler + [method: ImportingConstructor] + [method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + internal sealed class TestLanguageSpecificHandler() : ILspServiceDocumentRequestHandler { - [ImportingConstructor] - [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public TestLanguageSpecificHandler() - { - } - public bool MutatesSolutionState => true; public bool RequiresLSPSolution => true; @@ -291,14 +261,10 @@ public Task HandleRequestAsync(TestRequestTypeOne request, RequestContex /// [ExportCSharpVisualBasicStatelessLspService(typeof(TestLanguageSpecificHandlerWithDifferentParams)), PartNotDiscoverable, Shared] [LanguageServerEndpoint(TestDocumentHandler.MethodName, LanguageNames.VisualBasic)] - internal sealed class TestLanguageSpecificHandlerWithDifferentParams : ILspServiceDocumentRequestHandler + [method: ImportingConstructor] + [method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + internal sealed class TestLanguageSpecificHandlerWithDifferentParams() : ILspServiceDocumentRequestHandler { - [ImportingConstructor] - [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public TestLanguageSpecificHandlerWithDifferentParams() - { - } - public bool MutatesSolutionState => true; public bool RequiresLSPSolution => true; @@ -319,14 +285,10 @@ public Task HandleRequestAsync(TestRequestTypeTwo request, RequestContex /// [ExportCSharpVisualBasicStatelessLspService(typeof(TestDuplicateLanguageSpecificHandler)), PartNotDiscoverable, Shared] [LanguageServerEndpoint(TestDocumentHandler.MethodName, LanguageNames.FSharp)] - internal sealed class TestDuplicateLanguageSpecificHandler : ILspServiceRequestHandler + [method: ImportingConstructor] + [method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + internal sealed class TestDuplicateLanguageSpecificHandler() : ILspServiceRequestHandler { - [ImportingConstructor] - [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public TestDuplicateLanguageSpecificHandler() - { - } - public bool MutatesSolutionState => true; public bool RequiresLSPSolution => true;