public DeferredInitializationState(VisualStudioWorkspaceImpl workspace, IServiceProvider serviceProvider) : base(assertIsForeground: true) { ServiceProvider = serviceProvider; ShellOpenDocumentService = (IVsUIShellOpenDocument)serviceProvider.GetService(typeof(SVsUIShellOpenDocument)); ProjectTracker = new VisualStudioProjectTracker(serviceProvider, workspace.Services); // Ensure the document tracking service is initialized on the UI thread var documentTrackingService = (VisualStudioDocumentTrackingService)workspace.Services.GetService <IDocumentTrackingService>(); var documentProvider = new DocumentProvider(ProjectTracker, serviceProvider, documentTrackingService); var metadataReferenceProvider = workspace.Services.GetService <VisualStudioMetadataReferenceManager>(); var ruleSetFileProvider = workspace.Services.GetService <VisualStudioRuleSetManager>(); ProjectTracker.InitializeProviders(documentProvider, metadataReferenceProvider, ruleSetFileProvider); var workspaceHost = new VisualStudioWorkspaceHost(workspace); ProjectTracker.RegisterWorkspaceHost(workspaceHost); ProjectTracker.StartSendingEventsToWorkspaceHost(workspaceHost); var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel)); var saveEventsService = componentModel.GetService <SaveEventsService>(); saveEventsService.StartSendingSaveEvents(); VisualStudioProjectCacheHostServiceFactory.ConnectProjectCacheServiceToDocumentTracking(workspace.Services, (ProjectCacheService)workspace.CurrentSolution.Services.CacheService); // Ensure the options factory services are initialized on the UI thread workspace.Services.GetService <IOptionService>(); }
protected void InitializeStandardVisualStudioWorkspace(SVsServiceProvider serviceProvider, SaveEventsService saveEventsService) { var projectTracker = new VisualStudioProjectTracker(serviceProvider); // Ensure the document tracking service is initialized on the UI thread var documentTrackingService = this.Services.GetService <IDocumentTrackingService>(); var documentProvider = new RoslynDocumentProvider(projectTracker, serviceProvider, documentTrackingService); projectTracker.DocumentProvider = documentProvider; projectTracker.MetadataReferenceProvider = this.Services.GetService <VisualStudioMetadataReferenceManager>(); projectTracker.RuleSetFileProvider = this.Services.GetService <VisualStudioRuleSetManager>(); this.SetProjectTracker(projectTracker); var workspaceHost = new VisualStudioWorkspaceHost(this); projectTracker.RegisterWorkspaceHost(workspaceHost); projectTracker.StartSendingEventsToWorkspaceHost(workspaceHost); saveEventsService.StartSendingSaveEvents(); // Ensure the options factory services are initialized on the UI thread this.Services.GetService <IOptionService>(); }
/// <summary> /// Creates a document provider. /// </summary> /// <param name="serviceProvider">Service provider</param> /// <param name="documentTrackingService">An optional <see cref="VisualStudioDocumentTrackingService"/> to track active and visible documents.</param> public DocumentProvider( VisualStudioProjectTracker projectTracker, IServiceProvider serviceProvider, VisualStudioDocumentTrackingService documentTrackingService) { var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel)); _projectTracker = projectTracker; this._documentTrackingServiceOpt = documentTrackingService; this._runningDocumentTable = (IVsRunningDocumentTable4)serviceProvider.GetService(typeof(SVsRunningDocumentTable)); this._editorAdaptersFactoryService = componentModel.GetService <IVsEditorAdaptersFactoryService>(); this._contentTypeRegistryService = componentModel.GetService <IContentTypeRegistryService>(); _textManager = (IVsTextManager)serviceProvider.GetService(typeof(SVsTextManager)); _fileChangeService = (IVsFileChangeEx)serviceProvider.GetService(typeof(SVsFileChangeEx)); var shell = (IVsShell)serviceProvider.GetService(typeof(SVsShell)); if (shell == null) { // This can happen only in tests, bail out. return; } var runningDocumentTableForEvents = (IVsRunningDocumentTable)_runningDocumentTable; Marshal.ThrowExceptionForHR(runningDocumentTableForEvents.AdviseRunningDocTableEvents(new RunningDocTableEventsSink(this), out _runningDocumentTableEventCookie)); }
public CSharpProjectShim( ICSharpProjectRoot projectRoot, VisualStudioProjectTracker projectTracker, Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, IVsHierarchy hierarchy, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt) : base(projectTracker, reportExternalErrorCreatorOpt, projectSystemName, hierarchy, LanguageNames.CSharp, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt, commandLineParserServiceOpt) { _projectRoot = projectRoot; _warningNumberArrayPointer = Marshal.AllocHGlobal(0); // Ensure the default options are set up ResetAllOptions(); UpdateOptions(); projectTracker.AddProject(this); }
public CSharpProjectShim( ICSharpProjectRoot projectRoot, VisualStudioProjectTracker projectTracker, Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, IVsHierarchy hierarchy, IServiceProvider serviceProvider, MiscellaneousFilesWorkspace miscellaneousFilesWorkspaceOpt, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt) : base(projectTracker, reportExternalErrorCreatorOpt, projectSystemName, hierarchy, LanguageNames.CSharp, serviceProvider, miscellaneousFilesWorkspaceOpt, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt) { _projectRoot = projectRoot; _warningNumberArrayPointer = Marshal.AllocHGlobal(0); InitializeOptions(); projectTracker.AddProject(this); }
public WorkspaceHostState(VisualStudioProjectTracker tracker, IVisualStudioWorkspaceHost workspaceHost) { _tracker = tracker; _workspaceHost = workspaceHost; _pushedProjects = new HashSet<AbstractProject>(); this.HostReadyForEvents = false; _solutionAdded = false; }
public WorkspaceHostState(VisualStudioProjectTracker tracker, IVisualStudioWorkspaceHost workspaceHost) { _tracker = tracker; _workspaceHost = workspaceHost; _pushedProjects = new HashSet <AbstractProject>(); this.HostReadyForEvents = false; _solutionAdded = false; }
public AbstractProject( VisualStudioProjectTracker projectTracker, Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, string projectFilePath, Guid projectGuid, string projectTypeGuid, IVsHierarchy hierarchy, string language, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt) { Contract.ThrowIfNull(projectSystemName); ServiceProvider = serviceProvider; Language = language; Hierarchy = hierarchy; Guid = projectGuid; ProjectType = projectTypeGuid; var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel)); ContentTypeRegistryService = componentModel.GetService<IContentTypeRegistryService>(); this.RunningDocumentTable = (IVsRunningDocumentTable4)serviceProvider.GetService(typeof(SVsRunningDocumentTable)); this.DisplayName = projectSystemName; this.ProjectTracker = projectTracker; ProjectSystemName = projectSystemName; Workspace = visualStudioWorkspaceOpt; HostDiagnosticUpdateSource = hostDiagnosticUpdateSourceOpt; UpdateProjectDisplayNameAndFilePath(projectSystemName, projectFilePath); if (_filePathOpt != null) { Version = VersionStamp.Create(File.GetLastWriteTimeUtc(_filePathOpt)); } else { Version = VersionStamp.Create(); } Id = this.ProjectTracker.GetOrCreateProjectIdForPath(_filePathOpt ?? ProjectSystemName, ProjectSystemName); if (reportExternalErrorCreatorOpt != null) { ExternalErrorReporter = reportExternalErrorCreatorOpt(Id); } if (visualStudioWorkspaceOpt != null) { this.EditAndContinueImplOpt = new VsENCRebuildableProjectImpl(this); } }
public AbstractProject( VisualStudioProjectTracker projectTracker, Func <ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, string projectFilePath, IVsHierarchy hierarchy, string language, Guid projectGuid, #pragma warning disable IDE0060 // Remove unused parameter - not used, but left for compat with TypeScript IServiceProvider serviceProviderNotUsed, #pragma warning restore IDE0060 // Remove unused parameter VisualStudioWorkspaceImpl workspace, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, #pragma warning disable IDE0060 // Remove unused parameter - not used, but left for compat ICommandLineParserService commandLineParserServiceOpt = null ) #pragma warning restore IDE0060 // Remove unused parameter : base(projectTracker.ThreadingContext) { Hierarchy = hierarchy; Guid = projectGuid; Language = language; ProjectTracker = projectTracker; _visualStudioWorkspace = workspace; this.DisplayName = hierarchy != null && hierarchy.TryGetName(out var name) ? name : projectSystemName; ProjectSystemName = projectSystemName; HostDiagnosticUpdateSource = hostDiagnosticUpdateSourceOpt; // Set the default value for last design time build result to be true, until the project system lets us know that it failed. LastDesignTimeBuildSucceeded = true; if (projectFilePath != null && File.Exists(projectFilePath)) { ProjectFilePath = projectFilePath; } if (ProjectFilePath != null) { Version = VersionStamp.Create(File.GetLastWriteTimeUtc(ProjectFilePath)); } else { Version = VersionStamp.Create(); } if (reportExternalErrorCreatorOpt != null) { ExternalErrorReporter = reportExternalErrorCreatorOpt(Id); } }
public XamlProject(VisualStudioProjectTracker projectTracker, IVsHierarchy hierarchy, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspace) : base( projectTracker, reportExternalErrorCreatorOpt: null, projectSystemName: $"{XamlProject.GetProjectName(hierarchy)}-{nameof(XamlProject)}", hierarchy: hierarchy, language: StringConstants.XamlLanguageName, serviceProvider: serviceProvider, visualStudioWorkspaceOpt: visualStudioWorkspace, hostDiagnosticUpdateSourceOpt: null) { projectTracker.AddProject(this); }
public AbstractProject GetContextHostProject(IVsHierarchy hierarchy, VisualStudioProjectTracker projectTracker) { hierarchy = GetSharedItemContextHierarchy(hierarchy) ?? hierarchy; var projectName = GetActiveIntellisenseProjectContextInternal(hierarchy); if (projectName != null) { return(projectTracker.ImmutableProjects.FirstOrDefault(p => p.ProjectSystemName == projectName)); } else { return(projectTracker.ImmutableProjects.FirstOrDefault(p => p.Hierarchy == hierarchy)); } }
public AbstractRoslynProject( VisualStudioProjectTracker projectTracker, Func <ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, IVsHierarchy hierarchy, string language, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt) : base(projectTracker, reportExternalErrorCreatorOpt, projectSystemName, hierarchy, language, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt) { if (visualStudioWorkspaceOpt != null) { this.EditAndContinueImplOpt = new VsENCRebuildableProjectImpl(this); } }
public AbstractRoslynProject( VisualStudioProjectTracker projectTracker, Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, IVsHierarchy hierarchy, string language, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt) : base(projectTracker, reportExternalErrorCreatorOpt, projectSystemName, hierarchy, language, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt) { if (visualStudioWorkspaceOpt != null) { this.EditAndContinueImplOpt = new VsENCRebuildableProjectImpl(this); } }
public CSharpProjectShimWithServices( ICSharpProjectRoot projectRoot, VisualStudioProjectTracker projectTracker, Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, IVsHierarchy hierarchy, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt) : base( projectRoot, projectTracker, reportExternalErrorCreatorOpt, projectSystemName, hierarchy, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt) { }
protected CSharpProject( VisualStudioProjectTracker projectTracker, Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, IVsHierarchy hierarchy, IServiceProvider serviceProvider, MiscellaneousFilesWorkspace miscellaneousFilesWorkspaceOpt, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt) : base(projectTracker, reportExternalErrorCreatorOpt, projectSystemName, hierarchy, LanguageNames.CSharp, serviceProvider, miscellaneousFilesWorkspaceOpt, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt) { InitializeOptions(); projectTracker.AddProject(this); }
public AbstractProject( VisualStudioProjectTracker projectTracker, Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, string projectFilePath, IVsHierarchy hierarchy, string language, Guid projectGuid, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt = null) { Contract.ThrowIfNull(projectSystemName); ServiceProvider = serviceProvider; Language = language; Hierarchy = hierarchy; Guid = projectGuid; var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel)); ContentTypeRegistryService = componentModel.GetService<IContentTypeRegistryService>(); this.RunningDocumentTable = (IVsRunningDocumentTable4)serviceProvider.GetService(typeof(SVsRunningDocumentTable)); this.DisplayName = projectSystemName; this.ProjectTracker = projectTracker; ProjectSystemName = projectSystemName; Workspace = visualStudioWorkspaceOpt; CommandLineParserService = commandLineParserServiceOpt; HostDiagnosticUpdateSource = hostDiagnosticUpdateSourceOpt; // Set the default value for last design time build result to be true, until the project system lets us know that it failed. LastDesignTimeBuildSucceeded = true; UpdateProjectDisplayNameAndFilePath(projectSystemName, projectFilePath); if (ProjectFilePath != null) { Version = VersionStamp.Create(File.GetLastWriteTimeUtc(ProjectFilePath)); } else { Version = VersionStamp.Create(); } Id = this.ProjectTracker.GetOrCreateProjectIdForPath(ProjectFilePath ?? ProjectSystemName, ProjectSystemName); if (reportExternalErrorCreatorOpt != null) { ExternalErrorReporter = reportExternalErrorCreatorOpt(Id); } if (visualStudioWorkspaceOpt != null) { if (Language == LanguageNames.CSharp || Language == LanguageNames.VisualBasic) { this.EditAndContinueImplOpt = new VsENCRebuildableProjectImpl(this); } this.MetadataService = visualStudioWorkspaceOpt.Services.GetService<IMetadataService>(); } UpdateAssemblyName(); }
public static AbstractProject GetContextHostProject(IVsHierarchy sharedHierarchy, VisualStudioProjectTracker projectTracker) { return(s_singleton.GetContextHostProjectInternal(sharedHierarchy, projectTracker)); }
/// <summary>NOTE: Call only from derived class constructor</summary> protected void SetProjectTracker(VisualStudioProjectTracker projectTracker) { _projectTracker = projectTracker; }
public StubProject(VisualStudioProjectTracker projectTracker, Project project) : base(projectTracker, null, project.Name + "_Stub", project.FilePath, null, project.Language, Guid.Empty, null, null, null, null) { _id = project.Id; }
public AbstractProject( VisualStudioProjectTracker projectTracker, Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, IVsHierarchy hierarchy, string language, IServiceProvider serviceProvider, MiscellaneousFilesWorkspace miscellaneousFilesWorkspaceOpt, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt) { Contract.ThrowIfNull(projectSystemName); _language = language; this.ServiceProvider = serviceProvider; _hierarchy = hierarchy; var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel)); _contentTypeRegistryService = componentModel.GetService<IContentTypeRegistryService>(); this.RunningDocumentTable = (IVsRunningDocumentTable4)serviceProvider.GetService(typeof(SVsRunningDocumentTable)); this.DisplayName = _projectSystemName; _projectSystemName = projectSystemName; this.ProjectTracker = projectTracker; _miscellaneousFilesWorkspaceOpt = miscellaneousFilesWorkspaceOpt; _visualStudioWorkspaceOpt = visualStudioWorkspaceOpt; _hostDiagnosticUpdateSourceOpt = hostDiagnosticUpdateSourceOpt; UpdateProjectDisplayNameAndFilePath(); if (_filePathOpt != null) { _version = VersionStamp.Create(File.GetLastWriteTimeUtc(_filePathOpt)); } else { _version = VersionStamp.Create(); } _id = this.ProjectTracker.GetOrCreateProjectIdForPath(_filePathOpt ?? _projectSystemName, _projectSystemName); if (reportExternalErrorCreatorOpt != null) { _externalErrorReporter = reportExternalErrorCreatorOpt(_id); } if (visualStudioWorkspaceOpt != null) { this.EditAndContinueImplOpt = new VsENCRebuildableProjectImpl(this); } ConnectHierarchyEvents(); SetIsWebstite(hierarchy); }
public DocumentProvider(VisualStudioProjectTracker projectTracker, IServiceProvider serviceProvider, VisualStudioDocumentTrackingService documentTrackingService) { }