aboutsummaryrefslogtreecommitdiff
path: root/lib/Utils
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2024-05-22 17:49:57 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2024-05-22 17:49:57 -0400
commit1b590c2517fef110564943ed8a10edd11fa758b0 (patch)
tree09d3bef07200edff5654ccc47772bebbc54e94ed /lib/Utils
parent107b058a38d6785b350826c6fb01bb64997c630a (diff)
Squashed commit of the following:
commit 9a835fe12c9586ab8dd44d7c96fef4a2d6017e4b Author: vnugent <public@vaughnnugent.com> Date: Fri May 17 18:27:03 2024 -0400 chore: Update mimmaloc v2.1.6, update fPIC & cleanup commit 3b7004b88acfc7f7baa3a8857a5a2f7cf3dd560e Author: vnugent <public@vaughnnugent.com> Date: Fri May 17 16:03:28 2024 -0400 feat: Added ReadFileDataAsync function commit 9a964795757bf0da4dd7fcab15ad304f4ea3fdf1 Author: vnugent <public@vaughnnugent.com> Date: Wed May 15 21:57:39 2024 -0400 refactor: Harden some argon2 password hashing commit 4035c838c1508af0aa7e767a97431a692958ce1c Author: vnugent <public@vaughnnugent.com> Date: Sun May 12 16:55:32 2024 -0400 perf: Utils + http perf mods commit f4f0d4f74250257991c57bfae74c4852c7e1ae46 Author: vnugent <public@vaughnnugent.com> Date: Thu May 2 15:22:53 2024 -0400 feat: Buff middleware handlers | | Added implicit support for middleware post processing of files before the filehandler closes the connection. Also cleaned up some project file stuff commit f0b7dca107659df1d7d4631fdbd2aae9d716d053 Merge: 8c4a45e 107b058 Author: vnugent <public@vaughnnugent.com> Date: Sat Apr 20 12:24:05 2024 -0400 Merge branch 'main' into develop commit 8c4a45e384accf92b1b6d748530e8d46f7de40d6 Author: vnugent <public@vaughnnugent.com> Date: Sat Apr 20 11:10:30 2024 -0400 refactor: Overhaul C libraries and fix builds commit 42ff77080d10b0fc9fecbbc46141e8e23a1d066a Author: vnugent <public@vaughnnugent.com> Date: Sat Apr 20 00:45:57 2024 -0400 fix!: Middlware array, multiple cookie set, and cookie check commit 97e82b9d66f387f9e6d21d88ddc7a8ab8693149c Merge: 4ca5791 e07537a Author: vnugent <public@vaughnnugent.com> Date: Tue Apr 2 13:34:22 2024 -0400 Merge branch 'main' into develop commit 4ca5791ed67b9834bdbd010206b30373e4705e9b Author: vnugent <public@vaughnnugent.com> Date: Tue Apr 2 13:32:12 2024 -0400 fix: Missed ! on null pointer check commit 9b4036377c52200c6488c98180d69a0e63321f97 Author: vnugent <public@vaughnnugent.com> Date: Tue Apr 2 13:22:29 2024 -0400 fix: Fix _In_ macro for compression public api commit 53a7b4b5c5b67b4a4e06e1d9098cac4bcd6afd7c Merge: 448a93b 21130c8 Author: vnugent <public@vaughnnugent.com> Date: Sun Mar 31 17:01:15 2024 -0400 Merge branch 'main' into develop commit 448a93bb1d18d032087afe2476ffccb98634a54c Author: vnugent <public@vaughnnugent.com> Date: Sun Mar 31 16:56:51 2024 -0400 ci: fix third-party dir cleanup commit 9afed1427472da1ea13079f98dbe27339e55ee7d Author: vnugent <public@vaughnnugent.com> Date: Sun Mar 31 16:43:15 2024 -0400 perf: Deprecate unsafememoryhandle span extensions commit 3ff90da4f02af47ea6d233fdd4445337ebe36452 Author: vnugent <public@vaughnnugent.com> Date: Sat Mar 30 21:36:18 2024 -0400 refactor: Updates, advanced tracing, http optimizations commit 8d6b79b5ae309b36f265ba81529bcef8bfcd7414 Merge: 6c1667b 5585915 Author: vnugent <public@vaughnnugent.com> Date: Sun Mar 24 21:01:31 2024 -0400 Merge branch 'main' into develop commit 6c1667be23597513537f8190e2f55d65eb9b7c7a Author: vnugent <public@vaughnnugent.com> Date: Fri Mar 22 12:01:53 2024 -0400 refactor: Overhauled native library loading and lazy init commit ebf688f2f974295beabf7b5def7e6f6f150551d0 Author: vnugent <public@vaughnnugent.com> Date: Wed Mar 20 22:16:17 2024 -0400 refactor: Update compression header files and macros + Ci build commit 9c7b564911080ccd5cbbb9851a0757b05e1e9047 Author: vnugent <public@vaughnnugent.com> Date: Tue Mar 19 21:54:49 2024 -0400 refactor: JWK overhaul & add length getter to FileUpload commit 6d8c3444e09561e5957491b3cc1ae858e0abdd14 Author: vnugent <public@vaughnnugent.com> Date: Mon Mar 18 16:13:20 2024 -0400 feat: Add FNV1a software checksum and basic correction tests commit 00d182088cecefc08ca80b1faee9bed3f215f40b Author: vnugent <public@vaughnnugent.com> Date: Fri Mar 15 01:05:27 2024 -0400 chore: #6 Use utils filewatcher instead of built-in commit d513c10d9895c6693519ef1d459c6a5a76929436 Author: vnugent <public@vaughnnugent.com> Date: Sun Mar 10 21:58:14 2024 -0400 source tree project location updated
Diffstat (limited to 'lib/Utils')
-rw-r--r--lib/Utils/src/Extensions/MemoryExtensions.cs70
-rw-r--r--lib/Utils/src/Extensions/StringExtensions.cs6
-rw-r--r--lib/Utils/src/Memory/ForwardOnlyWriter.cs108
-rw-r--r--lib/Utils/src/Memory/IUnmangedHeap.cs7
-rw-r--r--lib/Utils/src/Memory/MemoryUtil.CopyUtilCore.cs5
-rw-r--r--lib/Utils/src/Memory/NativeHeap.cs4
-rw-r--r--lib/Utils/src/Memory/UnmanagedHeapBase.cs2
-rw-r--r--lib/Utils/src/VNLib.Utils.csproj7
8 files changed, 148 insertions, 61 deletions
diff --git a/lib/Utils/src/Extensions/MemoryExtensions.cs b/lib/Utils/src/Extensions/MemoryExtensions.cs
index 65d90a0..c433527 100644
--- a/lib/Utils/src/Extensions/MemoryExtensions.cs
+++ b/lib/Utils/src/Extensions/MemoryExtensions.cs
@@ -146,8 +146,13 @@ namespace VNLib.Utils.Extensions
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static MemoryManager<T> DirectAlloc<T>(this IUnmangedHeap heap, nuint size, bool zero = false) where T : unmanaged
+ public static MemoryManager<T> DirectAlloc<T>(this IUnmangedHeap heap, int size, bool zero = false) where T : unmanaged
{
+ /*
+ * Size it limited to int32 because the memory manager uses int32 for length
+ * and the constructor will attempt to cast the size to int32 or cause an
+ * overflow exception
+ */
MemoryHandle<T> handle = heap.Alloc<T>(size, zero);
return new SysBufferMemoryManager<T>(handle, true);
}
@@ -177,24 +182,6 @@ namespace VNLib.Utils.Extensions
//Method only exists for consistancy since unsafe handles are always 32bit
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int GetIntLength<T>(this in UnsafeMemoryHandle<T> handle) where T : unmanaged => handle.IntLength;
-
- /// <summary>
- /// Allows direct allocation of a fixed size <see cref="MemoryManager{T}"/> from a <see cref="IUnmangedHeap"/> instance
- /// of the specified number of elements
- /// </summary>
- /// <typeparam name="T">The unmanaged data type</typeparam>
- /// <param name="heap"></param>
- /// <param name="size">The number of elements to allocate on the heap</param>
- /// <param name="zero">Optionally zeros conents of the block when allocated</param>
- /// <returns>The <see cref="MemoryManager{T}"/> wrapper around the block of memory</returns>
- /// <exception cref="OverflowException"></exception>
- /// <exception cref="ArgumentOutOfRangeException"></exception>
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static MemoryManager<T> DirectAlloc<T>(this IUnmangedHeap heap, nint size, bool zero = false) where T : unmanaged
- {
- ArgumentOutOfRangeException.ThrowIfNegative(size);
- return DirectAlloc<T>(heap, (nuint)size, zero);
- }
/// <summary>
/// Gets an offset pointer from the base postion to the number of bytes specified. Performs bounds checks
@@ -578,6 +565,27 @@ namespace VNLib.Utils.Extensions
#region VnBufferWriter
/// <summary>
+ /// Appends the string value by copying it to the internal buffer
+ /// </summary>
+ /// <param name="buffer"></param>
+ /// <param name="value">The string value to append to the buffer</param>
+ /// <exception cref="ArgumentOutOfRangeException"></exception>
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void Append(this ref ForwardOnlyWriter<char> buffer, string? value)
+ => buffer.Append(value.AsSpan());
+
+ /// <summary>
+ /// Appends the string value by copying it to the internal buffer
+ /// when the string is known to be very short.
+ /// </summary>
+ /// <param name="buffer"></param>
+ /// <param name="value">The string value to append to the buffer</param>
+ /// <exception cref="ArgumentOutOfRangeException"></exception>
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void AppendSmall(this ref ForwardOnlyWriter<char> buffer, string? value)
+ => buffer.AppendSmall(value.AsSpan());
+
+ /// <summary>
/// Formats and appends a value type to the writer with proper endianess
/// </summary>
/// <param name="buffer"></param>
@@ -636,12 +644,20 @@ namespace VNLib.Utils.Extensions
/// <param name="formatProvider"></param>
/// <exception cref="ArgumentOutOfRangeException"></exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static void Append<T>(this ref ForwardOnlyWriter<char> buffer, T value, ReadOnlySpan<char> format = default, IFormatProvider? formatProvider = default) where T : ISpanFormattable
+ public static void Append<T>(
+ this ref ForwardOnlyWriter<char> buffer,
+ T value,
+ ReadOnlySpan<char> format = default,
+ IFormatProvider? formatProvider = default
+ ) where T : ISpanFormattable
{
//Format value and write to buffer
if (!value.TryFormat(buffer.Remaining, out int charsWritten, format, formatProvider))
{
- throw new ArgumentOutOfRangeException(nameof(buffer), "The value could not be formatted and appended to the buffer, because there is not enough available space");
+ throw new ArgumentOutOfRangeException(
+ nameof(buffer),
+ "The value could not be formatted and appended to the buffer, because there is not enough available space"
+ );
}
//Update written posiion
buffer.Advance(charsWritten);
@@ -657,12 +673,20 @@ namespace VNLib.Utils.Extensions
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="ArgumentOutOfRangeException"></exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static void Append<T>(this ref ForwardOnlyMemoryWriter<char> buffer, T value, ReadOnlySpan<char> format = default, IFormatProvider? formatProvider = default) where T : ISpanFormattable
+ public static void Append<T>(
+ this ref ForwardOnlyMemoryWriter<char> buffer,
+ T value,
+ ReadOnlySpan<char> format = default,
+ IFormatProvider? formatProvider = default
+ ) where T : ISpanFormattable
{
//Format value and write to buffer
if (!value.TryFormat(buffer.Remaining.Span, out int charsWritten, format, formatProvider))
{
- throw new ArgumentOutOfRangeException(nameof(buffer), "The value could not be formatted and appended to the buffer, because there is not enough available space");
+ throw new ArgumentOutOfRangeException(
+ nameof(buffer),
+ "The value could not be formatted and appended to the buffer, because there is not enough available space"
+ );
}
//Update written posiion
buffer.Advance(charsWritten);
diff --git a/lib/Utils/src/Extensions/StringExtensions.cs b/lib/Utils/src/Extensions/StringExtensions.cs
index c71d5a0..e9bbfbd 100644
--- a/lib/Utils/src/Extensions/StringExtensions.cs
+++ b/lib/Utils/src/Extensions/StringExtensions.cs
@@ -460,7 +460,7 @@ namespace VNLib.Utils.Extensions
public static int Replace(this Span<char> buffer, ReadOnlySpan<char> search, ReadOnlySpan<char> replace)
{
ForwardOnlyWriter<char> writer = new (buffer);
- writer.Replace(search, replace);
+ Replace(ref writer, search, replace);
return writer.Written;
}
@@ -496,9 +496,9 @@ namespace VNLib.Utils.Extensions
do
{
//Append the data before the search chars
- writer2.Append(buffer[..start]);
+ writer2.Append<char>(buffer[..start]);
//Append the replacment
- writer2.Append(replace);
+ writer2.Append<char>(replace);
//Shift buffer to the end of the
buffer = buffer[(start + searchLen)..];
//search for next index beyond current index
diff --git a/lib/Utils/src/Memory/ForwardOnlyWriter.cs b/lib/Utils/src/Memory/ForwardOnlyWriter.cs
index d3c33a2..55e3b11 100644
--- a/lib/Utils/src/Memory/ForwardOnlyWriter.cs
+++ b/lib/Utils/src/Memory/ForwardOnlyWriter.cs
@@ -23,6 +23,7 @@
*/
using System;
+using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
namespace VNLib.Utils.Memory
@@ -30,12 +31,22 @@ namespace VNLib.Utils.Memory
/// <summary>
/// Provides a stack based buffer writer
/// </summary>
- public ref struct ForwardOnlyWriter<T>
+ /// <remarks>
+ /// Creates a new <see cref="ForwardOnlyWriter{T}"/> assigning the specified buffer
+ /// at the specified offset
+ /// </remarks>
+ /// <param name="buffer">The buffer to write data to</param>
+ /// <param name="offset">The offset to begin the writer at</param>
+ [method: MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public ref struct ForwardOnlyWriter<T>(Span<T> buffer, int offset)
{
+ //Cache reference to the first value
+ private readonly ref T _basePtr = ref MemoryMarshal.GetReference(buffer);
+
/// <summary>
/// The buffer for writing output data to
/// </summary>
- public readonly Span<T> Buffer { get; }
+ public readonly Span<T> Buffer { get; } = buffer[offset..];
/// <summary>
/// The number of characters written to the buffer
@@ -57,43 +68,79 @@ namespace VNLib.Utils.Memory
/// </summary>
/// <param name="buffer">The buffer to write data to</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public ForwardOnlyWriter(Span<T> buffer)
- {
- Buffer = buffer;
- Written = 0;
- }
+ public ForwardOnlyWriter(Span<T> buffer): this(buffer, 0)
+ { }
/// <summary>
- /// Creates a new <see cref="ForwardOnlyWriter{T}"/> assigning the specified buffer
- /// at the specified offset
+ /// Returns a compiled string from the characters written to the buffer
/// </summary>
- /// <param name="buffer">The buffer to write data to</param>
- /// <param name="offset">The offset to begin the writer at</param>
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public ForwardOnlyWriter(Span<T> buffer, int offset)
+ /// <returns>A string of the characters written to the buffer</returns>
+ public readonly override string ToString() => Buffer[..Written].ToString();
+
+ /// <summary>
+ /// Appends a sequence to the buffer
+ /// </summary>
+ /// <param name="data">The data sequence to append to the buffer</param>
+ /// <exception cref="ArgumentOutOfRangeException"></exception>
+ public void Append<TClass>(ReadOnlySpan<T> data) where TClass : class, T
{
- Buffer = buffer[offset..];
- Written = 0;
+ //Make sure the current window is large enough to buffer the new string
+ ArgumentOutOfRangeException.ThrowIfGreaterThan(data.Length, RemainingSize, nameof(Remaining));
+
+ //write data to window
+ data.CopyTo(Remaining);
+
+ //update char position
+ Written += data.Length;
}
/// <summary>
- /// Returns a compiled string from the characters written to the buffer
+ /// Appends a sequence to the buffer of a value type by copying source
+ /// memory to internal buffer memory
/// </summary>
- /// <returns>A string of the characters written to the buffer</returns>
- public readonly override string ToString() => Buffer[..Written].ToString();
+ /// <typeparam name="TStruct"></typeparam>
+ /// <param name="data">The data sequence to append to the buffer</param>
+ /// <exception cref="ArgumentOutOfRangeException"></exception>
+ public void Append<TStruct>(ReadOnlySpan<TStruct> data) where TStruct : struct, T
+ {
+ //Make sure the current window is large enough to buffer the new string
+ ArgumentOutOfRangeException.ThrowIfGreaterThan(data.Length, RemainingSize, nameof(Remaining));
+
+ //write data to window
+ MemoryUtil.Memmove(
+ in MemoryMarshal.GetReference(data),
+ 0,
+ ref Unsafe.As<T, TStruct>(ref _basePtr), //Reinterpret the ref to the local scope type,
+ (nuint)Written,
+ (nuint)data.Length
+ );
+
+ //update char position
+ Written += data.Length;
+ }
/// <summary>
- /// Appends a sequence to the buffer
+ /// Appends a sequence to the buffer of a value type by copying source
+ /// memory to internal buffer memory, when the buffer size is known to be
+ /// smaller than <see cref="ushort.MaxValue"/>.
/// </summary>
- /// <param name="data">The data to append to the buffer</param>
+ /// <typeparam name="TStruct"></typeparam>
+ /// <param name="data">The data sequence to append to the buffer</param>
/// <exception cref="ArgumentOutOfRangeException"></exception>
- public void Append(ReadOnlySpan<T> data)
+ public void AppendSmall<TStruct>(ReadOnlySpan<TStruct> data) where TStruct : struct, T
{
//Make sure the current window is large enough to buffer the new string
ArgumentOutOfRangeException.ThrowIfGreaterThan(data.Length, RemainingSize, nameof(Remaining));
- Span<T> window = Buffer[Written..];
+
//write data to window
- data.CopyTo(window);
+ MemoryUtil.SmallMemmove(
+ in MemoryMarshal.GetReference(data),
+ 0,
+ ref Unsafe.As<T, TStruct>(ref _basePtr), //Reinterpret the ref to the local scope type,
+ (nuint)Written,
+ (ushort)data.Length
+ );
+
//update char position
Written += data.Length;
}
@@ -103,12 +150,21 @@ namespace VNLib.Utils.Memory
/// </summary>
/// <param name="c">The item to append to the buffer</param>
/// <exception cref="ArgumentOutOfRangeException"></exception>
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Append(T c)
{
//Make sure the current window is large enough to buffer the new string
ArgumentOutOfRangeException.ThrowIfZero(RemainingSize);
- //Write data to buffer and increment the buffer position
- Buffer[Written++] = c;
+
+ /*
+ * Calc pointer to last written position.
+ * Written points to the address directly after the last written element
+ */
+
+ ref T offset = ref Unsafe.Add(ref _basePtr, Written);
+ offset = c;
+
+ Written++;
}
/// <summary>
@@ -116,6 +172,7 @@ namespace VNLib.Utils.Memory
/// </summary>
/// <param name="count">The number of elements to advance the writer by</param>
/// <exception cref="ArgumentOutOfRangeException"></exception>
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Advance(int count)
{
ArgumentOutOfRangeException.ThrowIfGreaterThan(count, RemainingSize, nameof(Remaining));
@@ -126,6 +183,7 @@ namespace VNLib.Utils.Memory
/// Resets the writer by setting the <see cref="Written"/>
/// property to 0.
/// </summary>
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Reset() => Written = 0;
}
}
diff --git a/lib/Utils/src/Memory/IUnmangedHeap.cs b/lib/Utils/src/Memory/IUnmangedHeap.cs
index fdc0f9b..e6f82e0 100644
--- a/lib/Utils/src/Memory/IUnmangedHeap.cs
+++ b/lib/Utils/src/Memory/IUnmangedHeap.cs
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2023 Vaughn Nugent
+* Copyright (c) 2024 Vaughn Nugent
*
* Library: VNLib
* Package: VNLib.Utils
@@ -42,7 +42,10 @@ namespace VNLib.Utils.Memory
/// <param name="size">The size (in bytes) of the element</param>
/// <param name="elements">The number of elements to allocate</param>
/// <param name="zero">An optional parameter to zero the block of memory</param>
- /// <returns></returns>
+ /// <returns>A memory address to a valid block on the heap</returns>
+ /// <remarks>
+ /// If the heap is unable to allocate the requested memory, an OutOfMemoryException will be thrown
+ /// </remarks>
/// <exception cref="OutOfMemoryException"></exception>
IntPtr Alloc(nuint elements, nuint size, bool zero);
diff --git a/lib/Utils/src/Memory/MemoryUtil.CopyUtilCore.cs b/lib/Utils/src/Memory/MemoryUtil.CopyUtilCore.cs
index f196597..9decef7 100644
--- a/lib/Utils/src/Memory/MemoryUtil.CopyUtilCore.cs
+++ b/lib/Utils/src/Memory/MemoryUtil.CopyUtilCore.cs
@@ -126,7 +126,7 @@ namespace VNLib.Utils.Memory
Debug.Assert(!Unsafe.IsNullRef(in srcByte), "Null source reference passed to MemmoveByRef");
Debug.Assert(!Unsafe.IsNullRef(in dstByte), "Null destination reference passed to MemmoveByRef");
- //Check for 64bit copy
+ //Check for 64bit copy (should get optimized away when sizeof(nuint == uint) aka 32bit platforms)
if(byteCount > uint.MaxValue)
{
//We need a 64bit copy strategy
@@ -135,7 +135,6 @@ namespace VNLib.Utils.Memory
//Must be supported
if(_avxCopy.Features != CopyFeatures.NotSupported)
{
- //Copy
_avxCopy.Memmove(in srcByte, ref dstByte, byteCount);
return;
}
@@ -144,7 +143,6 @@ namespace VNLib.Utils.Memory
//try reflected memove incase it supports 64bit blocks
if(_reflectedMemmove.Features != CopyFeatures.NotSupported)
{
- //Copy
_reflectedMemmove.Memmove(in srcByte, ref dstByte, byteCount);
return;
}
@@ -223,6 +221,7 @@ namespace VNLib.Utils.Memory
public CopyFeatures Features => CopyFeatures.None;
///<inheritdoc/>
+ [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
public void Memmove(ref readonly byte src, ref byte dst, nuint byteCount)
{
Debug.Assert(byteCount < uint.MaxValue, "Byte count must be less than uint.MaxValue and flags assumed 64bit blocks were supported");
diff --git a/lib/Utils/src/Memory/NativeHeap.cs b/lib/Utils/src/Memory/NativeHeap.cs
index 6381dd9..fb9612c 100644
--- a/lib/Utils/src/Memory/NativeHeap.cs
+++ b/lib/Utils/src/Memory/NativeHeap.cs
@@ -106,7 +106,7 @@ namespace VNLib.Utils.Memory
private HeapMethods MethodTable;
- private unsafe NativeHeap(UnmanagedHeapDescriptor* flags, HeapMethods methodTable) :base(flags->CreationFlags, true)
+ private unsafe NativeHeap(UnmanagedHeapDescriptor* flags, HeapMethods methodTable) : base(flags->CreationFlags, true)
{
//Store heap pointer
SetHandle(flags->HeapPointer);
@@ -164,7 +164,7 @@ namespace VNLib.Utils.Memory
delegate ERRNO DestroyHeapDelegate(IntPtr heap);
[StructLayout(LayoutKind.Sequential)]
- record struct UnmanagedHeapDescriptor
+ struct UnmanagedHeapDescriptor
{
public IntPtr HeapPointer;
diff --git a/lib/Utils/src/Memory/UnmanagedHeapBase.cs b/lib/Utils/src/Memory/UnmanagedHeapBase.cs
index 599d8d9..7f42761 100644
--- a/lib/Utils/src/Memory/UnmanagedHeapBase.cs
+++ b/lib/Utils/src/Memory/UnmanagedHeapBase.cs
@@ -67,7 +67,7 @@ namespace VNLib.Utils.Memory
DangerousAddRef(ref handleCountIncremented);
//Failed to increment ref count, class has been disposed
- ObjectDisposedException.ThrowIf(handleCountIncremented == false, "The handle has been released");
+ ObjectDisposedException.ThrowIf(handleCountIncremented == false, this);
try
{
diff --git a/lib/Utils/src/VNLib.Utils.csproj b/lib/Utils/src/VNLib.Utils.csproj
index 7941a7b..83d245c 100644
--- a/lib/Utils/src/VNLib.Utils.csproj
+++ b/lib/Utils/src/VNLib.Utils.csproj
@@ -2,16 +2,19 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
+ <Nullable>enable</Nullable>
<RootNamespace>VNLib.Utils</RootNamespace>
<AssemblyName>VNLib.Utils</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <Nullable>enable</Nullable>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
- <AnalysisLevel>latest-all</AnalysisLevel>
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
</PropertyGroup>
<PropertyGroup>
+ <AnalysisLevel Condition="'$(BuildingInsideVisualStudio)' == true">latest-all</AnalysisLevel>
+ </PropertyGroup>
+
+ <PropertyGroup>
<PackageId>VNLib.Utils</PackageId>
<Authors>Vaughn Nugent</Authors>
<Company>Vaughn Nugent</Company>