GFramework/GFramework.SourceGenerators/Diagnostics/AutoRegisterModuleDiagnostics.cs
GeWuYou eb307bf188 feat(generator): 添加代码生成器诊断规则和测试用例
- 定义了 Godot 源代码生成器的诊断规则表格
- 添加了上下文获取生成器的全面单元测试
- 实现了自动生成行为和注册导出集合的诊断功能
- 配置了全局 using 语句简化代码生成器实现
- 添加了完整的分析器发布跟踪文档记录新规则
2026-04-13 10:01:46 +08:00

49 lines
1.9 KiB
C#

using GFramework.SourceGenerators.Common.Constants;
namespace GFramework.SourceGenerators.Diagnostics;
internal static class AutoRegisterModuleDiagnostics
{
private const string Category = $"{PathContests.SourceGeneratorsPath}.Architecture";
public static readonly DiagnosticDescriptor NestedClassNotSupported = new(
"GF_AutoModule_001",
"AutoRegisterModule does not support nested classes",
"AutoRegisterModule does not support nested class '{0}'",
Category,
DiagnosticSeverity.Error,
true);
public static readonly DiagnosticDescriptor RegistrationTypeRequired = new(
"GF_AutoModule_002",
"Registration attribute requires a concrete type",
"Attribute '{0}' on '{1}' requires a concrete type argument",
Category,
DiagnosticSeverity.Error,
true);
public static readonly DiagnosticDescriptor InstallMethodConflict = new(
"GF_AutoModule_005",
"Install method conflicts with generated code",
"Class '{0}' already defines 'Install(IArchitecture)', which conflicts with AutoRegisterModule generated code",
Category,
DiagnosticSeverity.Error,
true);
public static readonly DiagnosticDescriptor RegistrationTypeMustImplementExpectedInterface = new(
"GF_AutoModule_003",
"Registration type does not implement the expected interface",
"Type '{0}' used by '{1}' must implement '{2}'",
Category,
DiagnosticSeverity.Error,
true);
public static readonly DiagnosticDescriptor RegistrationTypeMustHaveParameterlessConstructor = new(
"GF_AutoModule_004",
"Registration type must have an accessible parameterless constructor",
"Type '{0}' used by '{1}' must have an accessible parameterless constructor",
Category,
DiagnosticSeverity.Error,
true);
}