• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Diagnostics.CompilationEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ProcessEventAsync

        private async Task ProcessEventAsync(CompilationEvent e, AnalysisScope analysisScope, AnalysisState analysisStateOpt, CancellationToken cancellationToken)
        {
            await ProcessEventCoreAsync(e, analysisScope, analysisStateOpt, cancellationToken).ConfigureAwait(false);

            if (analysisStateOpt != null)
            {
                await analysisStateOpt.OnCompilationEventProcessedAsync(e, analysisScope, cancellationToken).ConfigureAwait(false);
            }
        }
开发者ID:jeffanders,项目名称:roslyn,代码行数:9,代码来源:AnalyzerDriver.cs


示例2: ExecuteCompilationActionsAsync

        private async Task ExecuteCompilationActionsAsync(
            ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<CompilationAnalyzerAction>> compilationActionsMap,
            CompilationEvent compilationEvent,
            AnalysisScope analysisScope,
            AnalysisState analysisStateOpt,
            CancellationToken cancellationToken)
        {
            Debug.Assert(compilationEvent is CompilationStartedEvent || compilationEvent is CompilationCompletedEvent);

            try
            {
                foreach (var analyzer in analysisScope.Analyzers)
                {
                    ImmutableArray<CompilationAnalyzerAction> compilationActions;
                    if (compilationActionsMap.TryGetValue(analyzer, out compilationActions))
                    {
                        await analyzerExecutor.ExecuteCompilationActionsAsync(compilationActions, analyzer, compilationEvent, analysisScope, analysisStateOpt).ConfigureAwait(false);
                    }
                    else if (analysisStateOpt != null)
                    {
                        await analysisStateOpt.MarkEventCompleteAsync(compilationEvent, analyzer, cancellationToken).ConfigureAwait(false);
                    }
                }
            }
            finally
            {
                compilationEvent.FlushCache();
            }
        }
开发者ID:jeffanders,项目名称:roslyn,代码行数:29,代码来源:AnalyzerDriver.cs


示例3: ProcessEventCore

        private void ProcessEventCore(CompilationEvent e, AnalysisScope analysisScope, AnalysisState analysisStateOpt, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var symbolEvent = e as SymbolDeclaredCompilationEvent;
            if (symbolEvent != null)
            {
                ProcessSymbolDeclared(symbolEvent, analysisScope, analysisStateOpt, cancellationToken);
                return;
            }

            var completedEvent = e as CompilationUnitCompletedEvent;
            if (completedEvent != null)
            {
                ProcessCompilationUnitCompleted(completedEvent, analysisScope, analysisStateOpt, cancellationToken);
                return;
            }

            var endEvent = e as CompilationCompletedEvent;
            if (endEvent != null)
            {
                ProcessCompilationCompleted(endEvent, analysisScope, analysisStateOpt, cancellationToken);
                return;
            }

            var startedEvent = e as CompilationStartedEvent;
            if (startedEvent != null)
            {
                ProcessCompilationStarted(startedEvent, analysisScope, analysisStateOpt, cancellationToken);
                return;
            }

            throw new InvalidOperationException("Unexpected compilation event of type " + e.GetType().Name);
        }
开发者ID:JRobertGit,项目名称:roslyn,代码行数:34,代码来源:AnalyzerDriver.cs


示例4: AddPendingSourceEvent_NoLock

        private void AddPendingSourceEvent_NoLock(SyntaxTree tree, CompilationEvent compilationEvent)
        {
            HashSet<CompilationEvent> currentEvents;
            if (!_pendingSourceEvents.TryGetValue(tree, out currentEvents))
            {
                currentEvents = _compilationEventsPool.Allocate();
                _pendingSourceEvents[tree] = currentEvents;
                AnalyzerDriver.RemoveCachedSemanticModel(tree, compilationEvent.Compilation);
            }

            currentEvents.Add(compilationEvent);
        }
开发者ID:ralfkang,项目名称:roslyn,代码行数:12,代码来源:AnalysisState.cs


示例5: OnCompilationEventProcessed

        /// <summary>
        /// Invoke this method at completion of event processing for the given analysis scope.
        /// It updates the analysis state of this event for each analyzer and if the event has been fully processed for all analyzers, then removes it from our event cache.
        /// </summary>
        public void OnCompilationEventProcessed(CompilationEvent compilationEvent, AnalysisScope analysisScope)
        {
            // Analyze if the symbol and all its declaring syntax references are analyzed.
            var symbolDeclaredEvent = compilationEvent as SymbolDeclaredCompilationEvent;
            if (symbolDeclaredEvent != null)
            {
                OnSymbolDeclaredEventProcessed(symbolDeclaredEvent, analysisScope.Analyzers);
            }

            // Check if event is fully analyzed for all analyzers.
            foreach (var analyzerState in _analyzerStateMap.Values)
            {
                if (!analyzerState.IsEventAnalyzed(compilationEvent))
                {
                    return;
                }
            }

            // Remove the event from event map.
            lock (_gate)
            {
                UpdateEventsMap_NoLock(compilationEvent, add: false);
            }
        }
开发者ID:Excoriate,项目名称:roslyn,代码行数:28,代码来源:AnalysisState.cs


示例6: MarkEventComplete

 /// <summary>
 /// Marks the given event as fully analyzed for the given analyzer.
 /// </summary>
 public void MarkEventComplete(CompilationEvent compilationEvent, DiagnosticAnalyzer analyzer)
 {
     _analyzerStateMap[analyzer].MarkEventComplete(compilationEvent);
 }
开发者ID:Excoriate,项目名称:roslyn,代码行数:7,代码来源:AnalysisState.cs


示例7: AddPendingSourceEvent_NoLock

        private void AddPendingSourceEvent_NoLock(SyntaxTree tree, CompilationEvent compilationEvent)
        {
            HashSet<CompilationEvent> currentEvents;
            if (!_pendingSourceEvents.TryGetValue(tree, out currentEvents))
            {
                currentEvents = new HashSet<CompilationEvent>();
                _pendingSourceEvents[tree] = currentEvents;
                _compilationData.RemoveCachedSemanticModel(tree);
            }

            currentEvents.Add(compilationEvent);
        }
开发者ID:bgarate,项目名称:roslyn,代码行数:12,代码来源:AnalysisState.cs


示例8: RemovePendingSourceEvent_NoLock

 private void RemovePendingSourceEvent_NoLock(SyntaxTree tree, CompilationEvent compilationEvent)
 {
     HashSet<CompilationEvent> currentEvents;
     if (_pendingSourceEvents.TryGetValue(tree, out currentEvents))
     {
         if (currentEvents.Remove(compilationEvent) && currentEvents.Count == 0)
         {
             _compilationEventsPool.Free(currentEvents);
             _pendingSourceEvents.Remove(tree);
         }
     }
 }
开发者ID:Excoriate,项目名称:roslyn,代码行数:12,代码来源:AnalysisState.cs


示例9: ProcessEventAsync

 private async Task ProcessEventAsync(CompilationEvent e, CancellationToken cancellationToken)
 {
     try
     {
         var processEventTask = ProcessEventCoreAsync(e, cancellationToken);
         if (processEventTask != null)
         {
             await processEventTask.ConfigureAwait(false);
         }
     }
     catch (OperationCanceledException)
     {
         // when just a single operation is cancelled, we continue processing events.
         // TODO: what is the desired behavior in this case?
     }
 }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:16,代码来源:AnalyzerDriver.cs


示例10: ProcessEventCoreAsync

        private Task ProcessEventCoreAsync(CompilationEvent e, CancellationToken cancellationToken)
        {
            var symbolEvent = e as SymbolDeclaredCompilationEvent;
            if (symbolEvent != null)
            {
                return ProcessSymbolDeclaredAsync(symbolEvent, cancellationToken);
            }

            var completedEvent = e as CompilationUnitCompletedEvent;
            if (completedEvent != null)
            {
                return ProcessCompilationUnitCompletedAsync(completedEvent, cancellationToken);
            }

            var endEvent = e as CompilationCompletedEvent;
            if (endEvent != null)
            {
                return ProcessCompilationCompletedAsync(endEvent, cancellationToken);
            }

            if (e is CompilationStartedEvent)
            {
                // Ignore CompilationStartedEvent.
                return null;
            }

            throw new InvalidOperationException("Unexpected compilation event of type " + e.GetType().Name);
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:28,代码来源:AnalyzerDriver.cs


示例11: MarkEventCompleteAsync

 /// <summary>
 /// Marks the given event as fully analyzed for the given analyzer.
 /// </summary>
 public Task MarkEventCompleteAsync(CompilationEvent compilationEvent, DiagnosticAnalyzer analyzer, CancellationToken cancellationToken)
 {
     return GetAnalyzerState(analyzer).MarkEventCompleteAsync(compilationEvent, cancellationToken);
 }
开发者ID:ralfkang,项目名称:roslyn,代码行数:7,代码来源:AnalysisState.cs


示例12: TryStartProcessingEventAsync

 /// <summary>
 /// Attempts to start processing a compilation event for the given analyzer.
 /// </summary>
 /// <returns>
 /// Returns null if the event has already been processed for the analyzer OR is currently being processed by another task.
 /// Otherwise, returns a non-null state representing partial analysis state for the given event for the given analyzer.
 /// </returns>
 public Task<AnalyzerStateData> TryStartProcessingEventAsync(CompilationEvent compilationEvent, DiagnosticAnalyzer analyzer, CancellationToken cancellationToken)
 {
     return GetAnalyzerState(analyzer).TryStartProcessingEventAsync(compilationEvent, cancellationToken);
 }
开发者ID:ralfkang,项目名称:roslyn,代码行数:11,代码来源:AnalysisState.cs


示例13: OnCompilationEventProcessedAsync

        /// <summary>
        /// Invoke this method at completion of event processing for the given analysis scope.
        /// It updates the analysis state of this event for each analyzer and if the event has been fully processed for all analyzers, then removes it from our event cache.
        /// </summary>
        public async Task OnCompilationEventProcessedAsync(CompilationEvent compilationEvent, AnalysisScope analysisScope, CancellationToken cancellationToken)
        {
            // Analyze if the symbol and all its declaring syntax references are analyzed.
            var symbolDeclaredEvent = compilationEvent as SymbolDeclaredCompilationEvent;
            if (symbolDeclaredEvent != null)
            {
                await OnSymbolDeclaredEventProcessedAsync(symbolDeclaredEvent, analysisScope.Analyzers, cancellationToken).ConfigureAwait(false);
            }

            // Check if event is fully analyzed for all analyzers.
            foreach (var analyzerState in _analyzerStates)
            {
                var eventAnalyzed = await analyzerState.IsEventAnalyzedAsync(compilationEvent, cancellationToken).ConfigureAwait(false);
                if (!eventAnalyzed)
                {
                    return;
                }
            }

            // Remove the event from event map.
            using (await _gate.DisposableWaitAsync(cancellationToken).ConfigureAwait(false))
            {
                UpdateEventsMap_NoLock(compilationEvent, add: false);
            }

            if (symbolDeclaredEvent != null)
            {
                AnalyzerDriver.RemoveCachedDeclaringReferences(symbolDeclaredEvent.Symbol, symbolDeclaredEvent.Compilation);
            }
        }
开发者ID:ralfkang,项目名称:roslyn,代码行数:34,代码来源:AnalysisState.cs


示例14: UpdateEventsMap_NoLock

 private void UpdateEventsMap_NoLock(CompilationEvent compilationEvent, bool add)
 {
     var symbolEvent = compilationEvent as SymbolDeclaredCompilationEvent;
     if (symbolEvent != null)
     {
         // Add/remove symbol events.
         // Any diagnostics request for a tree should trigger symbol and syntax node analysis for symbols with at least one declaring reference in the tree.
         foreach (var location in symbolEvent.Symbol.Locations)
         {
             if (location.SourceTree != null)
             {
                 if (add)
                 {
                     AddPendingSourceEvent_NoLock(location.SourceTree, compilationEvent);
                 }
                 else
                 {
                     RemovePendingSourceEvent_NoLock(location.SourceTree, compilationEvent);
                 }
             }
         }
     }
     else
     {
         // Add/remove compilation unit completed events.
         var compilationUnitCompletedEvent = compilationEvent as CompilationUnitCompletedEvent;
         if (compilationUnitCompletedEvent != null)
         {
             var tree = compilationUnitCompletedEvent.SemanticModel.SyntaxTree;
             if (add)
             {
                 AddPendingSourceEvent_NoLock(tree, compilationEvent);
             }
             else
             {
                 RemovePendingSourceEvent_NoLock(tree, compilationEvent);
             }
         }
         else if (compilationEvent is CompilationStartedEvent || compilationEvent is CompilationCompletedEvent)
         {
             // Add/remove compilation events.
             if (add)
             {
                 _pendingNonSourceEvents.Add(compilationEvent);
             }
             else
             {
                 _pendingNonSourceEvents.Remove(compilationEvent);
             }
         }
         else
         {
             throw new InvalidOperationException("Unexpected compilation event of type " + compilationEvent.GetType().Name);
         }
     }
 }
开发者ID:Excoriate,项目名称:roslyn,代码行数:56,代码来源:AnalysisState.cs


示例15: RemovePendingSourceEvent_NoLock

 private void RemovePendingSourceEvent_NoLock(SyntaxTree tree, CompilationEvent compilationEvent)
 {
     HashSet<CompilationEvent> currentEvents;
     if (_pendingSourceEvents.TryGetValue(tree, out currentEvents))
     {
         if (currentEvents.Remove(compilationEvent) && currentEvents.Count == 0)
         {
             _pendingSourceEvents.Remove(tree);
             _compilationData.RemoveCachedSemanticModel(tree);
         }
     }
 }
开发者ID:bgarate,项目名称:roslyn,代码行数:12,代码来源:AnalysisState.cs


示例16: AddPendingSourceEvent_NoLock

        private void AddPendingSourceEvent_NoLock(SyntaxTree tree, CompilationEvent compilationEvent)
        {
            HashSet<CompilationEvent> currentEvents;
            if (!_pendingSourceEvents.TryGetValue(tree, out currentEvents))
            {
                currentEvents = _compilationEventsPool.Allocate();
                _pendingSourceEvents[tree] = currentEvents;
            }

            currentEvents.Add(compilationEvent);
        }
开发者ID:Excoriate,项目名称:roslyn,代码行数:11,代码来源:AnalysisState.cs


示例17: HasActionsForEvent

 private static bool HasActionsForEvent(CompilationEvent compilationEvent, AnalyzerActionCounts actionCounts)
 {
     if (compilationEvent is CompilationStartedEvent)
     {
         return actionCounts.CompilationActionsCount > 0 ||
             actionCounts.SyntaxTreeActionsCount > 0;
     }
     else if (compilationEvent is CompilationCompletedEvent)
     {
         return actionCounts.CompilationEndActionsCount > 0;
     }
     else if (compilationEvent is SymbolDeclaredCompilationEvent)
     {
         return actionCounts.SymbolActionsCount > 0 || actionCounts.HasAnyExecutableCodeActions;
     }
     else
     {
         return actionCounts.SemanticModelActionsCount > 0;
     }
 }
开发者ID:bgarate,项目名称:roslyn,代码行数:20,代码来源:AnalysisState.cs


示例18: HasActionsForEvent

 private static bool HasActionsForEvent(CompilationEvent compilationEvent, ActionCounts actionCounts)
 {
     if (compilationEvent is CompilationStartedEvent)
     {
         return actionCounts.CompilationActionsCount > 0 ||
             actionCounts.SyntaxTreeActionsCount > 0;
     }
     else if (compilationEvent is CompilationCompletedEvent)
     {
         return actionCounts.CompilationEndActionsCount > 0;
     }
     else if (compilationEvent is SymbolDeclaredCompilationEvent)
     {
         return actionCounts.CodeBlockActionsCount > 0 ||
             actionCounts.CodeBlockStartActionsCount > 0 ||
             actionCounts.SymbolActionsCount > 0 ||
             actionCounts.SyntaxNodeActionsCount > 0;
     }
     else
     {
         return actionCounts.SemanticModelActionsCount > 0;
     }
 }
开发者ID:Excoriate,项目名称:roslyn,代码行数:23,代码来源:AnalysisState.cs


示例19: MarkEventComplete

 /// <summary>
 /// Marks the given event as fully analyzed for the given analyzer.
 /// </summary>
 public void MarkEventComplete(CompilationEvent compilationEvent, DiagnosticAnalyzer analyzer)
 {
     GetAnalyzerState(analyzer).MarkEventComplete(compilationEvent);
 }
开发者ID:bgarate,项目名称:roslyn,代码行数:7,代码来源:AnalysisState.cs


示例20: TryStartProcessingEvent

 /// <summary>
 /// Attempts to start processing a compilation event for the given analyzer.
 /// </summary>
 /// <returns>
 /// Returns false if the event has already been processed for the analyzer OR is currently being processed by another task.
 /// If true, then it returns a non-null <paramref name="state"/> representing partial analysis state for the given event for the given analyzer.
 /// </returns>
 public bool TryStartProcessingEvent(CompilationEvent compilationEvent, DiagnosticAnalyzer analyzer, out AnalyzerStateData state)
 {
     return _analyzerStateMap[analyzer].TryStartProcessingEvent(compilationEvent, out state);
 }
开发者ID:Excoriate,项目名称:roslyn,代码行数:11,代码来源:AnalysisState.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Diagnostics.DiagnosticAnalyzer类代码示例发布时间:2022-05-26
下一篇:
C# Diagnostics.AnalyzerReference类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap