IDLGenerators: Do not generate required dictionary members as Optional

This commit is contained in:
devgianlu 2024-12-31 14:48:38 +01:00 committed by Andrew Kaster
parent 348db1c445
commit e14511468f
Notes: github-actions[bot] 2025-02-05 20:19:57 +00:00

View file

@ -945,6 +945,9 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
bool may_be_null = !optional_default_value.has_value() || parameter.type->is_nullable() || optional_default_value.value() == "null";
// Required dictionary members cannot be null.
may_be_null &= !member.required;
if (member.type->is_string() && optional && may_be_null) {
dictionary_generator.append(R"~~~(
if (@member_value_name@.has_value())