Files
Fishing2Server/Fantasy/Fantasy.Net/Fantasy.SourceGenerator/README_DEBUG.md
2025-10-29 17:59:43 +08:00

43 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Source Generator 调试指南
## 当前状态
生成器已编译成功,但没有生成任何代码文件。
## 可能的原因
1. **类型匹配问题**:生成器的 `IsSystemClass``GetSystemType` 方法无法正确识别 System 类
2. **Incremental Generator Pipeline 问题**Pipeline 可能过滤掉了所有候选类
3. **命名空间不匹配**:生成器可能在寻找错误的命名空间
## 调试步骤
### 方法 1简化生成器逻辑
`IsSystemClass` 改为返回 `true` 以查看是否有任何类被处理:
```csharp
private static bool IsSystemClass(SyntaxNode node)
{
return node is ClassDeclarationSyntax; // 处理所有类
}
```
### 方法 2查看生成器输出
```bash
# 启用详细日志
dotnet build /p:EmitCompilerGeneratedFiles=true /p:CompilerGeneratedFilesOutputPath=Generated
# 查看生成的文件
ls -la Generated/
```
### 方法 3使用 LinqPad/RoslynPad 测试
创建独立的测试项目来验证 Roslyn API 调用。
## 下一步
建议先尝试方法 2查看 MSBuild 是否能输出生成的文件。