using Microsoft.CodeAnalysis;
namespace GFramework.SourceGenerators.Diagnostics;
///
/// 提供 Context Get 注入生成器相关诊断。
///
public static class ContextGetDiagnostics
{
///
/// 不支持在嵌套类中生成注入代码。
///
public static readonly DiagnosticDescriptor NestedClassNotSupported = new(
"GF_ContextGet_001",
"Context Get injection does not support nested classes",
"Class '{0}' cannot use context Get injection inside a nested type",
"GFramework.SourceGenerators.Rule",
DiagnosticSeverity.Error,
true);
///
/// 带注入语义的字段不能是静态字段。
///
public static readonly DiagnosticDescriptor StaticFieldNotSupported = new(
"GF_ContextGet_002",
"Static field is not supported for context Get injection",
"Field '{0}' cannot be static when using generated context Get injection",
"GFramework.SourceGenerators.Rule",
DiagnosticSeverity.Error,
true);
///
/// 带注入语义的字段不能是只读字段。
///
public static readonly DiagnosticDescriptor ReadOnlyFieldNotSupported = new(
"GF_ContextGet_003",
"Readonly field is not supported for context Get injection",
"Field '{0}' cannot be readonly when using generated context Get injection",
"GFramework.SourceGenerators.Rule",
DiagnosticSeverity.Error,
true);
///
/// 字段类型与注入特性不匹配。
///
public static readonly DiagnosticDescriptor InvalidBindingType = new(
"GF_ContextGet_004",
"Field type is not valid for the selected context Get attribute",
"Field '{0}' type '{1}' is not valid for [{2}]",
"GFramework.SourceGenerators.Rule",
DiagnosticSeverity.Error,
true);
///
/// 使用 Context Get 注入的类型必须是上下文感知类型。
///
public static readonly DiagnosticDescriptor ContextAwareTypeRequired = new(
"GF_ContextGet_005",
"Context-aware type is required",
"Class '{0}' must be context-aware to use generated context Get injection",
"GFramework.SourceGenerators.Rule",
DiagnosticSeverity.Error,
true);
///
/// 一个字段不允许同时声明多个 Context Get 特性。
///
public static readonly DiagnosticDescriptor MultipleBindingAttributesNotSupported = new(
"GF_ContextGet_006",
"Multiple context Get attributes are not supported on the same field",
"Field '{0}' cannot declare multiple generated context Get attributes",
"GFramework.SourceGenerators.Rule",
DiagnosticSeverity.Error,
true);
}