示例#1
0
        private async ValueTask <TagHelperResolutionResult> GetTagHelpersCoreAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string factoryTypeName, CancellationToken cancellationToken)
        {
            if (projectHandle is null)
            {
                throw new ArgumentNullException(nameof(projectHandle));
            }

            if (string.IsNullOrEmpty(factoryTypeName))
            {
                throw new ArgumentException($"'{nameof(factoryTypeName)}' cannot be null or empty.", nameof(factoryTypeName));
            }

            var solution = await solutionInfo.GetSolutionAsync(ServiceBrokerClient, cancellationToken).ConfigureAwait(false);

            var projectSnapshot = await GetProjectSnapshotAsync(projectHandle, cancellationToken).ConfigureAwait(false);

            var workspaceProject = solution
                                   .Projects
                                   .FirstOrDefault(project => FilePathComparer.Instance.Equals(project.FilePath, projectSnapshot.FilePath));

            if (workspaceProject == null)
            {
                return(TagHelperResolutionResult.Empty);
            }

            var resolutionResult = await RazorServices.TagHelperResolver.GetTagHelpersAsync(workspaceProject, projectHandle.Configuration, factoryTypeName, cancellationToken).ConfigureAwait(false);

            return(resolutionResult);
        }
        private async ValueTask <TagHelperResolutionResult> GetTagHelpersCoreAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string factoryTypeName, CancellationToken cancellationToken)
        {
            if (projectHandle is null)
            {
                throw new ArgumentNullException(nameof(projectHandle));
            }

            if (string.IsNullOrEmpty(factoryTypeName))
            {
                throw new ArgumentException($"'{nameof(factoryTypeName)}' cannot be null or empty.", nameof(factoryTypeName));
            }

            // We should replace the below call: https://github.com/dotnet/razor-tooling/issues/6316
#pragma warning disable CS0618 // Type or member is obsolete
            var solution = await solutionInfo.GetSolutionAsync(ServiceBrokerClient, cancellationToken).ConfigureAwait(false);

#pragma warning restore CS0618 // Type or member is obsolete
            var projectSnapshot = await GetProjectSnapshotAsync(projectHandle, cancellationToken).ConfigureAwait(false);

            var workspaceProject = solution
                                   .Projects
                                   .FirstOrDefault(project => FilePathComparer.Instance.Equals(project.FilePath, projectSnapshot.FilePath));

            if (workspaceProject is null)
            {
                return(TagHelperResolutionResult.Empty);
            }

            var resolutionResult = await RazorServices.TagHelperResolver.GetTagHelpersAsync(workspaceProject, projectHandle.Configuration, factoryTypeName, cancellationToken).ConfigureAwait(false);

            return(resolutionResult);
        }
        public async ValueTask <TagHelperDeltaResult> GetTagHelpersDeltaCoreAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string factoryTypeName, int lastResultId, CancellationToken cancellationToken)
        {
            var tagHelperResolutionResult = await GetTagHelpersCoreAsync(solutionInfo, projectHandle, factoryTypeName, cancellationToken).ConfigureAwait(false);

            var currentTagHelpers = tagHelperResolutionResult.Descriptors;
            var deltaResult       = _tagHelperDeltaProvider.GetTagHelpersDelta(projectHandle.FilePath, lastResultId, currentTagHelpers);

            return(deltaResult);
        }
 public static ValueTask <Solution> GetSolutionAsync(
     this RazorPinnedSolutionInfoWrapper solutionInfo,
     ServiceBrokerClient client,
     CancellationToken cancellationToken
     ) =>
 RemoteWorkspaceManager.Default.GetSolutionAsync(
     client,
     solutionInfo.UnderlyingObject,
     cancellationToken
     );
示例#5
0
 public ValueTask <TagHelperResolutionResult> GetTagHelpersAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string factoryTypeName, CancellationToken cancellationToken = default)
 => RazorBrokeredServiceImplementation.RunServiceAsync(cancellationToken => GetTagHelpersCoreAsync(solutionInfo, projectHandle, factoryTypeName, cancellationToken), cancellationToken);
 public static ValueTask <T> RunServiceAsync <T>(this RazorPinnedSolutionInfoWrapper solutionInfo, ServiceBrokerClient client, Func <Solution, ValueTask <T> > implementation, CancellationToken cancellationToken)
 => RemoteWorkspaceManager.Default.RunServiceAsync(client, solutionInfo.UnderlyingObject, implementation, cancellationToken);
 public ValueTask <TagHelperDeltaResult> GetTagHelpersDeltaAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string factoryTypeName, int lastResultId, CancellationToken cancellationToken)
 => RazorBrokeredServiceImplementation.RunServiceAsync(cancellationToken => GetTagHelpersDeltaCoreAsync(solutionInfo, projectHandle, factoryTypeName, lastResultId, cancellationToken), cancellationToken);