Beispiel #1
0
        protected override async ValueTask ReportProjectRemovedAsync(ProjectId projectId, CancellationToken cancellationToken)
        {
            // cancel whenever the analyzer runner cancels or the client disconnects and the request is canceled:
            using var linkedSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, _callback.ClientDisconnectedSource.Token);

            await _callback.InvokeAsync(
                (callback, cancellationToken) => callback.OnProjectRemovedAsync(projectId, cancellationToken),
                linkedSource.Token).ConfigureAwait(false);
        }
 public ValueTask LogExceptionAsync(
     string exception,
     string text,
     CancellationToken cancellationToken
     ) =>
 _callback.InvokeAsync(
     (callback, cancellationToken) =>
     callback.LogExceptionAsync(_callbackId, exception, text, cancellationToken),
     cancellationToken
     );
 protected override async ValueTask ReportProjectRemovedAsync(
     ProjectId projectId,
     CancellationToken cancellationToken
     )
 {
     await _callback
     .InvokeAsync(
         (callback, cancellationToken) =>
         callback.OnProjectRemovedAsync(_callbackId, projectId, cancellationToken),
         cancellationToken
         )
     .ConfigureAwait(false);
 }
        /// <summary>
        /// Collects data from <paramref name="project"/> and reports it to the telemetry service.
        /// </summary>
        /// <remarks>
        /// Only sends data to the telemetry service when one of the collected data points changes,
        /// not necessarily every time this code is called.
        /// </remarks>
        public override async Task AnalyzeProjectAsync(
            Project project,
            bool semanticsChanged,
            InvocationReasons reasons,
            CancellationToken cancellationToken
            )
        {
            if (!semanticsChanged)
            {
                return;
            }

            var projectId = project.Id;
            var language  = project.Language;
            var analyzerReferencesCount  = project.AnalyzerReferences.Count;
            var projectReferencesCount   = project.AllProjectReferences.Count;
            var metadataReferencesCount  = project.MetadataReferences.Count;
            var documentsCount           = project.DocumentIds.Count;
            var additionalDocumentsCount = project.AdditionalDocumentIds.Count;

            var info = new ProjectTelemetryData(
                projectId: projectId,
                language: language,
                analyzerReferencesCount: analyzerReferencesCount,
                projectReferencesCount: projectReferencesCount,
                metadataReferencesCount: metadataReferencesCount,
                documentsCount: documentsCount,
                additionalDocumentsCount: additionalDocumentsCount
                );

            lock (_gate)
            {
                if (
                    _projectToData.TryGetValue(projectId, out var existingInfo) &&
                    existingInfo.Equals(info)
                    )
                {
                    // already have reported this.  No need to notify VS.
                    return;
                }

                _projectToData[projectId] = info;
            }

            await _callback
            .InvokeAsync(
                (callback, cancellationToken) =>
                callback.ReportProjectTelemetryDataAsync(
                    _callbackId,
                    info,
                    cancellationToken
                    ),
                cancellationToken
                )
            .ConfigureAwait(false);
        }
 protected override async ValueTask ReportTodoCommentDataAsync(
     DocumentId documentId,
     ImmutableArray <TodoCommentData> data,
     CancellationToken cancellationToken
     )
 {
     await _callback
     .InvokeAsync(
         (callback, cancellationToken) =>
         callback.ReportTodoCommentDataAsync(
             _callbackId,
             documentId,
             data,
             cancellationToken
             ),
         cancellationToken
         )
     .ConfigureAwait(false);
 }
 protected override ValueTask ReportTodoCommentDataAsync(DocumentId documentId, ImmutableArray <TodoCommentData> data, CancellationToken cancellationToken)
 => _callback.InvokeAsync(
     (callback, cancellationToken) => callback.ReportTodoCommentDataAsync(_callbackId, documentId, data, cancellationToken),
     cancellationToken);