mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
using System.Collections.Immutable;
|
|
using CliFx.Analyzers.Utils.Extensions;
|
|
using Microsoft.CodeAnalysis;
|
|
using Microsoft.CodeAnalysis.Diagnostics;
|
|
|
|
namespace CliFx.Analyzers
|
|
{
|
|
public abstract class AnalyzerBase : DiagnosticAnalyzer
|
|
{
|
|
public DiagnosticDescriptor SupportedDiagnostic { get; }
|
|
|
|
public sealed override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }
|
|
|
|
protected AnalyzerBase(
|
|
string diagnosticTitle,
|
|
string diagnosticMessage,
|
|
DiagnosticSeverity diagnosticSeverity = DiagnosticSeverity.Error)
|
|
{
|
|
SupportedDiagnostic = new DiagnosticDescriptor(
|
|
"CliFx_" + GetType().Name.TrimEnd("Analyzer"),
|
|
diagnosticTitle,
|
|
diagnosticMessage,
|
|
"CliFx",
|
|
diagnosticSeverity,
|
|
true
|
|
);
|
|
|
|
SupportedDiagnostics = ImmutableArray.Create(SupportedDiagnostic);
|
|
}
|
|
|
|
protected Diagnostic CreateDiagnostic(Location location) =>
|
|
Diagnostic.Create(SupportedDiagnostic, location);
|
|
|
|
public override void Initialize(AnalysisContext context)
|
|
{
|
|
context.EnableConcurrentExecution();
|
|
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
|
|
}
|
|
}
|
|
} |