当前位置: 首页>>代码示例>>C#>>正文


C# DiagnosticAnalyzer.GetType方法代码示例

本文整理汇总了C#中DiagnosticAnalyzer.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# DiagnosticAnalyzer.GetType方法的具体用法?C# DiagnosticAnalyzer.GetType怎么用?C# DiagnosticAnalyzer.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DiagnosticAnalyzer的用法示例。


在下文中一共展示了DiagnosticAnalyzer.GetType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LogAnalyzerCrashCount

        public static void LogAnalyzerCrashCount(DiagnosticAnalyzer analyzer, Exception ex, LogAggregator logAggregator, ProjectId projectId)
        {
            if (logAggregator == null || analyzer == null || ex == null || ex is OperationCanceledException)
            {
                return;
            }

            // TODO: once we create description manager, pass that into here.
            bool telemetry = DiagnosticAnalyzerLogger.AllowsTelemetry(null, analyzer, projectId);
            var tuple = ValueTuple.Create(telemetry, analyzer.GetType(), ex.GetType());
            logAggregator.IncreaseCount(tuple);
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:12,代码来源:DiagnosticAnalyzerLogger.cs

示例2: UpdateAnalyzerTypeCount

        public void UpdateAnalyzerTypeCount(DiagnosticAnalyzer analyzer, ActionCounts analyzerActions, Project projectOpt)
        {
            var telemetry = DiagnosticAnalyzerLogger.AllowsTelemetry(_owner, analyzer, projectOpt?.Id);

            ImmutableInterlocked.AddOrUpdate(
                ref _analyzerInfoMap,
                analyzer.GetType(),
                addValue: new AnalyzerInfo(analyzer, analyzerActions, telemetry),
                updateValueFactory: (k, ai) =>
                {
                    ai.SetAnalyzerTypeCount(analyzerActions);
                    return ai;
                });
        }
开发者ID:noahstein,项目名称:roslyn,代码行数:14,代码来源:DiagnosticLogAggregator.cs

示例3: AnalyzerInfo

            public AnalyzerInfo(DiagnosticAnalyzer analyzer, AnalyzerActions analyzerActions, bool telemetry)
            {
                CLRType = analyzer.GetType();
                Telemetry = telemetry;

                Counts[0] = analyzerActions.CodeBlockEndActionsCount;
                Counts[1] = analyzerActions.CodeBlockStartActionsCount;
                Counts[2] = analyzerActions.CompilationEndActionsCount;
                Counts[3] = analyzerActions.CompilationStartActionsCount;
                Counts[4] = analyzerActions.SemanticModelActionsCount;
                Counts[5] = analyzerActions.SymbolActionsCount;
                Counts[6] = analyzerActions.SyntaxNodeActionsCount;
                Counts[7] = analyzerActions.SyntaxTreeActionsCount;
            }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:14,代码来源:DiagnosticLogAggregator.cs

示例4: IsCompilerAnalyzer

        public static bool IsCompilerAnalyzer(DiagnosticAnalyzer analyzer)
        {
            // TODO: find better way.
            var typeString = analyzer.GetType().ToString();
            if (typeString == CSharpCompilerAnalyzerTypeName)
            {
                return true;
            }

            if (typeString == VisualBasicCompilerAnalyzerTypeName)
            {
                return true;
            }

            return false;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:16,代码来源:AnalyzerHelper.cs

示例5: AnalyzerInfo

 public AnalyzerInfo(DiagnosticAnalyzer analyzer, AnalyzerTelemetryInfo analyzerTelemetryInfo, bool telemetry)
 {
     CLRType = analyzer.GetType();
     Telemetry = telemetry;
     SetAnalyzerTypeCount(analyzerTelemetryInfo);
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:6,代码来源:DiagnosticLogAggregator.cs

示例6: GetUniqueDiagnosticStateNameAndVersion

            /// <summary>
            /// Get the unique state name for the given {type, provider} tuple.
            /// Note that this name is used by the underlying persistence stream of the corresponding <see cref="DiagnosticState"/> to Read/Write diagnostic data into the stream.
            /// If any two distinct {type, provider} tuples have the same diagnostic state name, we will end up sharing the persistence stream between them, leading to duplicate/missing/incorrect diagnostic data.
            /// </summary>
            private static ValueTuple<string, VersionStamp> GetUniqueDiagnosticStateNameAndVersion(StateType type, ProviderId providerId, DiagnosticAnalyzer provider)
            {
                Contract.ThrowIfNull(provider);

                // Get the unique ID for given diagnostic analyzer.
                // note that we also put version stamp so that we can detect changed provider
                var providerType = provider.GetType();
                var location = providerType.Assembly.Location;

                return ValueTuple.Create(UserDiagnosticsPrefixTableName + "_" + type.ToString() + "_" + providerType.AssemblyQualifiedName, GetProviderVersion(location));
            }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:16,代码来源:DiagnosticIncrementalAnalyzer.DiagnosticAnalyzersAndStates.cs

示例7: GetCompilationDiagnosticsAsync

        private async Task GetCompilationDiagnosticsAsync(DiagnosticAnalyzer analyzer, List<Diagnostic> diagnostics, Action<Project, DiagnosticAnalyzer, CancellationToken> forceAnalyzeAllDocuments)
        {
            Contract.ThrowIfFalse(_project.SupportsCompilation);

            using (var pooledObject = SharedPools.Default<List<Diagnostic>>().GetPooledObject())
            {
                var localDiagnostics = pooledObject.Object;
                var compilation = await _project.GetCompilationAsync(_cancellationToken).ConfigureAwait(false);
                DiagnosticAnalyzer clonedAnalyzer = null;

                try
                {
                    // Get all the analyzer actions, including the per-compilation actions.
                    var analyzerExecutor = GetAnalyzerExecutor(compilation, localDiagnostics.Add);
                    var analyzerActions = await this.GetAnalyzerActionsAsync(analyzer, analyzerExecutor).ConfigureAwait(false);
                    var hasDependentCompilationEndAction = await AnalyzerManager.Instance.GetAnalyzerHasDependentCompilationEndAsync(analyzer, analyzerExecutor).ConfigureAwait(false);

                    if (hasDependentCompilationEndAction && forceAnalyzeAllDocuments != null)
                    {
                        // Analyzer registered a compilation end action and at least one other analyzer action during its compilation start action.
                        // We need to ensure that we have force analyzed all documents in this project for this analyzer before executing the end actions.
                        // Doing so on the original analyzer instance might cause duplicate callbacks into the analyzer.
                        // So we create a new instance of this analyzer and compute compilation diagnostics on that instance.

                        try
                        {
                            clonedAnalyzer = Activator.CreateInstance(analyzer.GetType()) as DiagnosticAnalyzer;
                        }
                        catch
                        {
                            // Unable to created a new analyzer instance, bail out on reporting diagnostics.
                            return;
                        }

                        // Report analyzer exception diagnostics on original analyzer, not the temporary cloned one.
                        analyzerExecutor = GetAnalyzerExecutorForClone(compilation, localDiagnostics.Add, analyzerForExceptionDiagnostics: analyzer);

                        analyzerActions = await this.GetAnalyzerActionsAsync(clonedAnalyzer, analyzerExecutor).ConfigureAwait(false);
                        forceAnalyzeAllDocuments(_project, clonedAnalyzer, _cancellationToken);
                    }

                    // Compilation actions.
                    analyzerExecutor.ExecuteCompilationActions(analyzerActions.CompilationActions);

                    // CompilationEnd actions.
                    analyzerExecutor.ExecuteCompilationActions(analyzerActions.CompilationEndActions);

                    var filteredDiagnostics = CompilationWithAnalyzers.GetEffectiveDiagnostics(localDiagnostics, compilation);
                    diagnostics.AddRange(filteredDiagnostics);
                }
                finally
                {
                    if (clonedAnalyzer != null)
                    {
                        AnalyzerManager.Instance.ClearAnalyzerState(ImmutableArray.Create(clonedAnalyzer));
                    }
                }
            }
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:59,代码来源:DiagnosticAnalyzerDriver.cs


注:本文中的DiagnosticAnalyzer.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。