-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DynamicScene
- Malformed enum when reserializing
#12462
Comments
DynamicScene
- Malformed tuple reserializing
This seems like a pretty straightforward reflection serde bug. If you submit a patch with a test I'll happily review it. |
Just tested it and can confirm this is a bug. Full reproCode: #[derive(Reflect, Default)]
enum MyEnum {
#[default]
Unit,
Tuple(String),
Struct {
value: u32,
},
}
let mut registry = TypeRegistry::default();
registry.register::<MyEnum>();
let value = MyEnum::Tuple("Hello world".to_string());
let serializer = ReflectSerializer::new(&value, ®istry);
let serialized = ron::ser::to_string(&serializer).unwrap();
println!("{}", serialized);
let mut deserializer = ron::de::Deserializer::from_str(&serialized).unwrap();
let reflect_deserializer = UntypedReflectDeserializer::new(®istry);
let value = reflect_deserializer.deserialize(&mut deserializer).unwrap();
println!("{:?}", value);
let serializer = ReflectSerializer::new(&*value, ®istry);
let serialized = ron::ser::to_string(&serializer).unwrap();
println!("{}", serialized); Output:
Edit 2: Actually actually this is happening in the deserializer. We're using |
DynamicScene
- Malformed tuple reserializingDynamicScene
- Malformed enum when reserializing
# Objective - Addresses #12462 - When we serialize an enum, deserialize it, then reserialize it, the correct variant should be selected. ## Solution - Change `dynamic_enum.set_variant` to `dynamic_enum.set_variant_with_index` in `EnumVisitor`
Closed by #12464 |
# Objective - Addresses #12462 - When we serialize an enum, deserialize it, then reserialize it, the correct variant should be selected. ## Solution - Change `dynamic_enum.set_variant` to `dynamic_enum.set_variant_with_index` in `EnumVisitor`
Bevy version
0.14.0-dev
0.13.1
0.12.1
0.10.0
Relevant system information
What you did
What went wrong
Enums use the name of the first variant with the value of another:
Will serialize
MyEnum::Tuple("Hello World")
asUnit("Hello World")
.Steps to reproduce
Add the following to the
should_roundtrip_bincode
test crates\bevy_scene\src\serde.rs:868Will output:
Additional information
bincode
but same behavior forron
,serde_json
etc0.10
, is this intended behavior?The text was updated successfully, but these errors were encountered: