Skip to content

Commit 9386147

Browse files
Switch to simple primary constructors for several DI types. (#78513)
2 parents abcb9ba + b430311 commit 9386147

23 files changed

+82
-194
lines changed

src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptDidChangeHandler.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript;
1212

1313
[ExportStatelessLspService(typeof(DidChangeHandler), ProtocolConstants.TypeScriptLanguageContract), Shared]
14-
internal class VSTypeScriptDidChangeHandler : DidChangeHandler
15-
{
16-
[ImportingConstructor]
17-
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
18-
public VSTypeScriptDidChangeHandler()
19-
{
20-
}
21-
}
14+
[method: ImportingConstructor]
15+
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
16+
internal class VSTypeScriptDidChangeHandler() : DidChangeHandler;

src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptDidCloseHandler.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript;
1212

1313
[ExportStatelessLspService(typeof(DidCloseHandler), ProtocolConstants.TypeScriptLanguageContract), Shared]
14-
internal class VSTypeScriptDidCloseHandler : DidCloseHandler
15-
{
16-
[ImportingConstructor]
17-
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
18-
public VSTypeScriptDidCloseHandler()
19-
{
20-
}
21-
}
14+
[method: ImportingConstructor]
15+
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
16+
internal class VSTypeScriptDidCloseHandler() : DidCloseHandler;

src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptDidOpenHandler.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript;
1212

1313
[ExportStatelessLspService(typeof(DidOpenHandler), ProtocolConstants.TypeScriptLanguageContract), Shared]
14-
internal class VSTypeScriptDidOpenHandler : DidOpenHandler
15-
{
16-
[ImportingConstructor]
17-
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
18-
public VSTypeScriptDidOpenHandler()
19-
{
20-
}
21-
}
14+
[method: ImportingConstructor]
15+
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
16+
internal class VSTypeScriptDidOpenHandler() : DidOpenHandler;

src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptLifeCycleManager.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111
namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript;
1212

1313
[ExportLspServiceFactory(typeof(LspServiceLifeCycleManager), ProtocolConstants.TypeScriptLanguageContract), Shared]
14-
internal class VSTypeScriptLifeCycleManager : LspServiceLifeCycleManager.LspLifeCycleManagerFactory
15-
{
16-
[ImportingConstructor]
17-
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
18-
public VSTypeScriptLifeCycleManager(LspWorkspaceRegistrationService lspWorkspaceRegistrationService) : base(lspWorkspaceRegistrationService)
19-
{
20-
}
21-
}
14+
[method: ImportingConstructor]
15+
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
16+
internal class VSTypeScriptLifeCycleManager(LspWorkspaceRegistrationService lspWorkspaceRegistrationService)
17+
: LspServiceLifeCycleManager.LspLifeCycleManagerFactory(lspWorkspaceRegistrationService);

src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptLspWorkspaceManagerFactory.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript;
1212
[ExportLspServiceFactory(typeof(LspWorkspaceManager), ProtocolConstants.TypeScriptLanguageContract), Shared]
1313
[method: ImportingConstructor]
1414
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
15-
internal class VSTypeScriptLspWorkspaceManagerFactory(LspWorkspaceRegistrationService lspWorkspaceRegistrationService) : LspWorkspaceManagerFactory(lspWorkspaceRegistrationService)
16-
{
17-
}
15+
internal class VSTypeScriptLspWorkspaceManagerFactory(LspWorkspaceRegistrationService lspWorkspaceRegistrationService)
16+
: LspWorkspaceManagerFactory(lspWorkspaceRegistrationService);

src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptProjectContextHandler.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript;
1212

1313
[ExportStatelessLspService(typeof(GetTextDocumentWithContextHandler), ProtocolConstants.TypeScriptLanguageContract), Shared]
14-
internal class VSTypeScriptProjectContextHandler : GetTextDocumentWithContextHandler
15-
{
16-
[ImportingConstructor]
17-
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
18-
public VSTypeScriptProjectContextHandler()
19-
{
20-
}
21-
}
14+
[method: ImportingConstructor]
15+
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
16+
internal class VSTypeScriptProjectContextHandler() : GetTextDocumentWithContextHandler;

src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptRequestTelemetryLoggerFactory.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript;
1212

1313
[ExportLspServiceFactory(typeof(RequestTelemetryLogger), ProtocolConstants.TypeScriptLanguageContract), Shared]
14-
internal class VSTypeScriptRequestTelemetryLoggerFactory : RequestTelemetryLoggerFactory
15-
{
16-
[ImportingConstructor]
17-
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
18-
public VSTypeScriptRequestTelemetryLoggerFactory()
19-
{
20-
}
21-
}
14+
[method: ImportingConstructor]
15+
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
16+
internal class VSTypeScriptRequestTelemetryLoggerFactory() : RequestTelemetryLoggerFactory;

src/LanguageServer/Protocol/Features/UnifiedSuggestions/UnifiedSuggestedActions/UnifiedSuggestedAction.cs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,11 @@ namespace Microsoft.CodeAnalysis.UnifiedSuggestions;
1010
/// Similar to SuggestedAction, but in a location that can be used by
1111
/// both local Roslyn and LSP.
1212
/// </summary>
13-
internal class UnifiedSuggestedAction : IUnifiedSuggestedAction
13+
internal class UnifiedSuggestedAction(Workspace workspace, CodeAction codeAction, CodeActionPriority codeActionPriority) : IUnifiedSuggestedAction
1414
{
15-
public Workspace Workspace { get; }
15+
public Workspace Workspace { get; } = workspace;
1616

17-
public CodeAction OriginalCodeAction { get; }
17+
public CodeAction OriginalCodeAction { get; } = codeAction;
1818

19-
public CodeActionPriority CodeActionPriority { get; }
20-
21-
public UnifiedSuggestedAction(Workspace workspace, CodeAction codeAction, CodeActionPriority codeActionPriority)
22-
{
23-
Workspace = workspace;
24-
OriginalCodeAction = codeAction;
25-
CodeActionPriority = codeActionPriority;
26-
}
19+
public CodeActionPriority CodeActionPriority { get; } = codeActionPriority;
2720
}

src/LanguageServer/Protocol/Handler/Commands/ProvidesCommandAttribute.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,5 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Commands;
99

1010
[MetadataAttribute]
1111
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
12-
internal class CommandAttribute : MethodAttribute
13-
{
14-
public CommandAttribute(string command) : base(AbstractExecuteWorkspaceCommandHandler.GetRequestNameForCommandName(command))
15-
{
16-
}
17-
}
12+
internal class CommandAttribute(string command)
13+
: MethodAttribute(AbstractExecuteWorkspaceCommandHandler.GetRequestNameForCommandName(command));

src/LanguageServer/Protocol/Handler/DocumentChanges/DidCloseHandler.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler.DocumentChanges;
1515

1616
[ExportCSharpVisualBasicStatelessLspService(typeof(DidCloseHandler)), Shared]
1717
[Method(LSP.Methods.TextDocumentDidCloseName)]
18-
internal class DidCloseHandler : ILspServiceNotificationHandler<LSP.DidCloseTextDocumentParams>, ITextDocumentIdentifierHandler<LSP.DidCloseTextDocumentParams, TextDocumentIdentifier>
18+
[method: ImportingConstructor]
19+
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
20+
internal class DidCloseHandler() : ILspServiceNotificationHandler<LSP.DidCloseTextDocumentParams>, ITextDocumentIdentifierHandler<LSP.DidCloseTextDocumentParams, TextDocumentIdentifier>
1921
{
20-
[ImportingConstructor]
21-
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
22-
public DidCloseHandler()
23-
{
24-
}
25-
2622
public bool MutatesSolutionState => true;
2723
public bool RequiresLSPSolution => false;
2824

0 commit comments

Comments
 (0)