示例#1
0
        public void UpdateAnalyzerTypeCount(DiagnosticAnalyzer analyzer, AnalyzerTelemetryInfo analyzerTelemetryInfo, Project projectOpt)
        {
            var telemetry = DiagnosticAnalyzerLogger.AllowsTelemetry(_owner, analyzer, projectOpt?.Id);

            ImmutableInterlocked.AddOrUpdate(
                ref _analyzerInfoMap,
                analyzer.GetType(),
                addValue: new AnalyzerInfo(analyzer, analyzerTelemetryInfo, telemetry),
                updateValueFactory: (k, ai) =>
                {
                    ai.SetAnalyzerTypeCount(analyzerTelemetryInfo);
                    return ai;
                });
        }
示例#2
0
 public void SetAnalyzerTypeCount(AnalyzerTelemetryInfo analyzerTelemetryInfo)
 {
     Counts[0] = analyzerTelemetryInfo.CodeBlockActionsCount;
     Counts[1] = analyzerTelemetryInfo.CodeBlockEndActionsCount;
     Counts[2] = analyzerTelemetryInfo.CodeBlockStartActionsCount;
     Counts[3] = analyzerTelemetryInfo.CompilationActionsCount;
     Counts[4] = analyzerTelemetryInfo.CompilationEndActionsCount;
     Counts[5] = analyzerTelemetryInfo.CompilationStartActionsCount;
     Counts[6] = analyzerTelemetryInfo.SemanticModelActionsCount;
     Counts[7] = analyzerTelemetryInfo.SymbolActionsCount;
     Counts[8] = analyzerTelemetryInfo.SyntaxNodeActionsCount;
     Counts[9] = analyzerTelemetryInfo.SyntaxTreeActionsCount;
     Counts[10] = analyzerTelemetryInfo.OperationActionsCount;
     Counts[11] = analyzerTelemetryInfo.OperationBlockActionsCount;
     Counts[12] = analyzerTelemetryInfo.OperationBlockEndActionsCount;
     Counts[13] = analyzerTelemetryInfo.OperationBlockStartActionsCount;
 }
        public static void UpdateAnalyzerTypeCount(DiagnosticAnalyzer analyzer, AnalyzerTelemetryInfo analyzerTelemetryInfo, Project projectOpt, DiagnosticLogAggregator logAggregator)
        {
            if (analyzerTelemetryInfo == null || analyzer == null || logAggregator == null)
            {
                return;
            }

            logAggregator.UpdateAnalyzerTypeCount(analyzer, analyzerTelemetryInfo, projectOpt);
        }
示例#4
0
 public AnalyzerInfo(DiagnosticAnalyzer analyzer, AnalyzerTelemetryInfo analyzerTelemetryInfo, bool telemetry)
 {
     CLRType = analyzer.GetType();
     Telemetry = telemetry;
     SetAnalyzerTypeCount(analyzerTelemetryInfo);
 }
        private static void Serialize(ObjectWriter writer, AnalyzerTelemetryInfo telemetryInfo, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            writer.WriteInt32(telemetryInfo.CompilationStartActionsCount);
            writer.WriteInt32(telemetryInfo.CompilationEndActionsCount);
            writer.WriteInt32(telemetryInfo.CompilationActionsCount);
            writer.WriteInt32(telemetryInfo.SyntaxTreeActionsCount);
            writer.WriteInt32(telemetryInfo.SemanticModelActionsCount);
            writer.WriteInt32(telemetryInfo.SymbolActionsCount);
            writer.WriteInt32(telemetryInfo.SyntaxNodeActionsCount);
            writer.WriteInt32(telemetryInfo.CodeBlockStartActionsCount);
            writer.WriteInt32(telemetryInfo.CodeBlockEndActionsCount);
            writer.WriteInt32(telemetryInfo.CodeBlockActionsCount);
            writer.WriteInt32(telemetryInfo.OperationActionsCount);
            writer.WriteInt32(telemetryInfo.OperationBlockActionsCount);
            writer.WriteInt32(telemetryInfo.OperationBlockStartActionsCount);
            writer.WriteInt32(telemetryInfo.OperationBlockEndActionsCount);
            writer.WriteInt64(telemetryInfo.ExecutionTime.Ticks);
        }
示例#6
0
        private ImmutableDictionary<DiagnosticAnalyzer, AnalyzerTelemetryInfo> GetTelemetryInfo(
            ImmutableArray<DiagnosticAnalyzer> analyzers,
            CancellationToken cancellationToken)
        {
            var builder = ImmutableDictionary.CreateBuilder<DiagnosticAnalyzer, AnalyzerTelemetryInfo>();

            lock (_gate)
            {
                foreach (var analyzer in analyzers)
                {
                    var actionCounts = _analyzerActionCounts[analyzer];
                    var executionTime = _analyzerExecutionTimeOpt != null ? _analyzerExecutionTimeOpt[analyzer] : default(TimeSpan);
                    var telemetryInfo = new AnalyzerTelemetryInfo(actionCounts, executionTime);
                    builder.Add(analyzer, telemetryInfo);
                }
            }

            return builder.ToImmutable();
        }