gewuyou 1454c81a5b docs(adoption): 收口安装入口与公开文案
- 更新安装页的选包矩阵、推荐组合与 Godot 基线说明
- 收口公开 README 的 XML 阅读入口表述,移除治理式计数与日期字段
- 调整配置系统与基础教程入口的 reader-facing 文案,并同步更新恢复文档
2026-04-27 07:42:10 +08:00

80 lines
2.6 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.

# GFramework.Game.SourceGenerators
`GFramework.Game.SourceGenerators` 负责把 `schemas/**/*.schema.json` 转成游戏内容配置类型和表包装代码。
它服务的核心场景是:让 `YAML` 配置、`JSON Schema`、运行时加载器和工具链共享一套结构定义。
## 模块定位
这个包是编译期生成器,不是运行时库。
它会在编译期读取 schema并生成
- 配置数据类型
- 对应的表包装类型
-`GFramework.Game.Config` 运行时协作的访问辅助代码
## 包关系
- 运行时:`GFramework.Game`
- 生成器:`GFramework.Game.SourceGenerators`
- 公共生成器支撑:`GFramework.SourceGenerators.Common`
如果你的项目还会使用 `[Log]``[ContextAware]` 或 Core 侧上下文注入特性,还需要同时安装
`GFramework.Core.SourceGenerators`
## 目录与输入约定
当前项目结构显示该生成器主要围绕以下代码组织:
- `Config/SchemaConfigGenerator.cs`
- `Diagnostics/ConfigSchemaDiagnostics.cs`
- `GeWuYou.GFramework.Game.SourceGenerators.targets`
消费者项目的推荐目录约定:
```text
GameProject/
├─ config/
│ └─ monster/
│ └─ slime.yaml
└─ schemas/
└─ monster.schema.json
```
默认情况下,打包产物会通过 `targets``schemas/**/*.schema.json` 纳入 `AdditionalFiles`
## XML 阅读入口
下面这份目录视图用于帮助你定位 `GFramework.Game.SourceGenerators` 的生成器入口;具体诊断消息、生成输出和兼容性语义仍建议回到源码与测试继续核对。
| 类型族 | 代表类型 | 阅读重点 |
| --- | --- | --- |
| `Config/` | `SchemaConfigGenerator` | 看 schema 到配置类型 / 表包装 / 注册辅助代码的生成入口 |
| `Diagnostics/` | `ConfigSchemaDiagnostics` | 看生成器会抛出的诊断类别与失败边界 |
## 最小接入路径
```xml
<ItemGroup>
<PackageReference Include="GeWuYou.GFramework.Game" Version="x.y.z" />
<PackageReference Include="GeWuYou.GFramework.Game.SourceGenerators"
Version="x.y.z"
PrivateAssets="all"
ExcludeAssets="runtime" />
</ItemGroup>
```
如果你在仓库内用 `ProjectReference` 调试,仍需要把对应 `targets` 接进消费者项目。
## 什么时候使用它
- 你想把静态游戏内容维护成 `YAML`
- 你希望在编译期拿到强类型配置访问入口
- 你希望运行时加载、schema 校验和编辑工具链共用同一份结构定义
## 对应文档
- 配置系统:[配置系统文档](../docs/zh-CN/game/config-system.md)
- 源码生成器总览:[源码生成器文档首页](../docs/zh-CN/source-generators/index.md)