public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { return(new OOPTagHelperResolver( workspaceServices.GetRequiredService <ProjectSnapshotProjectEngineFactory>(), workspaceServices.GetRequiredService <ErrorReporter>(), workspaceServices.Workspace)); }
private ServiceHubRemoteHostClient( HostWorkspaceServices services, HubClient hubClient, HostGroup hostGroup, Stream stream) { _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; _hubClient = hubClient; _hostGroup = hostGroup; _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>(); }
private ServiceHubRemoteHostClient( HostWorkspaceServices services, IServiceBroker serviceBroker, ServiceBrokerClient serviceBrokerClient, HubClient hubClient, Stream stream, IRemoteServiceCallbackDispatcherProvider callbackDispatcherProvider) { _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; _callbackDispatcherProvider = callbackDispatcherProvider; _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>(); _isRemoteHostServerGC = RemoteHostOptions.IsServiceHubProcessServerGC(services); _isRemoteHostCoreClr = RemoteHostOptions.IsServiceHubProcessCoreClr(services); }
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { var errorReportingService = workspaceServices.GetRequiredService <IErrorReportingService>(); var errorLoggerService = workspaceServices.GetRequiredService <IErrorLoggerService>(); return(new ExtensionManager(_optionService, errorReportingService, errorLoggerService, _errorHandlers)); }
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { var solutionCrawlerRegistrationService = workspaceServices.GetRequiredService <ISolutionCrawlerRegistrationService>(); var solutionCrawlerService = workspaceServices.GetRequiredService <ISolutionCrawlerService>(); return(new UnitTestingSolutionCrawlerServiceAccessor(solutionCrawlerRegistrationService, solutionCrawlerService)); }
private protected SerializerService(HostWorkspaceServices workspaceServices) { _workspaceServices = workspaceServices; _storageService = workspaceServices.GetRequiredService <ITemporaryStorageService>(); _textService = workspaceServices.GetRequiredService <ITextFactoryService>(); _analyzerLoaderProvider = workspaceServices.GetRequiredService <IAnalyzerAssemblyLoaderProvider>(); _documentationService = workspaceServices.GetService <IDocumentationProviderService>(); _lazyLanguageSerializationService = new ConcurrentDictionary <string, IOptionsSerializationService>(concurrencyLevel: 2, capacity: _workspaceServices.SupportedLanguages.Count()); }
public OptionService( IGlobalOptionService globalOptionService, HostWorkspaceServices workspaceServices) { _globalOptionService = globalOptionService; var schedulerProvider = workspaceServices.GetRequiredService <ITaskSchedulerProvider>(); var listenerProvider = workspaceServices.GetRequiredService <IWorkspaceAsynchronousOperationListenerProvider>(); _taskQueue = new TaskQueue(listenerProvider.GetListener(), schedulerProvider.CurrentContextScheduler); _globalOptionService.OptionChanged += OnGlobalOptionServiceOptionChanged; }
public ValueTask GetAssetsAsync(Stream outputStream, int scopeId, Checksum[] checksums, CancellationToken cancellationToken) { // Complete RPC right away so the client can start reading from the stream. // The fire-and forget task starts writing to the output stream and the client will read it until it reads all expected data. _ = Task.Run(async() => { using var writer = new ObjectWriter(outputStream, leaveOpen: false, cancellationToken); var assetStorage = _services.GetRequiredService <ISolutionAssetStorageProvider>().AssetStorage; var serializer = _services.GetRequiredService <ISerializerService>(); await RemoteHostAssetSerialization.WriteDataAsync(writer, assetStorage, serializer, scopeId, checksums, cancellationToken).ConfigureAwait(false); }, cancellationToken); return(default);
private ServiceHubRemoteHostClient( HostWorkspaceServices services, HubClient hubClient, HostGroup hostGroup, Stream stream) : base(services) { var optionService = services.GetRequiredService <IOptionService>(); if (optionService.GetOption(RemoteHostOptions.EnableConnectionPool)) { int maxPoolConnection = optionService.GetOption(RemoteHostOptions.MaxPoolConnection); _connectionPool = new ConnectionPool( connectionFactory: (serviceName, cancellationToken) => CreateConnectionAsync(serviceName, callbackTarget: null, cancellationToken), maxPoolConnection); } _hubClient = hubClient; _hostGroup = hostGroup; _endPoint = new RemoteEndPoint(stream, hubClient.Logger, incomingCallTarget: this); _endPoint.Disconnected += OnDisconnected; _endPoint.UnexpectedExceptionThrown += OnUnexpectedExceptionThrown; _endPoint.StartListening(); }
public static SyntaxFormattingOptions Create(OptionSet options, HostWorkspaceServices services, string language) { var formattingService = services.GetRequiredLanguageService <ISyntaxFormattingService>(language); var configOptions = options.AsAnalyzerConfigOptions(services.GetRequiredService <IOptionService>(), language); return(formattingService.GetFormattingOptions(configOptions)); }
public static void ShowInfoBar(HostWorkspaceServices services, Exception?exception = null) { if (s_infoBarReported) { return; } s_infoBarReported = true; // use info bar to show warning to users var infoBarUIs = new List <InfoBarUI>(); infoBarUIs.Add( new InfoBarUI(ServicesVSResources.Learn_more, InfoBarUI.UIKind.HyperLink, () => BrowserHelper.StartBrowser(new Uri(OOPKilledMoreInfoLink)), closeAfterAction: false)); var errorReportingService = services.GetRequiredService <IErrorReportingService>(); if (exception != null) { infoBarUIs.Add( new InfoBarUI(WorkspacesResources.Show_Stack_Trace, InfoBarUI.UIKind.HyperLink, () => errorReportingService.ShowDetailedErrorInfo(exception), closeAfterAction: true)); } errorReportingService.ShowGlobalErrorInfo( ServicesVSResources.Unfortunately_a_process_used_by_Visual_Studio_has_encountered_an_unrecoverable_error_We_recommend_saving_your_work_and_then_closing_and_restarting_Visual_Studio, infoBarUIs.ToArray()); }
public Service(HostWorkspaceServices workspaceServices) { // We will defer creation of this reference manager until we have to to avoid it being constructed too // early and potentially causing deadlocks. _manager = new Lazy <MonoDevelopMetadataReferenceManager> ( () => workspaceServices.GetRequiredService <MonoDevelopMetadataReferenceManager> ()); }
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { var optionService = workspaceServices.GetRequiredService <IOptionService>(); var database = optionService.GetOption(StorageOptions.Database); switch (database) { case StorageDatabase.SQLite: if (!SQLitePersistentStorageService.TryInitializeLibraries()) { break; } var locationService = workspaceServices.GetService <IPersistentStorageLocationService>(); if (locationService != null) { return(new SQLitePersistentStorageService(optionService, locationService, _solutionSizeTracker)); } break; } return(NoOpPersistentStorageService.Instance); }
internal static IEnumerable <ClassifiedSpan> GetClassifiedSpans( HostWorkspaceServices workspaceServices, SemanticModel semanticModel, TextSpan textSpan, ClassificationOptions options, CancellationToken cancellationToken) { var service = workspaceServices.GetLanguageServices(semanticModel.Language).GetRequiredService <ISyntaxClassificationService>(); var syntaxClassifiers = service.GetDefaultSyntaxClassifiers(); var extensionManager = workspaceServices.GetRequiredService <IExtensionManager>(); var getNodeClassifiers = extensionManager.CreateNodeExtensionGetter(syntaxClassifiers, c => c.SyntaxNodeTypes); var getTokenClassifiers = extensionManager.CreateTokenExtensionGetter(syntaxClassifiers, c => c.SyntaxTokenKinds); using var _1 = ArrayBuilder <ClassifiedSpan> .GetInstance(out var syntacticClassifications); using var _2 = ArrayBuilder <ClassifiedSpan> .GetInstance(out var semanticClassifications); var root = semanticModel.SyntaxTree.GetRoot(cancellationToken); service.AddSyntacticClassifications(root, textSpan, syntacticClassifications, cancellationToken); service.AddSemanticClassifications(semanticModel, textSpan, getNodeClassifiers, getTokenClassifiers, semanticClassifications, options, cancellationToken); var allClassifications = new List <ClassifiedSpan>(semanticClassifications.Where(s => s.TextSpan.OverlapsWith(textSpan))); var semanticSet = semanticClassifications.Select(s => s.TextSpan).ToSet(); allClassifications.AddRange(syntacticClassifications.Where( s => s.TextSpan.OverlapsWith(textSpan) && !semanticSet.Contains(s.TextSpan))); allClassifications.Sort((s1, s2) => s1.TextSpan.Start - s2.TextSpan.Start); return(allClassifications); }
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { #if !DOTNET_BUILD_FROM_SOURCE var optionService = workspaceServices.GetRequiredService <IOptionService>(); var database = optionService.GetOption(StorageOptions.Database); switch (database) { case StorageDatabase.SQLite: var locationService = workspaceServices.GetService <IPersistentStorageLocationService>(); if (locationService != null) { if (UseInMemoryWriteCache(workspaceServices)) { return(new SQLite.v2.SQLitePersistentStorageService(locationService)); } else { return(new SQLite.v1.SQLitePersistentStorageService(locationService)); } } break; } #endif return(NoOpPersistentStorageService.Instance); }
public Service(HostWorkspaceServices workspaceServices) { // We will defer creation of this reference manager until we have to to avoid it being constructed too // early and potentially causing deadlocks. We do initialize it on the UI thread in the // VisualStudioWorkspaceImpl.DeferredState constructor to ensure it gets created there. _manager = new Lazy <VisualStudioMetadataReferenceManager>( () => workspaceServices.GetRequiredService <VisualStudioMetadataReferenceManager>()); }
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { if (_singleton == null) { _singleton = new VisualStudioErrorReportingService(workspaceServices.GetRequiredService <IInfoBarService>()); } return(_singleton); }
public static bool IsServiceHubProcessServerGC(HostWorkspaceServices services) { if (!IsServiceHubProcess64Bit(services)) { return(false); } return(services.GetRequiredService <IOptionService>().GetOption(OOPServerGC) || services.GetService <IExperimentationService>()?.IsExperimentEnabled(WellKnownExperimentNames.OOPServerGC) == true); }
private async Task PopulateWorkspaceFromDeferredProjectInfoAsync( CancellationToken cancellationToken) { // NOTE: We need to check cancellationToken after each await, in case the user has // already closed the solution. AssertIsForeground(); var componentModel = _serviceProvider.GetService(typeof(SComponentModel)) as IComponentModel; var workspaceProjectContextFactory = componentModel.GetService <IWorkspaceProjectContextFactory>(); var dte = _serviceProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; var solutionConfig = (EnvDTE80.SolutionConfiguration2)dte.Solution.SolutionBuild.ActiveConfiguration; OutputToOutputWindow($"Getting project information - start"); var start = DateTimeOffset.UtcNow; var projectInfos = SpecializedCollections.EmptyReadOnlyDictionary <string, DeferredProjectInformation>(); // Note that `solutionConfig` may be null. For example: if the solution doesn't actually // contain any projects. if (solutionConfig != null) { // Capture the context so that we come back on the UI thread, and do the actual project creation there. var deferredProjectWorkspaceService = _workspaceServices.GetService <IDeferredProjectWorkspaceService>(); projectInfos = await deferredProjectWorkspaceService.GetDeferredProjectInfoForConfigurationAsync( $"{solutionConfig.Name}|{solutionConfig.PlatformName}", cancellationToken).ConfigureAwait(true); } AssertIsForeground(); cancellationToken.ThrowIfCancellationRequested(); OutputToOutputWindow($"Getting project information - done (took {DateTimeOffset.UtcNow - start})"); OutputToOutputWindow($"Creating projects - start"); start = DateTimeOffset.UtcNow; var targetPathsToProjectPaths = BuildTargetPathMap(projectInfos); var analyzerAssemblyLoader = _workspaceServices.GetRequiredService <IAnalyzerService>().GetLoader(); foreach (var projectFilename in projectInfos.Keys) { cancellationToken.ThrowIfCancellationRequested(); GetOrCreateProjectFromArgumentsAndReferences( workspaceProjectContextFactory, analyzerAssemblyLoader, projectFilename, projectInfos, targetPathsToProjectPaths); } OutputToOutputWindow($"Creating projects - done (took {DateTimeOffset.UtcNow - start})"); OutputToOutputWindow($"Pushing to workspace - start"); start = DateTimeOffset.UtcNow; FinishLoad(); OutputToOutputWindow($"Pushing to workspace - done (took {DateTimeOffset.UtcNow - start})"); }
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { if (workspaceServices == null) { throw new ArgumentNullException(nameof(workspaceServices)); } var errorReporter = workspaceServices.GetRequiredService <ErrorReporter>(); return(new VisualStudioFileChangeTrackerFactory(_foregroundDispatcher, errorReporter, _fileChangeService)); }
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { if (workspaceServices is null) { throw new ArgumentNullException(nameof(workspaceServices)); } var errorReporter = workspaceServices.GetRequiredService <ErrorReporter>(); return(new VisualStudioFileChangeTrackerFactory(errorReporter, _fileChangeService, _projectSnapshotManagerDispatcher, _joinableTaskContext)); }
public Task <RemoteHostClient> CreateAsync(HostWorkspaceServices services, CancellationToken cancellationToken) { var optionService = services.GetRequiredService <IOptionService>(); if (optionService.GetOption(RemoteHostOptions.RemoteHostTest)) { return(InProcRemoteHostClient.CreateAsync(services, runCacheCleanup: false)); } return(SpecializedTasks.Null <RemoteHostClient>()); }
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { if (workspaceServices == null) { throw new ArgumentNullException(nameof(workspaceServices)); } var runningDocumentTable = (IVsRunningDocumentTable)_serviceProvider.GetService(typeof(SVsRunningDocumentTable)); var fileChangeTrackerFactory = workspaceServices.GetRequiredService <FileChangeTrackerFactory>(); return(new VisualStudioEditorDocumentManager(_foregroundDispatcher, fileChangeTrackerFactory, runningDocumentTable, _editorAdaptersFactory)); }
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { if (workspaceServices is null) { throw new ArgumentNullException(nameof(workspaceServices)); } var fileChangeTrackerFactory = workspaceServices.GetRequiredService <FileChangeTrackerFactory>(); var editorDocumentManager = new VisualStudioMacEditorDocumentManager(_projectSnapshotManagerDispatcher, _joinableTaskContext, fileChangeTrackerFactory); return(editorDocumentManager); }
protected Workspace(HostServices host) { _services = host.CreateWorkspaceServices(this); // queue used for sending events var workspaceTaskSchedulerFactory = _services.GetRequiredService <IWorkspaceTaskSchedulerFactory>(); _taskQueue = workspaceTaskSchedulerFactory.CreateEventingTaskQueue(); // initialize with empty document set _latestDocuments = new WorkspaceDocuments(ImmutableDictionary <DocumentId, Document> .Empty); }
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { if (workspaceServices == null) { throw new ArgumentNullException(nameof(workspaceServices)); } var fileChangeTrackerFactory = workspaceServices.GetRequiredService <FileChangeTrackerFactory>(); var editorDocumentManager = new VisualStudioMacEditorDocumentManager(_foregroundDispatcher, fileChangeTrackerFactory); return(editorDocumentManager); }
public OptionService( IGlobalOptionService globalOptionService, HostWorkspaceServices workspaceServices) { _globalOptionService = globalOptionService; var workspaceTaskSchedulerFactory = workspaceServices.GetRequiredService <IWorkspaceTaskSchedulerFactory>(); _taskQueue = workspaceTaskSchedulerFactory.CreateEventingTaskQueue(); _globalOptionService.OptionChanged += OnGlobalOptionServiceOptionChanged; }
public static bool IsUsingServiceHubOutOfProcess(HostWorkspaceServices services) { var optionService = services.GetRequiredService <IOptionService>(); if (Environment.Is64BitOperatingSystem && optionService.GetOption(OOP64Bit)) { // OOP64Bit is set and supported return(true); } return(false); }
private static StorageDatabase GetDatabase(HostWorkspaceServices workspaceServices) { var experimentationService = workspaceServices.GetService <IExperimentationService>(); if (experimentationService?.IsExperimentEnabled(WellKnownExperimentNames.CloudCache) == true) { return(StorageDatabase.CloudCache); } var optionService = workspaceServices.GetRequiredService <IOptionService>(); return(optionService.GetOption(StorageOptions.Database)); }
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { if (_singleton == null) { _singleton = new VisualStudioErrorReportingService( _threadingContext, _listenerProvider, workspaceServices.GetRequiredService <IInfoBarService>(), _serviceProvider); } return(_singleton); }