private ServiceHubRemoteHostClient( HostWorkspaceServices services, IServiceBroker serviceBroker, ServiceBrokerClient serviceBrokerClient, HubClient hubClient, Stream stream, RemoteServiceCallbackDispatcherRegistry callbackDispatchers) { _connectionPools = new ConnectionPools( connectionFactory: (serviceName, pool, cancellationToken) => CreateConnectionImplAsync(serviceName, callbackTarget: null, pool, cancellationToken), capacity: ConnectionPoolCapacity); // use the hub client logger for unexpected exceptions from devenv as well, so we have complete information in the log: services.GetService <IWorkspaceTelemetryService>()?.RegisterUnexpectedExceptionLogger(hubClient.Logger); _services = services; _serviceBroker = serviceBroker; _serviceBrokerClient = serviceBrokerClient; _hubClient = hubClient; _callbackDispatchers = callbackDispatchers; _endPoint = new RemoteEndPoint(stream, hubClient.Logger, incomingCallTarget: this); _endPoint.Disconnected += OnDisconnected; _endPoint.UnexpectedExceptionThrown += OnUnexpectedExceptionThrown; _endPoint.StartListening(); _assetStorage = services.GetRequiredService <ISolutionAssetStorageProvider>().AssetStorage; _serializer = services.GetRequiredService <ISerializerService>(); _errorReportingService = services.GetService <IErrorReportingService>(); _shutdownCancellationService = services.GetService <IRemoteHostClientShutdownCancellationService>(); }
public static async Task <RemoteHostClient> CreateAsync( HostWorkspaceServices services, IGlobalOptionService globalOptions, AsynchronousOperationListenerProvider listenerProvider, IServiceBroker serviceBroker, RemoteServiceCallbackDispatcherRegistry callbackDispatchers, CancellationToken cancellationToken) { using (Logger.LogBlock(FunctionId.ServiceHubRemoteHostClient_CreateAsync, KeyValueLogMessage.NoProperty, cancellationToken)) { #pragma warning disable ISB001 // Dispose of proxies #pragma warning disable VSTHRD012 // Provide JoinableTaskFactory where allowed var serviceBrokerClient = new ServiceBrokerClient(serviceBroker); #pragma warning restore var hubClient = new HubClient("ManagedLanguage.IDE.RemoteHostClient"); var client = new ServiceHubRemoteHostClient(services, globalOptions, serviceBrokerClient, hubClient, callbackDispatchers); await client.TryInvokeAsync <IRemoteAsynchronousOperationListenerService>( (service, cancellationToken) => service.EnableAsync(AsynchronousOperationListenerProvider.IsEnabled, listenerProvider.DiagnosticTokensEnabled, cancellationToken), cancellationToken).ConfigureAwait(false); client.Started(); return(client); } }
public static async Task <RemoteHostClient> CreateAsync( HostWorkspaceServices services, RemoteProcessConfiguration configuration, AsynchronousOperationListenerProvider listenerProvider, IServiceBroker serviceBroker, RemoteServiceCallbackDispatcherRegistry callbackDispatchers, CancellationToken cancellationToken) { using (Logger.LogBlock(FunctionId.ServiceHubRemoteHostClient_CreateAsync, KeyValueLogMessage.NoProperty, cancellationToken)) { #pragma warning disable ISB001 // Dispose of proxies #pragma warning disable VSTHRD012 // Provide JoinableTaskFactory where allowed var serviceBrokerClient = new ServiceBrokerClient(serviceBroker); #pragma warning restore var hubClient = new HubClient("ManagedLanguage.IDE.RemoteHostClient"); var client = new ServiceHubRemoteHostClient(services, configuration, serviceBrokerClient, hubClient, callbackDispatchers); var syntaxTreeConfigurationService = services.GetService <ISyntaxTreeConfigurationService>(); if (syntaxTreeConfigurationService != null) { await client.TryInvokeAsync <IRemoteProcessTelemetryService>( (service, cancellationToken) => service.SetSyntaxTreeConfigurationOptionsAsync(syntaxTreeConfigurationService.DisableRecoverableTrees, syntaxTreeConfigurationService.DisableProjectCacheService, syntaxTreeConfigurationService.EnableOpeningSourceGeneratedFilesInWorkspace, cancellationToken), cancellationToken).ConfigureAwait(false); } await client.TryInvokeAsync <IRemoteAsynchronousOperationListenerService>( (service, cancellationToken) => service.EnableAsync(AsynchronousOperationListenerProvider.IsEnabled, listenerProvider.DiagnosticTokensEnabled, cancellationToken), cancellationToken).ConfigureAwait(false); client.Started(); return(client); } }
public static async Task <RemoteHostClient> CreateAsync( HostWorkspaceServices services, AsynchronousOperationListenerProvider listenerProvider, IServiceBroker serviceBroker, RemoteServiceCallbackDispatcherRegistry callbackDispatchers, CancellationToken cancellationToken) { using (Logger.LogBlock(FunctionId.ServiceHubRemoteHostClient_CreateAsync, KeyValueLogMessage.NoProperty, cancellationToken)) { Logger.Log(FunctionId.RemoteHost_Bitness, KeyValueLogMessage.Create( LogType.Trace, m => { m["64bit"] = RemoteHostOptions.IsServiceHubProcess64Bit(services); m["ServerGC"] = RemoteHostOptions.IsServiceHubProcessServerGC(services); })); #pragma warning disable ISB001 // Dispose of proxies #pragma warning disable VSTHRD012 // Provide JoinableTaskFactory where allowed var serviceBrokerClient = new ServiceBrokerClient(serviceBroker); #pragma warning restore var hubClient = new HubClient("ManagedLanguage.IDE.RemoteHostClient"); var remoteHostStream = await RequestServiceAsync(services, hubClient, WellKnownServiceHubService.RemoteHost, cancellationToken).ConfigureAwait(false); var client = new ServiceHubRemoteHostClient(services, serviceBroker, serviceBrokerClient, hubClient, remoteHostStream, callbackDispatchers); var uiCultureLCID = CultureInfo.CurrentUICulture.LCID; var cultureLCID = CultureInfo.CurrentCulture.LCID; // initialize the remote service await client._endPoint.InvokeAsync <string>( nameof(IRemoteHostService.InitializeGlobalState), new object?[] { uiCultureLCID, cultureLCID }, cancellationToken).ConfigureAwait(false); if (AsynchronousOperationListenerProvider.IsEnabled && !IsRpsMachine()) { await client.TryInvokeAsync <IRemoteAsynchronousOperationListenerService>( (service, cancellationToken) => service.EnableAsync(AsynchronousOperationListenerProvider.IsEnabled, listenerProvider.DiagnosticTokensEnabled, cancellationToken), cancellationToken).ConfigureAwait(false); } client.Started(); return(client); }
public BrokeredServiceConnection( object?callbackTarget, RemoteServiceCallbackDispatcherRegistry callbackDispatchers, ServiceBrokerClient serviceBrokerClient, SolutionAssetStorage solutionAssetStorage, IErrorReportingService?errorReportingService, IRemoteHostClientShutdownCancellationService?shutdownCancellationService, bool isRemoteHost64Bit) { _serviceBrokerClient = serviceBrokerClient; _solutionAssetStorage = solutionAssetStorage; _errorReportingService = errorReportingService; _shutdownCancellationService = shutdownCancellationService; _serviceDescriptor = ServiceDescriptors.GetServiceDescriptor(typeof(TService), isRemoteHost64Bit); if (_serviceDescriptor.ClientInterface != null) { _callbackDispatcher = callbackDispatchers.GetDispatcher(typeof(TService)); _callbackHandle = _callbackDispatcher.CreateHandle(callbackTarget); } }