public async Task <Unit> Handle(RazorUpdateProjectParams request, CancellationToken cancellationToken)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var handle = request.ProjectSnapshotHandle;

            if (handle == null)
            {
                _logger.LogWarning("Could not update project information. This often happens after Razor LanguageServer releases when project formats change. Once project information has been recalculated by OmniSharp this warning should go away.");
                return(Unit.Value);
            }

            await Task.Factory.StartNew(
                () => _projectService.UpdateProject(
                    handle.FilePath,
                    handle.Configuration,
                    handle.RootNamespace,
                    handle.ProjectWorkspaceState ?? ProjectWorkspaceState.Default,
                    handle.Documents ?? Array.Empty <DocumentSnapshotHandle>()),
                CancellationToken.None,
                TaskCreationOptions.None,
                _foregroundDispatcher.ForegroundScheduler);

            return(Unit.Value);
        }
Example #2
0
        public async Task Handle_UpdateProject_NoProjectSnapshotHandle_Noops()
        {
            // Arrange
            var projectService = new Mock <RazorProjectService>(MockBehavior.Strict);
            var endpoint       = new RazorProjectEndpoint(Dispatcher, projectService.Object, LoggerFactory);
            var request        = new RazorUpdateProjectParams()
            {
                ProjectSnapshotHandle = null,
            };

            // Act & Assert
            await endpoint.Handle(request, CancellationToken.None);
        }
Example #3
0
        public async Task <Unit> Handle(RazorUpdateProjectParams request, CancellationToken cancellationToken)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            await Task.Factory.StartNew(
                () => _projectService.UpdateProject(
                    request.FilePath,
                    request.Configuration,
                    request.RootNamespace,
                    request.ProjectWorkspaceState ?? ProjectWorkspaceState.Default,
                    request.Documents ?? Array.Empty <DocumentSnapshotHandle>()),
                CancellationToken.None,
                TaskCreationOptions.None,
                _foregroundDispatcher.ForegroundScheduler);

            return(Unit.Value);
        }