示例工程 17-reflection-keypaths
17-reflection-keypaths/README.md
# 第 17 章示例 · 反射与 KeyPath
`Mirror` 读取存储属性与嵌套结构、`WritableKeyPath` 泛型写入、KeyPath 排序、`@dynamicMemberLookup`、`@dynamicCallable`、`ObjectIdentifier` 身份比较,以及 KeyPath 的 8 字节句柄。
## 运行
swift run Ch17Demo
## 验证
swift test # 12 个测试
./run.sh # build + test + 快照比对
## 结构
| 文件 | 对应小节 | 说明 |
| --- | --- | --- |
| `Sources/Ch17Kit/MirrorLab.swift` | 17.1 / 17.2 | Mirror 读取、嵌套展开 |
| `Sources/Ch17Kit/KeyPathLab.swift` | 17.3–17.7 | KeyPath 读写、动态成员/调用、身份 |
| `Sources/Ch17Demo/App.swift` | 17.8 | 固定输出与布局 |
## 已知限制
`Mirror` 的输出顺序按声明顺序,但不保证跨编译器版本稳定;示例只对存储属性做断言,不对字符串拼接的完整格式做跨版本承诺。