Fix using Dictionary as virtual method parameter in scripting bindings

This commit is contained in:
Wojtek Figat
2026-03-30 19:55:44 +02:00
parent b2457b6ee6
commit 2748216190

View File

@@ -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);