Removed blittable constraint on ToArray and ToEnumerable

pull/83/head
David Hall 2019-11-21 16:33:39 -07:00
parent 2c94f7cdde
commit ce3dc1a0fe
1 changed files with 2 additions and 2 deletions

View File

@ -367,7 +367,7 @@ namespace Vanara.InteropServices
if (IsInvalid) return null;
//if (Size < Marshal.SizeOf(typeof(T)) * count + prefixBytes)
// throw new InsufficientMemoryException("Requested array is larger than the memory allocated.");
if (!typeof(T).IsBlittable()) throw new ArgumentException(@"Structure layout is not sequential or explicit.");
//if (!typeof(T).IsBlittable()) throw new ArgumentException(@"Structure layout is not sequential or explicit.");
Debug.Assert(typeof(T).StructLayoutAttribute?.Value == LayoutKind.Sequential);
return handle.ToArray<T>(count, prefixBytes, sz);
}
@ -384,7 +384,7 @@ namespace Vanara.InteropServices
if (IsInvalid) return new T[0];
//if (Size < Marshal.SizeOf(typeof(T)) * count + prefixBytes)
// throw new InsufficientMemoryException("Requested array is larger than the memory allocated.");
if (!typeof(T).IsBlittable()) throw new ArgumentException(@"Structure layout is not sequential or explicit.");
//if (!typeof(T).IsBlittable()) throw new ArgumentException(@"Structure layout is not sequential or explicit.");
Debug.Assert(typeof(T).StructLayoutAttribute?.Value == LayoutKind.Sequential);
return handle.ToIEnum<T>(count, prefixBytes, sz);
}