Fix mismatched types in C# source gen

This commit is contained in:
grovre
2025-02-02 23:37:13 -06:00
parent ea249e3595
commit b244f7b292
2 changed files with 12 additions and 2 deletions

View File

@@ -41,7 +41,13 @@ impl CodeWriter for SchemaMap {
.members
.iter()
.map(|member| {
format!("{} = {:#X}", member.name, member.value)
let hex = format!("{:#X}", member.value);
let cast = if member.value == -1 {
format!("unchecked(({})-1)", type_name)
} else {
format!("{}", hex)
};
format!("{} = {}", member.name, cast)
})
.collect::<Vec<_>>()
.join(",\n");