public override Task RemoveProjectAsync(ProjectId projectId, CancellationToken cancellationToken)
 {
     return(_endPoint.InvokeAsync(
                nameof(IDesignerAttributeListener.OnProjectRemovedAsync),
                new object[] { projectId },
                cancellationToken));
 }
 public async Task <IList <PackageWithTypeResult> > FindPackagesWithTypeAsync(
     string source, string name, int arity, CancellationToken cancellationToken)
 {
     return(await _endPoint.InvokeAsync <IList <PackageWithTypeResult> >(
                nameof(IRemoteSymbolSearchUpdateEngine.FindPackagesWithTypeAsync),
                new object[] { source, name, arity },
                cancellationToken).ConfigureAwait(false));
 }
Exemple #3
0
        public override async Task RunRemoteAsync(
            string targetName,
            Solution?solution,
            IReadOnlyList <object?> arguments,
            CancellationToken cancellationToken
            )
        {
            if (solution != null)
            {
                using var scope = await _solutionAssetStorage
                                  .StoreAssetsAsync(solution, cancellationToken)
                                  .ConfigureAwait(false);

                using var _ = ArrayBuilder <object?> .GetInstance(
                          arguments.Count + 1,
                          out var argumentsBuilder
                          );

                argumentsBuilder.Add(scope.SolutionInfo);
                argumentsBuilder.AddRange(arguments);

                await _serviceEndPoint
                .InvokeAsync(targetName, argumentsBuilder, cancellationToken)
                .ConfigureAwait(false);
            }
            else
            {
                await _serviceEndPoint
                .InvokeAsync(targetName, arguments, cancellationToken)
                .ConfigureAwait(false);
            }
        }
        private async Task AnalyzeProjectAsync(Project project, Document?specificDocument, CancellationToken cancellationToken)
        {
            if (!project.SupportsCompilation)
            {
                return;
            }

            // We need to reanalyze the project whenever it (or any of its dependencies) have
            // changed.  We need to know about dependencies since if a downstream project adds the
            // DesignerCategory attribute to a class, that can affect us when we examine the classes
            // in this project.
            var projectVersion = await project.GetDependentSemanticVersionAsync(cancellationToken).ConfigureAwait(false);

            var latestInfos = await ComputeLatestInfosAsync(
                project, projectVersion, specificDocument, cancellationToken).ConfigureAwait(false);

            // Now get all the values that actually changed and notify VS about them. We don't need
            // to tell it about the ones that didn't change since that will have no effect on the
            // user experience.
            //
            //  !  is safe here as `i.changed` implies `i.info` is non-null.
            var changedInfos = latestInfos.Where(i => i.changed).Select(i => i.info !.Value).ToList();

            if (changedInfos.Count > 0)
            {
                await _endPoint.InvokeAsync(
                    nameof(IDesignerAttributeListener.RegisterDesignerAttributesAsync),
                    new object[] { changedInfos },
                    cancellationToken).ConfigureAwait(false);
            }

            // now that we've notified VS, persist all the infos we have (changed or otherwise) back
            // to disk.  We want to do this even when the data is unchanged so that our version
            // stamps will be correct for the next time we come around to analyze this project.
            //
            // Note: we have a potential race condition here.  Specifically, for simplicity, the VS
            // side will return immediately, without actually notifying the project system.  That
            // means that we could persist the data to local storage that isn't in sync with what
            // the project system knows about.  i.e. if VS is closed or crashes before that
            // information is persisted, then these two systems will be in disagreement.  this is
            // believed to not be a big issue given how small a time window this would be and how
            // easy it would be to get out of that state (just edit the file).

            await PersistLatestInfosAsync(project.Solution, projectVersion, latestInfos, cancellationToken).ConfigureAwait(false);
        }
Exemple #5
0
            private void OnWorkspaceChanged(object sender, WorkspaceChangeEventArgs e)
            {
                // workspace event is serialized events. and reset delay only get updated here
                if (!_resettableDelay.Task.IsCompleted)
                {
                    _resettableDelay.Reset();
                    return;
                }

                var delay = new ResettableDelay((int)s_delay.TotalMilliseconds, expeditableDelaySource: AsynchronousOperationListenerProvider.NullListener);

                _resettableDelay = delay;
                delay.Task.ContinueWith(InvalidateAsync, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default);

                async Task InvalidateAsync(Task _)
                {
                    var document = _workspace.CurrentSolution.GetDocument(_documentId);

                    if (document == null)
                    {
                        return;
                    }

                    var newVersion = await document.Project.GetDependentVersionAsync(CancellationToken.None).ConfigureAwait(false);

                    if (newVersion == _lastVersion)
                    {
                        return;
                    }

                    // fire and forget.
                    // ignore any exception such as rpc already disposed (disconnected)

                    _lastVersion = newVersion;

                    await _endPoint.InvokeAsync(
                        nameof(IRemoteCodeLensDataPoint.Invalidate),
                        Array.Empty <object>(),
                        CancellationToken.None).ConfigureAwait(false);
                }
            }
 public Task AddItemsAsync(int count)
 => _endPoint.InvokeAsync(nameof(AddItemsAsync), new object[] { count }, CancellationToken);
Exemple #7
0
 public Task OnStartedAsync()
 => _endPoint.InvokeAsync(nameof(SymbolFinder.FindReferencesServerCallback.OnStartedAsync), Array.Empty <object>(), _cancellationToken);
Exemple #8
0
 public Task ReportProgressAsync(int current, int maximum)
 => _endPoint.InvokeAsync(nameof(SymbolFinder.FindLiteralsServerCallback.ReportProgressAsync), new object[] { current, maximum }, _cancellationToken);
 public Task OnReferenceFoundAsync(Document document, TextSpan span)
 => _endPoint.InvokeAsync(nameof(SymbolFinder.FindLiteralsServerCallback.OnReferenceFoundAsync), new object[] { document.Id, span }, _cancellationToken);