Skip to content

Commit

Permalink
primary ctors
Browse files Browse the repository at this point in the history
  • Loading branch information
dibarbet committed Apr 10, 2024
1 parent 3412a49 commit 114e682
Showing 1 changed file with 25 additions and 63 deletions.
88 changes: 25 additions & 63 deletions src/Features/LanguageServer/ProtocolUnitTests/HandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TestRequestTypeOne, string>
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class TestDocumentHandler() : ILspServiceDocumentRequestHandler<TestRequestTypeOne, string>
{
public const string MethodName = nameof(TestDocumentHandler);

[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public TestDocumentHandler()
{
}

public bool MutatesSolutionState => true;
public bool RequiresLSPSolution => true;

Expand All @@ -161,16 +157,12 @@ public Task<string> HandleRequestAsync(TestRequestTypeOne request, RequestContex

[ExportCSharpVisualBasicStatelessLspService(typeof(TestRequestHandlerWithNoParams)), PartNotDiscoverable, Shared]
[LanguageServerEndpoint(MethodName, LanguageServerConstants.DefaultLanguageName)]
internal sealed class TestRequestHandlerWithNoParams : ILspServiceRequestHandler<string>
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class TestRequestHandlerWithNoParams() : ILspServiceRequestHandler<string>
{
public const string MethodName = nameof(TestRequestHandlerWithNoParams);

[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public TestRequestHandlerWithNoParams()
{
}

public bool MutatesSolutionState => true;
public bool RequiresLSPSolution => true;

Expand All @@ -181,15 +173,10 @@ public Task<string> HandleRequestAsync(RequestContext context, CancellationToken
}

[LanguageServerEndpoint(MethodName, LanguageServerConstants.DefaultLanguageName)]
internal sealed class TestNotificationHandler : ILspServiceNotificationHandler<TestRequestTypeOne>
internal sealed class TestNotificationHandler() : ILspServiceNotificationHandler<TestRequestTypeOne>
{
public const string MethodName = nameof(TestNotificationHandler);
public readonly TaskCompletionSource<string> ResultSource;

public TestNotificationHandler()
{
ResultSource = new TaskCompletionSource<string>();
}
public readonly TaskCompletionSource<string> ResultSource = new();

public bool MutatesSolutionState => true;
public bool RequiresLSPSolution => true;
Expand All @@ -205,30 +192,21 @@ 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).
/// </summary>
[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();
}
}

[LanguageServerEndpoint(MethodName, LanguageServerConstants.DefaultLanguageName)]
internal sealed class TestNotificationWithoutParamsHandler : ILspServiceNotificationHandler
internal sealed class TestNotificationWithoutParamsHandler() : ILspServiceNotificationHandler
{
public const string MethodName = nameof(TestNotificationWithoutParamsHandler);
public readonly TaskCompletionSource<string> ResultSource;

public TestNotificationWithoutParamsHandler()
{
ResultSource = new TaskCompletionSource<string>();
}
public readonly TaskCompletionSource<string> ResultSource = new();

public bool MutatesSolutionState => true;
public bool RequiresLSPSolution => true;
Expand All @@ -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).
/// </summary>
[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();
Expand All @@ -263,14 +237,10 @@ public ILspService CreateILspService(LspServices lspServices, WellKnownLspServer
/// </summary>
[ExportCSharpVisualBasicStatelessLspService(typeof(TestLanguageSpecificHandler)), PartNotDiscoverable, Shared]
[LanguageServerEndpoint(TestDocumentHandler.MethodName, LanguageNames.FSharp)]
internal sealed class TestLanguageSpecificHandler : ILspServiceDocumentRequestHandler<TestRequestTypeOne, string>
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class TestLanguageSpecificHandler() : ILspServiceDocumentRequestHandler<TestRequestTypeOne, string>
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public TestLanguageSpecificHandler()
{
}

public bool MutatesSolutionState => true;
public bool RequiresLSPSolution => true;

Expand All @@ -291,14 +261,10 @@ public Task<string> HandleRequestAsync(TestRequestTypeOne request, RequestContex
/// </summary>
[ExportCSharpVisualBasicStatelessLspService(typeof(TestLanguageSpecificHandlerWithDifferentParams)), PartNotDiscoverable, Shared]
[LanguageServerEndpoint(TestDocumentHandler.MethodName, LanguageNames.VisualBasic)]
internal sealed class TestLanguageSpecificHandlerWithDifferentParams : ILspServiceDocumentRequestHandler<TestRequestTypeTwo, string>
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class TestLanguageSpecificHandlerWithDifferentParams() : ILspServiceDocumentRequestHandler<TestRequestTypeTwo, string>
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public TestLanguageSpecificHandlerWithDifferentParams()
{
}

public bool MutatesSolutionState => true;
public bool RequiresLSPSolution => true;

Expand All @@ -319,14 +285,10 @@ public Task<string> HandleRequestAsync(TestRequestTypeTwo request, RequestContex
/// </summary>
[ExportCSharpVisualBasicStatelessLspService(typeof(TestDuplicateLanguageSpecificHandler)), PartNotDiscoverable, Shared]
[LanguageServerEndpoint(TestDocumentHandler.MethodName, LanguageNames.FSharp)]
internal sealed class TestDuplicateLanguageSpecificHandler : ILspServiceRequestHandler<string>
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class TestDuplicateLanguageSpecificHandler() : ILspServiceRequestHandler<string>
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public TestDuplicateLanguageSpecificHandler()
{
}

public bool MutatesSolutionState => true;
public bool RequiresLSPSolution => true;

Expand Down

0 comments on commit 114e682

Please sign in to comment.