Skip to content

Commit 3de19a1

Browse files
authored
Use brokered service for IManagedHotReloadService in VS (#83018)
###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/roslyn/pull/83018)
1 parent 8d42c9c commit 3de19a1

5 files changed

Lines changed: 20 additions & 59 deletions

File tree

src/EditorFeatures/Core/EditAndContinue/ManagedHotReloadServiceProxy.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Composition;
88
using System.Threading;
99
using System.Threading.Tasks;
10+
using Microsoft.CodeAnalysis.BrokeredServices;
1011
using Microsoft.CodeAnalysis.Host.Mef;
1112
using Microsoft.VisualStudio.Debugger.Contracts.HotReload;
1213
using InternalContracts = Microsoft.CodeAnalysis.Contracts.EditAndContinue;
@@ -17,18 +18,25 @@ namespace Microsoft.CodeAnalysis.EditAndContinue;
1718
[Export(typeof(InternalContracts.IManagedHotReloadService))]
1819
[method: ImportingConstructor]
1920
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
20-
internal sealed class ManagedHotReloadServiceProxy(Lazy<IManagedHotReloadService> service) :
21+
internal sealed class ManagedHotReloadServiceProxy(IServiceBrokerProvider serviceBrokerProvider) :
22+
BrokeredServiceProxy<IManagedHotReloadService>(serviceBrokerProvider.ServiceBroker, BrokeredServiceDescriptors.DebuggerManagedHotReloadService),
2123
InternalContracts.IManagedHotReloadService
2224
{
23-
public async ValueTask<ImmutableArray<InternalContracts.ManagedActiveStatementDebugInfo>> GetActiveStatementsAsync(CancellationToken cancellation)
24-
=> (await service.Value.GetActiveStatementsAsync(cancellation).ConfigureAwait(false)).SelectAsArray(a => a.ToContract());
25+
public async ValueTask<ImmutableArray<InternalContracts.ManagedActiveStatementDebugInfo>> GetActiveStatementsAsync(CancellationToken cancellationToken)
26+
{
27+
var result = await InvokeAsync((service, cancellationToken) => service.GetActiveStatementsAsync(cancellationToken), cancellationToken).ConfigureAwait(false);
28+
return result.SelectAsArray(info => info.ToContract());
29+
}
2530

26-
public async ValueTask<InternalContracts.ManagedHotReloadAvailability> GetAvailabilityAsync(Guid module, CancellationToken cancellation)
27-
=> (await service.Value.GetAvailabilityAsync(module, cancellation).ConfigureAwait(false)).ToContract();
31+
public async ValueTask<InternalContracts.ManagedHotReloadAvailability> GetAvailabilityAsync(Guid module, CancellationToken cancellationToken)
32+
{
33+
var result = await InvokeAsync((service, module, cancellationToken) => service.GetAvailabilityAsync(module, cancellationToken), module, cancellationToken).ConfigureAwait(false);
34+
return result.ToContract();
35+
}
2836

29-
public ValueTask<ImmutableArray<string>> GetCapabilitiesAsync(CancellationToken cancellation)
30-
=> service.Value.GetCapabilitiesAsync(cancellation);
37+
public ValueTask<ImmutableArray<string>> GetCapabilitiesAsync(CancellationToken cancellationToken)
38+
=> InvokeAsync((service, cancellationToken) => service.GetCapabilitiesAsync(cancellationToken), cancellationToken);
3139

32-
public ValueTask PrepareModuleForUpdateAsync(Guid module, CancellationToken cancellation)
33-
=> service.Value.PrepareModuleForUpdateAsync(module, cancellation);
40+
public ValueTask PrepareModuleForUpdateAsync(Guid module, CancellationToken cancellationToken)
41+
=> InvokeAsync((service, module, cancellationToken) => service.PrepareModuleForUpdateAsync(module, cancellationToken), module, cancellationToken);
3442
}

src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/BrokeredServices/Services/Descriptors.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ internal sealed class Descriptors
4343
{ RemoteProjectInitializationStatusService.Moniker, new ServiceRegistration(ServiceAudience.Local, null, allowGuestClients: false) },
4444
{ BrokeredServiceDescriptors.SolutionSnapshotProvider.Moniker, new ServiceRegistration(ServiceAudience.Local, null, allowGuestClients: false) },
4545
{ BrokeredServiceDescriptors.DebuggerManagedHotReloadService.Moniker, new ServiceRegistration(ServiceAudience.Local, null, allowGuestClients: false) },
46-
{ BrokeredServiceDescriptors.HotReloadSessionNotificationService.Moniker, new ServiceRegistration(ServiceAudience.Local, null, allowGuestClients: false) },
47-
{ BrokeredServiceDescriptors.ManagedHotReloadAgentManagerService.Moniker, new ServiceRegistration(ServiceAudience.Local, null, allowGuestClients: false) },
48-
{ BrokeredServiceDescriptors.GenericHotReloadAgentManagerService.Moniker, new ServiceRegistration(ServiceAudience.Local, null, allowGuestClients: false) },
4946
{ BrokeredServiceDescriptors.HotReloadOptionService.Moniker, new ServiceRegistration(ServiceAudience.Local, null, allowGuestClients: false) },
5047
{ BrokeredServiceDescriptors.HotReloadLoggerService.Moniker, new ServiceRegistration(ServiceAudience.Local, null, allowGuestClients: false) },
5148
{ BrokeredServiceDescriptors.MauiLaunchCustomizerService.Moniker, new ServiceRegistration(ServiceAudience.Local, null, allowGuestClients: false) },

src/VisualStudio/DevKit/Impl/EditAndContinue/ManagedHotReloadServiceProxy.cs

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/VisualStudio/DevKit/Impl/Microsoft.VisualStudio.LanguageServices.DevKit.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<Compile Include="..\..\..\EditorFeatures\Core\EditAndContinue\Contracts\ContractWrappers.cs" Link="EditAndContinue\ContractWrappers.cs" />
1818
<Compile Include="..\..\..\EditorFeatures\Core\EditAndContinue\ManagedHotReloadLanguageService.cs" Link="EditAndContinue\ManagedHotReloadLanguageService.cs" />
1919
<Compile Include="..\..\..\EditorFeatures\Core\EditAndContinue\ManagedHotReloadLanguageServiceImpl.cs" Link="EditAndContinue\ManagedHotReloadLanguageServiceImpl.cs" />
20+
<Compile Include="..\..\..\EditorFeatures\Core\EditAndContinue\ManagedHotReloadServiceProxy.cs" Link="EditAndContinue\ManagedHotReloadServiceProxy.cs" />
2021
<Compile Include="..\..\..\Workspaces\Remote\ServiceHub\Services\EditAndContinue\EditAndContinueLogReporter.cs" Link="EditAndContinue\EditAndContinueLogReporter.cs" />
2122
<Compile Include="..\..\..\Workspaces\Remote\ServiceHub\Services\EditAndContinue\HotReloadLoggerProxy.cs" Link="EditAndContinue\HotReloadLoggerProxy.cs" />
2223
<Compile Include="..\..\..\VisualStudio\Core\Def\Telemetry\Shared\*.cs" LinkBase="Logging" />

src/Workspaces/Remote/Core/BrokeredServiceDescriptors.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,8 @@ protected override JsonRpcConnection CreateConnection(JsonRpc jsonRpc)
7070
internal const string DebuggerComponentName = "Debugger";
7171

7272
public static readonly ServiceRpcDescriptor SolutionSnapshotProvider = CreateClientServiceDescriptor("SolutionSnapshotProvider", new Version(0, 1));
73-
public static readonly ServiceRpcDescriptor DebuggerManagedHotReloadService = CreateDebuggerServiceDescriptor("ManagedHotReloadService", new Version(0, 1));
74-
public static readonly ServiceRpcDescriptor HotReloadLoggerService = CreateDebuggerServiceDescriptor("HotReloadLogger", new Version(0, 1));
75-
public static readonly ServiceRpcDescriptor HotReloadSessionNotificationService = CreateDebuggerServiceDescriptor("HotReloadSessionNotificationService", new Version(0, 1));
76-
public static readonly ServiceRpcDescriptor ManagedHotReloadAgentManagerService = CreateDebuggerServiceDescriptor("ManagedHotReloadAgentManagerService", new Version(0, 1));
77-
public static readonly ServiceRpcDescriptor GenericHotReloadAgentManagerService = CreateDebuggerServiceDescriptor("GenericHotReloadAgentManagerService", new Version(0, 1));
73+
public static readonly ServiceRpcDescriptor DebuggerManagedHotReloadService = CreateDebuggerServiceDescriptor("ManagedHotReloadService", new Version(1, 0));
74+
public static readonly ServiceRpcDescriptor HotReloadLoggerService = CreateDebuggerServiceDescriptor("HotReloadLogger", new Version(1, 0));
7875
public static readonly ServiceRpcDescriptor HotReloadOptionService = CreateDebuggerClientServiceDescriptor("HotReloadOptionService", new Version(0, 1));
7976
public static readonly ServiceRpcDescriptor MauiLaunchCustomizerService = CreateMauiServiceDescriptor("MauiLaunchCustomizerService", new Version(0, 1));
8077
public static readonly ServiceRpcDescriptor CssVisualDiagnosticsService = CreateWebToolsServiceDescriptor("CssVisualDiagnosticsService", new Version(0, 1));

0 commit comments

Comments
 (0)