-
Notifications
You must be signed in to change notification settings - Fork 358
Closed
Labels
Description
Feature Request
Since we can only inspect proc macro generated code, but can't debug into it. It's necessary to add field read/write hook we can debug serialization field by field
Is your feature request related to a problem? Please describe
No response
Describe the solution you'd like
- Add a
fory_debugattr, when enabled, generate hook code call to invoke external methods defined instruct_.rs. - Allow customize field hook methods for tests and more advanced debug
Example:
#[derive(ForyObject, Debug, PartialEq)]
#[fory_debug]
struct Person1 {
f1: Color1,
f2: Color1,
// skip
f3: Color2,
f5: Vec<Color1>,
f6: Option<Color1>,
f7: Option<Color1>,
f8: Color1,
last: i8,
}
fory_core::serializer::struct_::struct_before_read_field(
"Animal1",
"f3",
context,
);
if !_field.field_type.nullable {
_f3 = Some(
<Vec<i8> as fory_core::Serializer>::fory_read_data(context)?,
);
} else {
_f3 = Some(
<Vec<
i8,
> as fory_core::Serializer>::fory_read(
context,
true,
false,
)?,
);
}
fory_core::serializer::struct_::struct_after_read_field(
"Animal1",
"f3",
(&_f3) as &dyn std::any::Any,
context,
);Describe alternatives you've considered
No response
Additional context
No response