Here's responsible code that throws on NativeArray, but seems like no such check is done for NativeList, which raises a concern: is NativeArray restriction is redundant or NativeList not checking is a bug?
[Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")]
private static void CheckAllocateArguments(int length, Allocator allocator)
{
if (allocator <= Allocator.None)
throw new ArgumentException("Allocator must be Temp, TempJob or Persistent", nameof (allocator));
if (allocator >= Allocator.FirstUserIndex)
throw new ArgumentException("Use CollectionHelper.CreateNativeArray for custom allocator", nameof (allocator));
if (length < 0)
throw new ArgumentOutOfRangeException(nameof (length), "Length must be >= 0");
}
@tropic harbor
is my understanding as well FWIW. We expose