rojo-rbx / rbx-dom

Roblox DOM and (de)serialization implementation in Rust
MIT License
113 stars 46 forks source link

Make `rbx_binary` use nil UniqueId for default value #337

Closed Dekkonot closed 1 year ago

Dekkonot commented 1 year ago

Fully resolves #324 by making UniqueId's default a null value, which may appears many times in a file.

Due to #327, it shouldn't affect anyone, but it's more 'correct' behavior anyway, so it's what we should be doing.

Tested in a version where UniqueId serializes using the following code:

use std::fs::File;

use rbx_dom_weak::{types::UniqueId, InstanceBuilder, WeakDom};

fn main() {
    let dom = WeakDom::new(
        InstanceBuilder::new("Workspace").with_children([
            InstanceBuilder::new("Folder")
                .with_property("UniqueId", UniqueId::now().unwrap())
                .with_name("UniqueId set"),
            InstanceBuilder::new("Folder"),
            InstanceBuilder::new("Folder"),
            InstanceBuilder::new("Folder"),
        ]),
    );

    rbx_binary::to_writer(File::create("out.rbxl").unwrap(), &dom, &[dom.root_ref()]).unwrap()
}