本文整理汇总了C#中AnalyzerExecutor类的典型用法代码示例。如果您正苦于以下问题:C# AnalyzerExecutor类的具体用法?C# AnalyzerExecutor怎么用?C# AnalyzerExecutor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnalyzerExecutor类属于命名空间,在下文中一共展示了AnalyzerExecutor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCompilationAnalysisScopeAsync
private async Task<HostCompilationStartAnalysisScope> GetCompilationAnalysisScopeAsync(
DiagnosticAnalyzer analyzer,
HostSessionStartAnalysisScope sessionScope,
AnalyzerExecutor analyzerExecutor)
{
var analyzerAndOptions = new AnalyzerAndOptions(analyzer, analyzerExecutor.AnalyzerOptions);
try
{
return await GetCompilationAnalysisScopeCoreAsync(analyzerAndOptions, sessionScope, analyzerExecutor).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
// Task to compute the scope was cancelled.
// Clear the entry in scope map for analyzer, so we can attempt a retry.
ConditionalWeakTable<Compilation, Task<HostCompilationStartAnalysisScope>> compilationActionsMap;
if (_compilationScopeMap.TryGetValue(analyzerAndOptions, out compilationActionsMap))
{
compilationActionsMap.Remove(analyzerExecutor.Compilation);
}
analyzerExecutor.CancellationToken.ThrowIfCancellationRequested();
return await GetCompilationAnalysisScopeAsync(analyzer, sessionScope, analyzerExecutor).ConfigureAwait(false);
}
}
示例2: GetSessionAnalysisScopeAsync
private async Task<HostSessionStartAnalysisScope> GetSessionAnalysisScopeAsync(
DiagnosticAnalyzer analyzer,
AnalyzerExecutor analyzerExecutor)
{
var analyzerExecutionContext = _analyzerExecutionContextMap.GetOrCreateValue(analyzer);
return await GetSessionAnalysisScopeCoreAsync(analyzer, analyzerExecutor, analyzerExecutionContext).ConfigureAwait(false);
}
示例3: DiagnosticIncrementalAnalyzer
public DiagnosticIncrementalAnalyzer(DiagnosticAnalyzerService owner, int correlationId, Workspace workspace, AnalyzerManager analyzerManager)
{
_owner = owner;
_correlationId = correlationId;
_memberRangeMap = new MemberRangeMap();
_analyzersAndState = new DiagnosticAnalyzersAndStates(this, workspace, analyzerManager);
_executor = new AnalyzerExecutor(this);
_diagnosticLogAggregator = new DiagnosticLogAggregator(_owner);
}
示例4: ClearCompilationScopeMap
private void ClearCompilationScopeMap(AnalyzerAndOptions analyzerAndOptions, AnalyzerExecutor analyzerExecutor)
{
ConditionalWeakTable<Compilation, Task<HostCompilationStartAnalysisScope>> compilationActionsCache;
lock (_compilationScopeMap)
{
if (_compilationScopeMap.TryGetValue(analyzerAndOptions, out compilationActionsCache))
{
compilationActionsCache.Remove(analyzerExecutor.Compilation);
}
}
}
示例5: DiagnosticIncrementalAnalyzer
public DiagnosticIncrementalAnalyzer(
DiagnosticAnalyzerService owner,
int correlationId,
Workspace workspace,
HostAnalyzerManager analyzerManager,
AbstractHostDiagnosticUpdateSource hostDiagnosticUpdateSource)
: base(owner, workspace, analyzerManager, hostDiagnosticUpdateSource)
{
_correlationId = correlationId;
_memberRangeMap = new MemberRangeMap();
_executor = new AnalyzerExecutor(this);
_stateManager = new StateManager(analyzerManager);
_stateManager.ProjectAnalyzerReferenceChanged += OnProjectAnalyzerReferenceChanged;
}
示例6: DiagnosticIncrementalAnalyzer
public DiagnosticIncrementalAnalyzer(
DiagnosticAnalyzerService owner,
int correlationId,
Workspace workspace,
HostAnalyzerManager analyzerManager,
AbstractHostDiagnosticUpdateSource hostDiagnosticUpdateSource)
: base(owner, workspace, analyzerManager, hostDiagnosticUpdateSource)
{
_correlationId = correlationId;
_memberRangeMap = new MemberRangeMap();
_executor = new AnalyzerExecutor(this);
_eventQueue = new SimpleTaskQueue(TaskScheduler.Default);
_stateManager = new StateManager(analyzerManager);
_stateManager.ProjectAnalyzerReferenceChanged += OnProjectAnalyzerReferenceChanged;
_solutionCrawlerAnalysisState = new SolutionCrawlerAnalysisState(analyzerManager);
}
示例7: Initialize
/// <summary>
/// Initializes the compilation for the analyzer driver.
/// It also computes and initializes <see cref="analyzerActions"/> and <see cref="_symbolActionsByKind"/>.
/// Finally, it initializes and starts the <see cref="_primaryTask"/> for the driver.
/// </summary>
/// <remarks>
/// NOTE: This method must only be invoked from <see cref="AnalyzerDriver.Create(Compilation, ImmutableArray{DiagnosticAnalyzer}, AnalyzerOptions, AnalyzerManager, Action{Diagnostic}, out Compilation, CancellationToken)"/>.
/// </remarks>
private void Initialize(Compilation comp, AnalyzerExecutor analyzerExecutor, CancellationToken cancellationToken)
{
try
{
Debug.Assert(_compilation == null);
Debug.Assert(comp.EventQueue == this.CompilationEventQueue);
_compilation = comp;
this.analyzerExecutor = analyzerExecutor;
// Compute the set of effective actions based on suppression, and running the initial analyzers
var analyzerActionsTask = GetAnalyzerActionsAsync(_analyzers, analyzerManager, analyzerExecutor);
var initializeTask = analyzerActionsTask.ContinueWith(t =>
{
this.analyzerActions = t.Result;
_symbolActionsByKind = MakeSymbolActionsByKind();
_semanticModelActionsMap = MakeSemanticModelActionsByAnalyzer();
_compilationActionsMap = MakeCompilationActionsByAnalyzer(this.analyzerActions.CompilationActions);
_compilationEndActionsMap = MakeCompilationActionsByAnalyzer(this.analyzerActions.CompilationEndActions);
}, cancellationToken, TaskContinuationOptions.None, TaskScheduler.Default);
// create the primary driver task.
cancellationToken.ThrowIfCancellationRequested();
_primaryTask = Task.Run(async () =>
{
await initializeTask.ConfigureAwait(false);
await ProcessCompilationEventsAsync(cancellationToken).ConfigureAwait(false);
}, cancellationToken)
.ContinueWith(c => DiagnosticQueue.TryComplete(), cancellationToken, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default);
}
finally
{
if (_primaryTask == null)
{
// Set primaryTask to be a cancelled task.
var tcs = new TaskCompletionSource<int>();
tcs.SetCanceled();
_primaryTask = tcs.Task;
// Try to set the DiagnosticQueue to be complete.
this.DiagnosticQueue.TryComplete();
}
}
}
示例8: GetCompilationAnalysisScopeAsync
public Task<HostCompilationStartAnalysisScope> GetCompilationAnalysisScopeAsync(
HostSessionStartAnalysisScope sessionScope,
AnalyzerExecutor analyzerExecutor)
{
Func<Compilation, Task<HostCompilationStartAnalysisScope>> getTask = comp =>
{
return Task.Run(() =>
{
var compilationAnalysisScope = new HostCompilationStartAnalysisScope(sessionScope);
analyzerExecutor.ExecuteCompilationStartActions(sessionScope.CompilationStartActions, compilationAnalysisScope);
return compilationAnalysisScope;
}, analyzerExecutor.CancellationToken);
};
var callback = new ConditionalWeakTable<Compilation, Task<HostCompilationStartAnalysisScope>>.CreateValueCallback(getTask);
var compilationActionsCache = GetOrCreateCompilationActionsCache(analyzerExecutor.AnalyzerOptions);
return compilationActionsCache.GetValue(analyzerExecutor.Compilation, callback);
}
示例9: GetCompilationAnalysisScopeCoreAsync
private Task<HostCompilationStartAnalysisScope> GetCompilationAnalysisScopeCoreAsync(
AnalyzerAndOptions analyzerAndOptions,
HostSessionStartAnalysisScope sessionScope,
AnalyzerExecutor analyzerExecutor)
{
Func<Compilation, Task<HostCompilationStartAnalysisScope>> getTask = comp =>
{
return Task.Run(() =>
{
var compilationAnalysisScope = new HostCompilationStartAnalysisScope(sessionScope);
analyzerExecutor.ExecuteCompilationStartActions(sessionScope.CompilationStartActions, compilationAnalysisScope);
return compilationAnalysisScope;
}, analyzerExecutor.CancellationToken);
};
var callback = new ConditionalWeakTable<Compilation, Task<HostCompilationStartAnalysisScope>>.CreateValueCallback(getTask);
var compilationActionsMap = _compilationScopeMap.GetOrAdd(analyzerAndOptions, new ConditionalWeakTable<Compilation, Task<HostCompilationStartAnalysisScope>>());
return compilationActionsMap.GetValue(analyzerExecutor.Compilation, callback);
}
示例10: GetCompilationAnalysisScopeCoreAsync
private async Task<HostCompilationStartAnalysisScope> GetCompilationAnalysisScopeCoreAsync(
HostSessionStartAnalysisScope sessionScope,
AnalyzerExecutor analyzerExecutor,
AnalyzerExecutionContext analyzerExecutionContext)
{
try
{
return await analyzerExecutionContext.GetCompilationAnalysisScopeAsync(sessionScope, analyzerExecutor).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
// Task to compute the scope was cancelled.
// Clear the entry in scope map for analyzer, so we can attempt a retry.
analyzerExecutionContext.ClearCompilationScopeMap(analyzerExecutor.AnalyzerOptions, analyzerExecutor.Compilation);
analyzerExecutor.CancellationToken.ThrowIfCancellationRequested();
return await GetCompilationAnalysisScopeCoreAsync(sessionScope, analyzerExecutor, analyzerExecutionContext).ConfigureAwait(false);
}
}
示例11: GetSessionAnalysisScopeCoreAsync
private async Task<HostSessionStartAnalysisScope> GetSessionAnalysisScopeCoreAsync(
DiagnosticAnalyzer analyzer,
AnalyzerExecutor analyzerExecutor,
AnalyzerExecutionContext analyzerExecutionContext)
{
try
{
var task = analyzerExecutionContext.GetSessionAnalysisScopeTask(analyzer, analyzerExecutor);
return await task.ConfigureAwait(false);
}
catch (OperationCanceledException)
{
// Task to compute the scope was cancelled.
// Clear the entry in scope map for analyzer, so we can attempt a retry.
analyzerExecutionContext.ClearSessionScopeTask();
analyzerExecutor.CancellationToken.ThrowIfCancellationRequested();
return await GetSessionAnalysisScopeCoreAsync(analyzer, analyzerExecutor, analyzerExecutionContext).ConfigureAwait(false);
}
}
示例12: GetSessionAnalysisScopeTask
public Task<HostSessionStartAnalysisScope> GetSessionAnalysisScopeTask(DiagnosticAnalyzer analyzer, AnalyzerExecutor analyzerExecutor)
{
lock (_gate)
{
Task<HostSessionStartAnalysisScope> task;
if (_lazySessionScopeTask != null)
{
return _lazySessionScopeTask;
}
task = Task.Run(() =>
{
var sessionScope = new HostSessionStartAnalysisScope();
analyzerExecutor.ExecuteInitializeMethod(analyzer, sessionScope);
return sessionScope;
}, analyzerExecutor.CancellationToken);
_lazySessionScopeTask = task;
return task;
}
}
示例13: GetSessionAnalysisScopeCoreAsync
private Task<HostSessionStartAnalysisScope> GetSessionAnalysisScopeCoreAsync(
DiagnosticAnalyzer analyzer,
AnalyzerExecutor analyzerExecutor)
{
Func<DiagnosticAnalyzer, Task<HostSessionStartAnalysisScope>> getTask = a =>
{
return Task.Run(() =>
{
var sessionScope = new HostSessionStartAnalysisScope();
analyzerExecutor.ExecuteInitializeMethod(a, sessionScope);
return sessionScope;
}, analyzerExecutor.CancellationToken);
};
return _sessionScopeMap.GetOrAdd(analyzer, getTask);
}
示例14: IsDiagnosticAnalyzerSuppressed
/// <summary>
/// Returns true if all the diagnostics that can be produced by this analyzer are suppressed through options.
/// </summary>
internal bool IsDiagnosticAnalyzerSuppressed(
DiagnosticAnalyzer analyzer,
CompilationOptions options,
Func<DiagnosticAnalyzer, bool> isCompilerAnalyzer,
AnalyzerExecutor analyzerExecutor)
{
if (isCompilerAnalyzer(analyzer))
{
// Compiler analyzer must always be executed for compiler errors, which cannot be suppressed or filtered.
return false;
}
var supportedDiagnostics = GetSupportedDiagnosticDescriptors(analyzer, analyzerExecutor);
var diagnosticOptions = options.SpecificDiagnosticOptions;
foreach (var diag in supportedDiagnostics)
{
if (HasNotConfigurableTag(diag.CustomTags))
{
if (diag.IsEnabledByDefault)
{
// Diagnostic descriptor is not configurable, so the diagnostics created through it cannot be suppressed.
return false;
}
else
{
// NotConfigurable disabled diagnostic can be ignored as it is never reported.
continue;
}
}
// Is this diagnostic suppressed by default (as written by the rule author)
var isSuppressed = !diag.IsEnabledByDefault;
// If the user said something about it, that overrides the author.
if (diagnosticOptions.ContainsKey(diag.Id))
{
isSuppressed = diagnosticOptions[diag.Id] == ReportDiagnostic.Suppress;
}
if (!isSuppressed)
{
return false;
}
}
return true;
}
示例15: IsSupportedDiagnostic
internal bool IsSupportedDiagnostic(DiagnosticAnalyzer analyzer, Diagnostic diagnostic, Func<DiagnosticAnalyzer, bool> isCompilerAnalyzer, AnalyzerExecutor analyzerExecutor)
{
// Avoid realizing all the descriptors for all compiler diagnostics by assuming that compiler analyzer doesn't report unsupported diagnostics.
if (isCompilerAnalyzer(analyzer))
{
return true;
}
// Get all the supported diagnostics and scan them linearly to see if the reported diagnostic is supported by the analyzer.
// The linear scan is okay, given that this runs only if a diagnostic is being reported and a given analyzer is quite unlikely to have hundreds of thousands of supported diagnostics.
var supportedDescriptors = GetSupportedDiagnosticDescriptors(analyzer, analyzerExecutor);
foreach (var descriptor in supportedDescriptors)
{
if (descriptor.Id.Equals(diagnostic.Id, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
return false;
}