Fixed bug when handling enums

pull/83/head
David Hall 2019-08-15 00:16:05 -07:00
parent 602f847bd8
commit a23ac2d587
1 changed files with 2 additions and 0 deletions

View File

@ -98,6 +98,8 @@ namespace Vanara.InteropServices
object GetBlittable(Type retType)
{
if (retType.IsEnum && Marshal.SizeOf(Enum.GetUnderlyingType(retType)) <= sz)
return Enum.ToObject(retType, Marshal.PtrToStructure(ptr, Enum.GetUnderlyingType(retType)));
if (Marshal.SizeOf(retType) <= sz)
return Marshal.PtrToStructure(ptr, retType);
throw SizeExc();