diff --git a/Core/Extensions/InteropExtensions.cs b/Core/Extensions/InteropExtensions.cs index 65e4e32a..399ab839 100644 --- a/Core/Extensions/InteropExtensions.cs +++ b/Core/Extensions/InteropExtensions.cs @@ -659,7 +659,7 @@ namespace Vanara.Extensions /// If known, the total number of bytes allocated to the native memory in . /// The number of bytes written. The offset is not included. /// - public static int Write(this IntPtr ptr, T value, int offset = 0, SizeT allocatedBytes = default) where T : struct => + public static int Write(this IntPtr ptr, in T value, int offset = 0, SizeT allocatedBytes = default) where T : struct => WriteNoChecks(ptr, value, offset, allocatedBytes); internal static Type TrueType(Type type, out int size) diff --git a/Core/InteropServices/SafeMemoryHandle.cs b/Core/InteropServices/SafeMemoryHandle.cs index 33763614..79e035f8 100644 --- a/Core/InteropServices/SafeMemoryHandle.cs +++ b/Core/InteropServices/SafeMemoryHandle.cs @@ -426,7 +426,7 @@ namespace Vanara.InteropServices /// The value to write. /// if set to true automatically extend the allocated memory to the size required to hold . /// The number of bytes to offset from the beginning of this allocated memory before writing. - public void Write(T value, bool autoExtend = true, int offset = 0) where T : struct + public void Write(in T value, bool autoExtend = true, int offset = 0) where T : struct { if (IsInvalid) throw new MemberAccessException("Safe memory pointer is not valid."); if (autoExtend)