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


C# DiagnosticAnalyzer类代码示例

本文整理汇总了C#中DiagnosticAnalyzer的典型用法代码示例。如果您正苦于以下问题:C# DiagnosticAnalyzer类的具体用法?C# DiagnosticAnalyzer怎么用?C# DiagnosticAnalyzer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: GetDocumentBodyAnalysisDataAsync

            public async Task<AnalysisData> GetDocumentBodyAnalysisDataAsync(
                DiagnosticAnalyzer provider, ProviderId providerId, VersionArgument versions, DiagnosticAnalyzerDriver analyzerDriver,
                SyntaxNode root, SyntaxNode member, int memberId, bool supportsSemanticInSpan, MemberRangeMap.MemberRanges ranges)
            {
                try
                {
                    var document = analyzerDriver.Document;
                    var cancellationToken = analyzerDriver.CancellationToken;

                    var state = AnalyzersAndState.GetOrCreateDiagnosticState(StateType.Document, providerId, provider, document.Project.Id, document.Project.Language);
                    var existingData = await state.TryGetExistingDataAsync(document, cancellationToken).ConfigureAwait(false);

                    ImmutableArray<DiagnosticData> diagnosticData;
                    if (supportsSemanticInSpan && CanUseDocumentState(existingData, ranges.TextVersion, versions.DataVersion))
                    {
                        var memberDxData = await GetSemanticDiagnosticsAsync(providerId, provider, analyzerDriver).ConfigureAwait(false);

                        diagnosticData = _owner.UpdateDocumentDiagnostics(existingData, ranges.Ranges, memberDxData.AsImmutableOrEmpty(), root.SyntaxTree, member, memberId);
                        ValidateMemberDiagnostics(providerId, provider, document, root, diagnosticData);
                    }
                    else
                    {
                        // if we can't re-use existing document state, only option we have is updating whole document state here.
                        var dx = await GetSemanticDiagnosticsAsync(providerId, provider, analyzerDriver).ConfigureAwait(false);
                        diagnosticData = dx.AsImmutableOrEmpty();
                    }

                    return new AnalysisData(versions.TextVersion, versions.DataVersion, GetExistingItems(existingData), diagnosticData);
                }
                catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
                {
                    throw ExceptionUtilities.Unreachable;
                }
            }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:34,代码来源:DiagnosticIncrementalAnalyzer.IncrementalAnalyzer.AnalyzerExecutor.cs

示例2: Cache

            public static void Cache(DiagnosticAnalyzer analyzer, object key, CacheEntry entry)
            {
                AssertKey(key);

                // add new cache entry
                var analyzerMap = s_map.GetOrAdd(analyzer, _ => new ConcurrentDictionary<object, CacheEntry>(concurrencyLevel: 2, capacity: 10));
                analyzerMap[key] = entry;
            }
开发者ID:TyOverby,项目名称:roslyn,代码行数:8,代码来源:DiagnosticIncrementalAnalyzer.InMemoryStorage.cs

示例3: StateSet

            public StateSet(string language, DiagnosticAnalyzer analyzer, string errorSourceName)
            {
                _language = language;
                _analyzer = analyzer;
                _errorSourceName = errorSourceName;

                _state = CreateDiagnosticStates(language, analyzer);
            }
开发者ID:RoryVL,项目名称:roslyn,代码行数:8,代码来源:DiagnosticIncrementalAnalyzer.StateSet.cs

示例4: GetSavedMemberRange

 public MemberRanges GetSavedMemberRange(DiagnosticAnalyzer analyzer, Document document)
 {
     var data = _map.GetOrAdd(document.Id, s_createMap);
     lock (data)
     {
         return GetSavedMemberRange_NoLock(data, analyzer, document);
     }
 }
开发者ID:GloryChou,项目名称:roslyn,代码行数:8,代码来源:MemberRangeMap.cs

示例5: GetNameAndVersion

            /// <summary>
            /// Get the unique state name for the given {type, analyzer} 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, analyzer} 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> GetNameAndVersion(DiagnosticAnalyzer analyzer, StateType type)
            {
                Contract.ThrowIfNull(analyzer);

                // Get the unique ID for given diagnostic analyzer.
                // note that we also put version stamp so that we can detect changed analyzer.
                var tuple = analyzer.GetAnalyzerIdAndVersion();
                return ValueTuple.Create(UserDiagnosticsPrefixTableName + "_" + type.ToString() + "_" + tuple.Item1, tuple.Item2);
            }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:14,代码来源:DiagnosticIncrementalAnalyzer.StateSet.cs

示例6: Touch

        public void Touch(DiagnosticAnalyzer analyzer, Document document, VersionStamp version)
        {
            // only touch and updateMemberRange methods are allowed to update the dictionaries
            var data = _map.GetOrAdd(document.Id, s_createMap);

            lock (data)
            {
                Touch_NoLock(data, analyzer, document, version);
            }
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:10,代码来源:MemberRangeMap.cs

示例7: GetOrCreateStateSet

                public StateSet GetOrCreateStateSet(Project project, DiagnosticAnalyzer analyzer)
                {
                    var map = GetOrCreateAnalyzerMap(project);
                    if (map.TryGetValue(analyzer, out var set))
                    {
                        return set;
                    }

                    return null;
                }
开发者ID:TyOverby,项目名称:roslyn,代码行数:10,代码来源:DiagnosticIncrementalAnalyzer.StateManager.ProjectStates.cs

示例8: GetOrCreateStateSet

                public StateSet GetOrCreateStateSet(string language, DiagnosticAnalyzer analyzer)
                {
                    var map = GetAnalyzerMap(language);

                    StateSet set;
                    if (map.TryGetValue(analyzer, out set))
                    {
                        return set;
                    }

                    return null;
                }
开发者ID:GloryChou,项目名称:roslyn,代码行数:12,代码来源:DiagnosticIncrementalAnalyzer.StateManager.HostStates.cs

示例9: 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

示例10: TryGetValue

            public static bool TryGetValue(DiagnosticAnalyzer analyzer, object key, out CacheEntry entry)
            {
                AssertKey(key);

                entry = default(CacheEntry);
                if (!s_map.TryGetValue(analyzer, out var analyzerMap) ||
                    !analyzerMap.TryGetValue(key, out entry))
                {
                    return false;
                }

                return true;
            }
开发者ID:TyOverby,项目名称:roslyn,代码行数:13,代码来源:DiagnosticIncrementalAnalyzer.InMemoryStorage.cs

示例11: 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

示例12: 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

示例13: 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

示例14: CreateDiagnosticStates

            private static DiagnosticState[] CreateDiagnosticStates(string language, DiagnosticAnalyzer analyzer)
            {
                var states = new DiagnosticState[s_stateTypeCount];

                for (int stateType = 0; stateType < s_stateTypeCount; stateType++)
                {
                    var nameAndVersion = GetNameAndVersion(analyzer, (StateType)stateType);

                    var name = nameAndVersion.Item1;
                    var version = nameAndVersion.Item2;

                    states[stateType] = new DiagnosticState(name, version, language);
                }

                return states;
            }
开发者ID:RoryVL,项目名称:roslyn,代码行数:16,代码来源:DiagnosticIncrementalAnalyzer.StateSet.cs

示例15: Remove

            public static void Remove(DiagnosticAnalyzer analyzer, object key)
            {
                AssertKey(key);
                // remove the entry
                if (!s_map.TryGetValue(analyzer, out var analyzerMap))
                {
                    return;
                }

                analyzerMap.TryRemove(key, out var entry);

                if (analyzerMap.IsEmpty)
                {
                    s_map.TryRemove(analyzer, out analyzerMap);
                }
            }
开发者ID:TyOverby,项目名称:roslyn,代码行数:16,代码来源:DiagnosticIncrementalAnalyzer.InMemoryStorage.cs


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