本文整理汇总了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);
}
示例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;
});
}
示例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;
}
示例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;
}
示例5: AnalyzerInfo
public AnalyzerInfo(DiagnosticAnalyzer analyzer, AnalyzerTelemetryInfo analyzerTelemetryInfo, bool telemetry)
{
CLRType = analyzer.GetType();
Telemetry = telemetry;
SetAnalyzerTypeCount(analyzerTelemetryInfo);
}
示例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));
}
}
}
}