コード例 #1
0
        protected virtual async Task <TagHelperResolutionResult> ResolveTagHelpersOutOfProcessAsync(IProjectEngineFactory factory, Project workspaceProject, ProjectSnapshot projectSnapshot, CancellationToken cancellationToken)
        {
            // We're being overly defensive here because the OOP host can return null for the client/session/operation
            // when it's disconnected (user stops the process).
            //
            // This will change in the future to an easier to consume API but for VS RTM this is what we have.
            var remoteClient = await RazorRemoteHostClient.TryGetClientAsync(_workspace.Services, RazorServiceDescriptors.TagHelperProviderServiceDescriptors, RazorRemoteServiceCallbackDispatcherRegistry.Empty, cancellationToken);

            if (remoteClient == null)
            {
                // Could not resolve
                return(null);
            }

            var projectHandle = new ProjectSnapshotHandle(projectSnapshot.FilePath, projectSnapshot.Configuration, projectSnapshot.RootNamespace);
            var result        = await remoteClient.TryInvokeAsync <IRemoteTagHelperProviderService, TagHelperResolutionResult>(
                workspaceProject.Solution,
                (service, solutionInfo, innerCancellationToken) => service.GetTagHelpersAsync(solutionInfo, projectHandle, factory?.GetType().AssemblyQualifiedName, innerCancellationToken),
                cancellationToken
                );

            return(result.HasValue ? result.Value : null);
        }
コード例 #2
0
        protected virtual async Task <TagHelperResolutionResult> ResolveTagHelpersOutOfProcessAsync(IProjectEngineFactory factory, Project workspaceProject, ProjectSnapshot projectSnapshot)
        {
            // We're being overly defensive here because the OOP host can return null for the client/session/operation
            // when it's disconnected (user stops the process).
            //
            // This will change in the future to an easier to consume API but for VS RTM this is what we have.
            try
            {
                var remoteClient = await RazorRemoteHostClient.CreateAsync(_workspace, CancellationToken.None);

                var args = new object[]
                {
                    projectSnapshot,
                    factory?.GetType().AssemblyQualifiedName,
                };

                var result = await remoteClient.TryRunRemoteAsync <TagHelperResolutionResult>(
                    "GetTagHelpersAsync",
                    workspaceProject.Solution,
                    args,
                    CancellationToken.None).ConfigureAwait(false);

                return(result.HasValue ? result.Value : null);
            }
            catch (Exception ex)
            {
                // We silence exceptions from the OOP host because we don't want to bring down VS for an OOP failure.
                // We will retry all failures in process anyway, so if there's a real problem that isn't unique to OOP
                // then it will report a crash in VS.
                _errorReporter.ReportError(ex, projectSnapshot);
            }

            return(null);
        }
コード例 #3
0
 protected override Task <TagHelperResolutionResult> ResolveTagHelpersOutOfProcessAsync(IProjectEngineFactory factory, ProjectSnapshot project)
 {
     Assert.NotNull(OnResolveOutOfProcess);
     return(OnResolveOutOfProcess(factory, project));
 }
コード例 #4
0
 protected override Task <TagHelperResolutionResult> ResolveTagHelpersOutOfProcessAsync(IProjectEngineFactory factory, Project workspaceProject, ProjectSnapshot projectSnapshot, CancellationToken cancellationToken)
 {
     Assert.NotNull(OnResolveOutOfProcess);
     return(OnResolveOutOfProcess(factory, projectSnapshot));
 }
コード例 #5
0
        protected virtual async Task <TagHelperResolutionResult> ResolveTagHelpersOutOfProcessAsync(IProjectEngineFactory factory, ProjectSnapshot project)
        {
            // We're being overly defensive here because the OOP host can return null for the client/session/operation
            // when it's disconnected (user stops the process).
            //
            // This will change in the future to an easier to consume API but for VS RTM this is what we have.
            try
            {
                var client = await RazorLanguageServiceClientFactory.CreateAsync(_workspace, CancellationToken.None);

                if (client != null)
                {
                    using (var session = await client.CreateSessionAsync(project.WorkspaceProject.Solution))
                    {
                        if (session != null)
                        {
                            var args = new object[]
                            {
                                Serialize(project),
                                factory == null ? null : factory.GetType().AssemblyQualifiedName,
                            };

                            var json = await session.InvokeAsync <JObject>("GetTagHelpersAsync", args, CancellationToken.None).ConfigureAwait(false);

                            return(Deserialize(json));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // We silence exceptions from the OOP host because we don't want to bring down VS for an OOP failure.
                // We will retry all failures in process anyway, so if there's a real problem that isn't unique to OOP
                // then it will report a crash in VS.
                _errorReporter.ReportError(ex, project);
            }

            return(null);
        }