From 1cd2f6a070f52589e775ccc00aa0609a550590fc Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 15 May 2024 13:23:30 +0200 Subject: [PATCH] Fix compilation when using non-strongly typed enum as default value --- .../Flax.Build/Bindings/BindingsGenerator.CSharp.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs index 8001ffc9a..a1ad9880d 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs @@ -267,13 +267,21 @@ namespace Flax.Build.Bindings if (value.Contains('(') && value.Contains(')')) return "new " + value; + // Special case for non-strongly typed enums + if (valueType != null && !value.Contains('.', StringComparison.Ordinal)) + { + apiType = FindApiTypeInfo(buildData, valueType, caller); + if (apiType is EnumInfo) + return $"{apiType.Name}.{value}"; + } + return value; } private static string GenerateCSharpNativeToManaged(BuildData buildData, TypeInfo typeInfo, ApiTypeInfo caller, bool marshalling = false) { string result; - if (typeInfo?.Type == null) + if (typeInfo == null || typeInfo.Type == null) throw new ArgumentNullException(); // Use dynamic array as wrapper container for fixed-size native arrays