77using System . Composition ;
88using System . Threading ;
99using System . Threading . Tasks ;
10+ using Microsoft . CodeAnalysis . BrokeredServices ;
1011using Microsoft . CodeAnalysis . Host . Mef ;
1112using Microsoft . VisualStudio . Debugger . Contracts . HotReload ;
1213using 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}
0 commit comments