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, IServiceBroker serviceBroker, 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))); #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); 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); 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, 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))); // let each client to have unique id so that we can distinguish different clients when service is restarted var clientId = $"VS ({Process.GetCurrentProcess().Id}) ({Guid.NewGuid()})"; var hostGroup = new HostGroup(clientId); var hubClient = new HubClient("ManagedLanguage.IDE.RemoteHostClient"); var remoteHostStream = await RequestServiceAsync(services, hubClient, WellKnownServiceHubService.RemoteHost, hostGroup, cancellationToken).ConfigureAwait(false); var client = new ServiceHubRemoteHostClient(services, hubClient, hostGroup, remoteHostStream); 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); 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); }