Merge branch 'fixedalloc-maxcount' of https://github.com/Tryibion/FlaxEngine into Tryibion-fixedalloc-maxcount
This commit is contained in:
@@ -898,6 +898,30 @@ namespace Flax.Build.Bindings
|
||||
if (defaultValue != null)
|
||||
contents.Append(indent).Append("[DefaultValue(").Append(defaultValue).Append(")]").AppendLine();
|
||||
}
|
||||
|
||||
// Check if array has fixed allocation and add in MaxCount Collection attribute if a Collection attribute does not already exist.
|
||||
if (defaultValueType != null && (string.IsNullOrEmpty(attributes) || !attributes.Contains("Collection", StringComparison.Ordinal)))
|
||||
{
|
||||
// Array or Span or DataContainer
|
||||
#if USE_NETCORE
|
||||
if ((defaultValueType.Type == "Array" || defaultValueType.Type == "Span" || defaultValueType.Type == "DataContainer" || defaultValueType.Type == "MonoArray" || defaultValueType.Type == "MArray") && defaultValueType.GenericArgs != null)
|
||||
#else
|
||||
if ((defaultValueType.Type == "Array" || defaultValueType.Type == "Span" || defaultValueType.Type == "DataContainer") && defaultValueType.GenericArgs != null)
|
||||
#endif
|
||||
{
|
||||
if (defaultValueType.GenericArgs.Count > 1)
|
||||
{
|
||||
var allocationArg = defaultValueType.GenericArgs[1];
|
||||
if (allocationArg.Type.Contains("FixedAllocation", StringComparison.Ordinal) && allocationArg.GenericArgs.Count > 0)
|
||||
{
|
||||
if (int.TryParse(allocationArg.GenericArgs[0].ToString(), out int allocation))
|
||||
{
|
||||
contents.Append(indent).Append($"[Collection(MaxCount={allocation.ToString()})]").AppendLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void GenerateCSharpAttributes(BuildData buildData, StringBuilder contents, string indent, ApiTypeInfo apiTypeInfo, bool useUnmanaged, string defaultValue = null, TypeInfo defaultValueType = null)
|
||||
|
||||
Reference in New Issue
Block a user