diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs index 681483cf9..4bf6ae35a 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs @@ -24,7 +24,7 @@ namespace Flax.Build.Bindings private static readonly List CppAutoSerializeProperties = new List(); public static readonly HashSet CppIncludeFiles = new HashSet(); private static readonly List CppIncludeFilesList = new List(); - private static readonly HashSet CppVariantToTypes = new HashSet(); + private static readonly Dictionary CppVariantToTypes = new Dictionary(); private static readonly Dictionary CppVariantFromTypes = new Dictionary(); private static bool CppNonPodTypesConvertingGeneration = false; private static StringBuilder CppContentsEnd; @@ -231,13 +231,15 @@ namespace Flax.Build.Bindings throw new Exception($"Not supported type to convert from the Variant to fixed-size array '{typeInfo}[{typeInfo.ArraySize}]'."); if (typeInfo.Type == "Array" && typeInfo.GenericArgs != null) { - CppVariantToTypes.Add(typeInfo); - return $"MoveTemp(VariantTo{GenerateCppWrapperNativeToVariantMethodName(typeInfo)}({value}))"; + var wrapperName = GenerateCppWrapperNativeToVariantMethodName(typeInfo); + CppVariantToTypes[wrapperName] = typeInfo; + return $"MoveTemp(VariantTo{wrapperName}({value}))"; } if (typeInfo.Type == "Dictionary" && typeInfo.GenericArgs != null) { - CppVariantToTypes.Add(typeInfo); - return $"MoveTemp(VariantTo{GenerateCppWrapperNativeToVariantMethodName(typeInfo)}({value}))"; + var wrapperName = GenerateCppWrapperNativeToVariantMethodName(typeInfo); + CppVariantToTypes[wrapperName] = typeInfo; + return $"MoveTemp(VariantTo{wrapperName}({value}))"; } if (typeInfo.Type == "Span" && typeInfo.GenericArgs != null) { @@ -2790,12 +2792,14 @@ namespace Flax.Build.Bindings var header = GetStringBuilder(); // Variant converting helper methods - foreach (var typeInfo in CppVariantToTypes) + foreach (var e in CppVariantToTypes) { + var wrapperName = e.Key; + var typeInfo = e.Value; var name = typeInfo.ToString(false); header.AppendLine(); header.AppendLine("namespace {"); - header.Append($"{name} VariantTo{GenerateCppWrapperNativeToVariantMethodName(typeInfo)}(const Variant& v)").AppendLine(); + header.Append($"{name} VariantTo{wrapperName}(const Variant& v)").AppendLine(); header.Append('{').AppendLine(); header.Append($" {name} result;").AppendLine(); if (typeInfo.Type == "Array" && typeInfo.GenericArgs != null)