project-overview
Dataforge 项目结构、核心模块及测试流程概览
Installation
Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.
View source ↗GuidesSkill instructions
Dataforge 项目概览
Dataforge 是一个功能类似于 freezed + json_serializable 的数据类生成库。
核心模块结构
-
dataforge_base 包含核心的代码生成逻辑 (Model, Parser, Writer)。这是
cli和generator的共同基础。 -
cli 命令行工具,用于独立生成代码。
- 入口:
bin/dataforge.dart - 依赖
dataforge_base
- 入口:
-
generator 基于
build_runner的生成器实现。- 用于
flutter pub run build_runner build - 依赖
dataforge_base
- 用于
架构说明:
generator和cli均依赖并共享dataforge_base的逻辑,确保生成行为一致。
开发与测试流程
Generator 测试
主要基于 build_test 和 source_gen 的 @ShouldGenerate 注解进行测试。
-
位置:
generator/test/ - 方法: 验证输入源代码 (source) 是否生成了预期的输出代码 (generated)。
CLI 测试
采用集成测试 (Integration Testing) 流程,模拟真实使用场景:
-
编写 Case: 在
cli/test/models/等目录编写包含@DataForge注解的 Dart 文件。 -
生成代码: 通过
bin/dataforge.dart运行生成命令,处理这些 Case 文件。 -
验证逻辑: 运行
test目录下的测试脚本,直接引用并测试生成的代码逻辑(如toJson,fromJson等)。
Examples
Read the usage examples in the source repository.
View source ↗Source history
- Indexed on
- 2026-01-20
- Index updated
- 2026-01-26
- Branch
- main
Index and sync dates describe this directory. View the source repository for code history.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!