mirror of https://github.com/dahall/Vanara.git
Changed Marshal.SizeOf to InteropExtensions.SizeOf to account for IVanaraMarshaler instances
parent
80b7256543
commit
61fe0f30d8
|
@ -222,7 +222,7 @@ namespace Vanara.InteropServices
|
||||||
ThrowIfDisposed();
|
ThrowIfDisposed();
|
||||||
if (!CanRead) throw new NotSupportedException();
|
if (!CanRead) throw new NotSupportedException();
|
||||||
if (fsize == 0) return Array.CreateInstance(elemType, 0);
|
if (fsize == 0) return Array.CreateInstance(elemType, 0);
|
||||||
var elemSize = elemType == typeof(string) || byRef ? IntPtr.Size : Marshal.SizeOf(elemType);
|
var elemSize = elemType == typeof(string) || byRef ? IntPtr.Size : (int)InteropExtensions.SizeOf(elemType);
|
||||||
var blockSize = elemSize * fsize;
|
var blockSize = elemSize * fsize;
|
||||||
if (Position + blockSize > Capacity) throw new ArgumentOutOfRangeException();
|
if (Position + blockSize > Capacity) throw new ArgumentOutOfRangeException();
|
||||||
Array ret;
|
Array ret;
|
||||||
|
@ -479,10 +479,10 @@ namespace Vanara.InteropServices
|
||||||
return es.Sum(s => s.GetByteCount(true, charSet));
|
return es.Sum(s => s.GetByteCount(true, charSet));
|
||||||
|
|
||||||
case IEnumerable<object> eo:
|
case IEnumerable<object> eo:
|
||||||
return eo.Sum(o => o is null ? 0 : Marshal.SizeOf(o));
|
return eo.Sum(o => o is null ? 0 : (int)InteropExtensions.SizeOf(o.GetType()));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return Marshal.SizeOf(obj);
|
return (int)InteropExtensions.SizeOf(obj.GetType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue