From 27482161902ac35adf0db30ec4709b169663edf4 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 30 Mar 2026 19:55:44 +0200 Subject: [PATCH] Fix using `Dictionary` as virtual method parameter in scripting bindings --- .../Flax.Build/Bindings/BindingsGenerator.Cpp.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs index 50d3aa85c..8002c66a5 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs @@ -997,6 +997,22 @@ namespace Flax.Build.Bindings if (typeInfo.Type == "BytesContainer" && typeInfo.GenericArgs == null) return $"MUtils::ToArray({value})"; + // Dictionary + if (typeInfo.Type == "Dictionary" && typeInfo.GenericArgs != null) + { + CppIncludeFiles.Add("Engine/Scripting/Internal/ManagedDictionary.h"); + var keyClass = GenerateCppGetNativeType(buildData, typeInfo.GenericArgs[0], caller); + var valueClass = GenerateCppGetNativeType(buildData, typeInfo.GenericArgs[1], caller); + return $"ManagedDictionary::ToManaged({value}, {keyClass}, {valueClass})"; + } + + // HashSet + if (typeInfo.Type == "HashSet" && typeInfo.GenericArgs != null) + { + // TODO: automatic converting managed-native for HashSet + throw new NotImplementedException("TODO: converting managed HashSet to native"); + } + // Construct native typename for MUtils template argument var nativeType = new StringBuilder(64); nativeType.Append(typeInfo.Type);