示例#1
0
        public async Task InitializeAsync_RetrievesHostProjectManagerStateAndInitializesGuestManager()
        {
            // Arrange
            var projectHandle = new ProjectSnapshotHandleProxy(
                new Uri("vsls:/path/project.csproj"),
                RazorConfiguration.Default,
                "project",
                ProjectWorkspaceStateWithTagHelpers);
            var state = new ProjectSnapshotManagerProxyState(new[] { projectHandle });
            var hostProjectManagerProxy = Mock.Of <IProjectSnapshotManagerProxy>(
                proxy => proxy.GetProjectManagerStateAsync(It.IsAny <CancellationToken>()) == Task.FromResult(state));
            var synchronizationService = new ProjectSnapshotSynchronizationService(
                JoinableTaskFactory,
                SessionContext,
                hostProjectManagerProxy,
                ProjectSnapshotManager);

            // Act
            await synchronizationService.InitializeAsync(CancellationToken.None);

            // Assert
            var project = Assert.Single(ProjectSnapshotManager.Projects);

            Assert.Equal("/guest/path/project.csproj", project.FilePath);
            Assert.Same(RazorConfiguration.Default, project.Configuration);
            Assert.Same(ProjectWorkspaceStateWithTagHelpers.TagHelpers, project.TagHelpers);
        }
示例#2
0
        public async Task <ICollaborationService> CreateServiceAsync(CollaborationSession sessionContext, CancellationToken cancellationToken)
        {
            // This collaboration service depends on these serializers being immediately available so we need to register these now so the
            // guest project snapshot manager can retrieve the hosts project state.
            var serializer = (JsonSerializer)sessionContext.GetService(typeof(JsonSerializer));

            serializer.Converters.RegisterRazorLiveShareConverters();

            var languageServices = _workspace.Services.GetLanguageServices(RazorLanguage.Name);
            var projectManager   = (ProjectSnapshotManagerBase)languageServices.GetRequiredService <ProjectSnapshotManager>();

            var projectSnapshotManagerProxy = await sessionContext.GetRemoteServiceAsync <IProjectSnapshotManagerProxy>(typeof(IProjectSnapshotManagerProxy).Name, cancellationToken);

            var synchronizationService = new ProjectSnapshotSynchronizationService(
                _joinableTaskContext.Factory,
                sessionContext,
                projectSnapshotManagerProxy,
                projectManager);

            await synchronizationService.InitializeAsync(cancellationToken);

            return(synchronizationService);
        }