From 86c0532edc0042b26dda5f1ca41abdf80db46414 Mon Sep 17 00:00:00 2001 From: vnugent Date: Sat, 6 Jan 2024 13:09:21 -0500 Subject: initial migration to .net 8.0 --- README.md | 2 ++ .../src/VNLib.Hashing.Portable.csproj | 4 ++-- .../tests/VNLib.Hashing.PortableTests.csproj | 2 +- .../VNLib.Net.Compression.csproj | 10 +++------- .../VNLib.Net.CompressionTests.csproj | 2 +- lib/Net.Http/src/VNLib.Net.Http.csproj | 4 ++-- .../src/Exceptions/FBMException.cs | 8 ++------ .../src/Exceptions/InvalidResponseException.cs | 8 ++------ .../src/VNLib.Net.Messaging.FBM.csproj | 4 ++-- .../src/VNLib.Net.Rest.Client.csproj | 4 ++-- .../src/VNLib.Net.Transport.SimpleTCP.csproj | 4 ++-- .../VNLib.Plugins.Essentials.ServiceStack.csproj | 4 ++-- .../src/Sessions/SessionException.cs | 7 ++----- .../src/Users/UserCreationFailedException.cs | 5 +---- .../src/Users/UserExistsException.cs | 8 ++------ .../src/VNLib.Plugins.Essentials.csproj | 4 ++-- .../src/VNLib.Plugins.PluginBase.csproj | 4 ++-- lib/Plugins.Runtime/src/LoaderExtensions.cs | 5 ++--- lib/Plugins.Runtime/src/PluginUnloadExcpetion.cs | 7 ++----- .../src/VNLib.Plugins.Runtime.csproj | 4 ++-- lib/Plugins/src/VNLib.Plugins.csproj | 4 ++-- lib/Utils/README.md | 2 +- lib/Utils/src/ERRNO.cs | 10 ++-------- lib/Utils/src/Extensions/StringExtensions.cs | 22 +++++++++++++--------- lib/Utils/src/Memory/MemoryUtil.cs | 12 ++++++------ .../src/Resources/ResourceDeleteFailedException.cs | 5 ++--- .../src/Resources/ResourceUpdateFailedException.cs | 6 ++---- lib/Utils/src/VNLib.Utils.csproj | 6 +++--- lib/Utils/tests/VNLib.UtilsTests.csproj | 2 +- 29 files changed, 70 insertions(+), 99 deletions(-) diff --git a/README.md b/README.md index abf5a13..e2cb063 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ Again, go to my website below, my email address is available, go ahead and send ### .NET Version Notice I prefer sticking with lts .NET versions and 8 just released, so I will likely be upgrading once its "stable" and I have the time to port and test everything. Core libraries will be first then downstream packages. +**Update** Upgrades to .NET 8 have started and breaking changes/obsolete apis have been addressed. Futher updates and improvements will be made to make use of new features and apis. + ## Index/NameSpaces **VNLib.** - [Utils](lib/Utils/#) - A mutli-use library focused on reducing complexity for working with native resources, memory, asynchronous patterns and data-structures, object/resource pooling, critical resource handling, and common logging abstractions. diff --git a/lib/Hashing.Portable/src/VNLib.Hashing.Portable.csproj b/lib/Hashing.Portable/src/VNLib.Hashing.Portable.csproj index 8caae03..7e31e0c 100644 --- a/lib/Hashing.Portable/src/VNLib.Hashing.Portable.csproj +++ b/lib/Hashing.Portable/src/VNLib.Hashing.Portable.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 VNLib.Hashing.Portable VNLib.Hashing True @@ -17,7 +17,7 @@ Provides managed and random cryptocraphic hashing helper classes, including complete Argon2 password hashing. Vaughn Nugent Vaughn Nugent - Copyright © 2023 Vaughn Nugent + Copyright © 2024 Vaughn Nugent https://www.vaughnnugent.com/resources/software/modules/VNLib.Core https://github.com/VnUgE/VNLib.Core/tree/main/lib/Hashing.Portable README.md diff --git a/lib/Hashing.Portable/tests/VNLib.Hashing.PortableTests.csproj b/lib/Hashing.Portable/tests/VNLib.Hashing.PortableTests.csproj index 45a5589..e68b1a2 100644 --- a/lib/Hashing.Portable/tests/VNLib.Hashing.PortableTests.csproj +++ b/lib/Hashing.Portable/tests/VNLib.Hashing.PortableTests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable diff --git a/lib/Net.Compression/VNLib.Net.Compression/VNLib.Net.Compression.csproj b/lib/Net.Compression/VNLib.Net.Compression/VNLib.Net.Compression.csproj index c6a05cd..36082f1 100644 --- a/lib/Net.Compression/VNLib.Net.Compression/VNLib.Net.Compression.csproj +++ b/lib/Net.Compression/VNLib.Net.Compression/VNLib.Net.Compression.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 VNLib.Net.Compression VNLib.Net.Compression true @@ -22,12 +22,8 @@ Vaughn Nugent Vaughn Nugent VNLib Native Http Compression Provider - Copyright © 2023 Vaughn Nugent - - .NET/6.0 dynamically loadable managed wrapper library for loading vnlib_compress native library. It provides - an implementation of the IHttpCompressorManager interface for use with the VNLib.Net.Http library and servers - wishing to support dynamic response compression. - + Copyright © 2024 Vaughn Nugent + .NET/8.0 dynamically loadable managed wrapper library for loading vnlib_compress native library. It provides an implementation of the IHttpCompressorManager interface for use with the VNLib.Net.Http library and servers wishing to support dynamic response compression. https://www.vaughnnugent.com/resources/software/modules/VNLib.Core https://github.com/VnUgE/VNLib.Core/tree/main/lib/Net.Compression diff --git a/lib/Net.Compression/VNLib.Net.CompressionTests/VNLib.Net.CompressionTests.csproj b/lib/Net.Compression/VNLib.Net.CompressionTests/VNLib.Net.CompressionTests.csproj index 53a6155..97549db 100644 --- a/lib/Net.Compression/VNLib.Net.CompressionTests/VNLib.Net.CompressionTests.csproj +++ b/lib/Net.Compression/VNLib.Net.CompressionTests/VNLib.Net.CompressionTests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable false true diff --git a/lib/Net.Http/src/VNLib.Net.Http.csproj b/lib/Net.Http/src/VNLib.Net.Http.csproj index ea0bdb7..43224fe 100644 --- a/lib/Net.Http/src/VNLib.Net.Http.csproj +++ b/lib/Net.Http/src/VNLib.Net.Http.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 VNLib.Net.Http VNLib.Net.Http en-US @@ -17,7 +17,7 @@ Vaughn Nugent VNLib HTTP Library Provides a high performance HTTP 0.9-1.1 application processing layer for handling transport *agnostic connections and asynchronous event support for applications serving HTTP requests such as web content. This library has a large focus on low/no GC allocations using unmanaged memory support provided by the VNLib.Utils library. No external dependencies outside of the VNLib ecosystem are required. The VNLib.Plugins and VNLib.Plugins.Essentials libraries are highly recommended for serving web content. - Copyright © 2023 Vaughn Nugent + Copyright © 2024 Vaughn Nugent https://www.vaughnnugent.com/resources/software/modules/VNLib.Core https://github.com/VnUgE/VNLib.Core/tree/main/lib/Net.Http readme.md diff --git a/lib/Net.Messaging.FBM/src/Exceptions/FBMException.cs b/lib/Net.Messaging.FBM/src/Exceptions/FBMException.cs index 1d5c7db..1a047a9 100644 --- a/lib/Net.Messaging.FBM/src/Exceptions/FBMException.cs +++ b/lib/Net.Messaging.FBM/src/Exceptions/FBMException.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2022 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Net.Messaging.FBM @@ -23,7 +23,7 @@ */ using System; -using System.Runtime.Serialization; + namespace VNLib.Net.Messaging.FBM { @@ -44,9 +44,5 @@ namespace VNLib.Net.Messaging.FBM public FBMException(string message, Exception innerException) : base(message, innerException) { } - /// - protected FBMException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } } } diff --git a/lib/Net.Messaging.FBM/src/Exceptions/InvalidResponseException.cs b/lib/Net.Messaging.FBM/src/Exceptions/InvalidResponseException.cs index 3f0b970..3fb61fa 100644 --- a/lib/Net.Messaging.FBM/src/Exceptions/InvalidResponseException.cs +++ b/lib/Net.Messaging.FBM/src/Exceptions/InvalidResponseException.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2022 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Net.Messaging.FBM @@ -23,7 +23,7 @@ */ using System; -using System.Runtime.Serialization; + namespace VNLib.Net.Messaging.FBM { @@ -44,9 +44,5 @@ namespace VNLib.Net.Messaging.FBM public InvalidResponseException(string message, Exception innerException) : base(message, innerException) { } - /// - protected InvalidResponseException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } } } diff --git a/lib/Net.Messaging.FBM/src/VNLib.Net.Messaging.FBM.csproj b/lib/Net.Messaging.FBM/src/VNLib.Net.Messaging.FBM.csproj index 70a640d..667dfed 100644 --- a/lib/Net.Messaging.FBM/src/VNLib.Net.Messaging.FBM.csproj +++ b/lib/Net.Messaging.FBM/src/VNLib.Net.Messaging.FBM.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 VNLib.Net.Messaging.FBM VNLib.Net.Messaging.FBM enable @@ -15,7 +15,7 @@ Vaughn Nugent Vaughn Nugent Fixed Buffer Messaging protocol class library. Implements a high-performance asynchronous request/response messaging architecture build on top of HTTP websockets. Provides client and server data structures. - Copyright © 2023 Vaughn Nugent + Copyright © 2024 Vaughn Nugent https://www.vaughnnugent.com/resources/software/modules/VNLib.Core https://github.com/VnUgE/VNLib.Core/tree/main/lib/Net.Messaging.FBM README.md diff --git a/lib/Net.Rest.Client/src/VNLib.Net.Rest.Client.csproj b/lib/Net.Rest.Client/src/VNLib.Net.Rest.Client.csproj index d5ee1cf..c431fdd 100644 --- a/lib/Net.Rest.Client/src/VNLib.Net.Rest.Client.csproj +++ b/lib/Net.Rest.Client/src/VNLib.Net.Rest.Client.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable VNLib.Net.Rest.Client VNLib.Net.Rest.Client @@ -14,7 +14,7 @@ VNLib.Net.Rest.Client Vaughn Nugent Vaughn Nugent - Copyright © 2023 Vaughn Nugent + Copyright © 2024 Vaughn Nugent Provides a RestClient connection pool using the Utils.ObjectRental framework for reusing RestClients with a common configuration to execute RestRequests against. This library also implements an OAuth2 authenticator for the RestSharp IAuthenticator using the client credentials method. https://www.vaughnnugent.com/resources/software/modules/VNLib.Core https://github.com/VnUgE/VNLib.Core/tree/main/lib/Net.Rest.Client diff --git a/lib/Net.Transport.SimpleTCP/src/VNLib.Net.Transport.SimpleTCP.csproj b/lib/Net.Transport.SimpleTCP/src/VNLib.Net.Transport.SimpleTCP.csproj index ac3e0a1..e8c28f1 100644 --- a/lib/Net.Transport.SimpleTCP/src/VNLib.Net.Transport.SimpleTCP.csproj +++ b/lib/Net.Transport.SimpleTCP/src/VNLib.Net.Transport.SimpleTCP.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 VNLib.Net.Transport VNLib.Net.Transport.SimpleTCP enable @@ -18,7 +18,7 @@ Provides a library for single process asynchronous, event driven, TCP socket listening and supporting structures to implement simple high performance TCP servers with or without TLS security. Vaughn Nugent Vaughn Nugent - Copyright © 2023 Vaughn Nugent + Copyright © 2024 Vaughn Nugent https://www.vaughnnugent.com/resources/software/modules/VNLib.Core https://github.com/VnUgE/VNLib.Core/tree/main/lib/Net.Transport.SimpleTCP diff --git a/lib/Plugins.Essentials.ServiceStack/src/VNLib.Plugins.Essentials.ServiceStack.csproj b/lib/Plugins.Essentials.ServiceStack/src/VNLib.Plugins.Essentials.ServiceStack.csproj index 8fd7e77..792b168 100644 --- a/lib/Plugins.Essentials.ServiceStack/src/VNLib.Plugins.Essentials.ServiceStack.csproj +++ b/lib/Plugins.Essentials.ServiceStack/src/VNLib.Plugins.Essentials.ServiceStack.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 VNLib.Plugins.Essentials.ServiceStack VNLib.Plugins.Essentials.ServiceStack enable @@ -15,7 +15,7 @@ Vaughn Nugent Vaughn Nugent VNLib.Plugins.Essentials.ServiceStack - Copyright © 2023 Vaughn Nugent + Copyright © 2024 Vaughn Nugent Provides data structures for building a dynamic HTTP servicing stack with runtime plugin loading, dynamic endpoint routing, middleware* configuration, and multi-server managment. diff --git a/lib/Plugins.Essentials/src/Sessions/SessionException.cs b/lib/Plugins.Essentials/src/Sessions/SessionException.cs index 554c55f..384c97a 100644 --- a/lib/Plugins.Essentials/src/Sessions/SessionException.cs +++ b/lib/Plugins.Essentials/src/Sessions/SessionException.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2022 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Plugins.Essentials @@ -23,7 +23,7 @@ */ using System; -using System.Runtime.Serialization; + namespace VNLib.Plugins.Essentials.Sessions { @@ -41,8 +41,5 @@ namespace VNLib.Plugins.Essentials.Sessions /// public SessionException(string message, Exception innerException) : base(message, innerException) {} - /// - protected SessionException(SerializationInfo info, StreamingContext context) : base(info, context) - {} } } diff --git a/lib/Plugins.Essentials/src/Users/UserCreationFailedException.cs b/lib/Plugins.Essentials/src/Users/UserCreationFailedException.cs index 0c901f2..1469624 100644 --- a/lib/Plugins.Essentials/src/Users/UserCreationFailedException.cs +++ b/lib/Plugins.Essentials/src/Users/UserCreationFailedException.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2023 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Plugins.Essentials @@ -23,7 +23,6 @@ */ using System; -using System.Runtime.Serialization; using VNLib.Utils.Resources; @@ -40,7 +39,5 @@ namespace VNLib.Plugins.Essentials.Users {} public UserCreationFailedException(string message, Exception innerException) : base(message, innerException) {} - protected UserCreationFailedException(SerializationInfo info, StreamingContext context) : base(info, context) - {} } } \ No newline at end of file diff --git a/lib/Plugins.Essentials/src/Users/UserExistsException.cs b/lib/Plugins.Essentials/src/Users/UserExistsException.cs index e9b9586..3322c30 100644 --- a/lib/Plugins.Essentials/src/Users/UserExistsException.cs +++ b/lib/Plugins.Essentials/src/Users/UserExistsException.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2023 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Plugins.Essentials @@ -23,7 +23,7 @@ */ using System; -using System.Runtime.Serialization; + namespace VNLib.Plugins.Essentials.Users { @@ -44,9 +44,5 @@ namespace VNLib.Plugins.Essentials.Users /// public UserExistsException(string message, Exception innerException) : base(message, innerException) { } - - /// - protected UserExistsException(SerializationInfo info, StreamingContext context) : base(info, context) - { } } } \ No newline at end of file diff --git a/lib/Plugins.Essentials/src/VNLib.Plugins.Essentials.csproj b/lib/Plugins.Essentials/src/VNLib.Plugins.Essentials.csproj index 65fff58..9b8abb7 100644 --- a/lib/Plugins.Essentials/src/VNLib.Plugins.Essentials.csproj +++ b/lib/Plugins.Essentials/src/VNLib.Plugins.Essentials.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 VNLib.Plugins.Essentials VNLib.Plugins.Essentials latest-all @@ -16,7 +16,7 @@ Vaughn NUgent VNLib.Plugins.Essentials VNLib Essentials Plugin Library - Copyright © 2023 Vaughn Nugent + Copyright © 2024 Vaughn Nugent Provides essential web, sessions, users abstractions for building extensable web applications with satefull sessions, user based intraction with login and account security extensions. VNLib, Plugins, VNLib.Plugins.Essentials, Essentials, Essential Plugins, HTTP Essentials, OAuth2 https://www.vaughnnugent.com/resources/software/modules/VNLib.Core diff --git a/lib/Plugins.PluginBase/src/VNLib.Plugins.PluginBase.csproj b/lib/Plugins.PluginBase/src/VNLib.Plugins.PluginBase.csproj index c7a8414..2b8eccd 100644 --- a/lib/Plugins.PluginBase/src/VNLib.Plugins.PluginBase.csproj +++ b/lib/Plugins.PluginBase/src/VNLib.Plugins.PluginBase.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 VNLib.Plugins VNLib.Plugins.PluginBase latest-all @@ -13,7 +13,7 @@ Vaughn Nugent Vaughn Nugent VNLib.Plugins.PluginBase - Copyright © 2023 Vaughn Nugent + Copyright © 2024 Vaughn Nugent A base class for VNLib.Plugins that provides all supported loading functionalities, with built-in logging, loading, task-managment and endpoint routing. https://www.vaughnnugent.com/resources/software/modules/VNLib.Core https://github.com/VnUgE/VNLib.Core/tree/main/lib/Plugins.PluginBase diff --git a/lib/Plugins.Runtime/src/LoaderExtensions.cs b/lib/Plugins.Runtime/src/LoaderExtensions.cs index b892213..e88ccb3 100644 --- a/lib/Plugins.Runtime/src/LoaderExtensions.cs +++ b/lib/Plugins.Runtime/src/LoaderExtensions.cs @@ -56,7 +56,6 @@ namespace VNLib.Plugins.Runtime private sealed class TypedRegistration : IPluginEventListener where T: class { private readonly ITypedPluginConsumer _consumerEvents; - private readonly object? _userState; private T? _service; private readonly Type _type; @@ -77,7 +76,7 @@ namespace VNLib.Plugins.Runtime .First(); //Call load with the exported type - _consumerEvents.OnLoad(service, _userState); + _consumerEvents.OnLoad(service, state); //Store for unload _service = service; @@ -86,7 +85,7 @@ namespace VNLib.Plugins.Runtime public void OnPluginUnloaded(PluginController controller, object? state) { //Unload - _consumerEvents.OnUnload(_service!, _userState); + _consumerEvents.OnUnload(_service!, state); _service = null; } } diff --git a/lib/Plugins.Runtime/src/PluginUnloadExcpetion.cs b/lib/Plugins.Runtime/src/PluginUnloadExcpetion.cs index c961b4e..b1a3819 100644 --- a/lib/Plugins.Runtime/src/PluginUnloadExcpetion.cs +++ b/lib/Plugins.Runtime/src/PluginUnloadExcpetion.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2023 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Plugins.Runtime @@ -23,7 +23,7 @@ */ using System; -using System.Runtime.Serialization; + namespace VNLib.Plugins.Runtime { @@ -42,8 +42,5 @@ namespace VNLib.Plugins.Runtime public PluginUnloadException(string message, Exception innerException) : base(message, innerException) { } - - protected PluginUnloadException(SerializationInfo info, StreamingContext context) : base(info, context) - { } } } diff --git a/lib/Plugins.Runtime/src/VNLib.Plugins.Runtime.csproj b/lib/Plugins.Runtime/src/VNLib.Plugins.Runtime.csproj index c3e58f3..30f2106 100644 --- a/lib/Plugins.Runtime/src/VNLib.Plugins.Runtime.csproj +++ b/lib/Plugins.Runtime/src/VNLib.Plugins.Runtime.csproj @@ -2,7 +2,7 @@ enable - net6.0 + net8.0 VNLib.Plugins.Runtime VNLib.Plugins.Runtime latest-all @@ -14,7 +14,7 @@ Vaughn Nugent Vaughn Nugent VNLib.Plugins.Runtime - Copyright © 2023 Vaughn Nugent + Copyright © 2024 Vaughn Nugent A runtime plugin loader for .NET. Allows runtime loading and tracking of .NET assemblies that export the VNLib.Plugin.IPlugin interface. https://www.vaughnnugent.com/resources/software/modules/VNLib.Core https://github.com/VnUgE/VNLib.Core/tree/main/lib/Plugins.Runtime diff --git a/lib/Plugins/src/VNLib.Plugins.csproj b/lib/Plugins/src/VNLib.Plugins.csproj index 05f57d3..21fb203 100644 --- a/lib/Plugins/src/VNLib.Plugins.csproj +++ b/lib/Plugins/src/VNLib.Plugins.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 VNLib.Plugins VNLib.Plugins enable @@ -14,7 +14,7 @@ Vaughn Nugent Vaughn Nugent VNLib.Plugins - Copyright © 2023 Vaughn Nugent + Copyright © 2024 Vaughn Nugent Plugins, VNLIb, VNLib Plugins, Plugin Base VNLib Plugins Interface Assembly Provides a standard interface for building dynamically loadable plugins and asynchronus web endpoint processing, compatible with the VNLib.Plugins.Runtime loader library. diff --git a/lib/Utils/README.md b/lib/Utils/README.md index f5b1244..341b1d4 100644 --- a/lib/Utils/README.md +++ b/lib/Utils/README.md @@ -1,6 +1,6 @@ # VNLib.Utils -A .NET 6 /C# library for common .NET operation and memory optimizations. +A .NET 8 /C# library for common .NET operation and memory optimizations. ### Builds & Feeds Builds contain the individual components listed below packaged per-project, available for download on my website. Build packages will be tgz archives (except for nuget packages). You can obtain debug and release builds, along with per-project source code. diff --git a/lib/Utils/src/ERRNO.cs b/lib/Utils/src/ERRNO.cs index 3bc1296..2a59ba6 100644 --- a/lib/Utils/src/ERRNO.cs +++ b/lib/Utils/src/ERRNO.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2023 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Utils @@ -85,13 +85,7 @@ namespace VNLib.Utils /// C style boolean conversion. false if 0, true otherwise /// /// - public static implicit operator bool(ERRNO errorVal) => errorVal != 0; - - /// - /// Creates a new from the value if the stored (nint) error code - /// - /// The contating the pointer value - public static implicit operator IntPtr(ERRNO errno) => new(errno.ErrorCode); + public static implicit operator bool(ERRNO errorVal) => errorVal != 0; /// /// Creates a new nint from the value if the stored error code diff --git a/lib/Utils/src/Extensions/StringExtensions.cs b/lib/Utils/src/Extensions/StringExtensions.cs index 42b7b32..7ffaaa2 100644 --- a/lib/Utils/src/Extensions/StringExtensions.cs +++ b/lib/Utils/src/Extensions/StringExtensions.cs @@ -475,10 +475,10 @@ namespace VNLib.Utils.Extensions { Span buffer = writer.AsSpan(); - //If the search and replacment parameters are the same length + //If the search and replacement parameters are the same length if (search.Length == replace.Length) { - buffer.ReplaceInPlace(search, replace); + ReplaceInPlace(buffer, search, replace); return; } @@ -490,24 +490,28 @@ namespace VNLib.Utils.Extensions return; } - //Replacment might be empty - writer.Reset(); + //Init new writer over the buffer + ForwardOnlyWriter writer2 = new(buffer); do { - //Append the data before the split character - writer.Append(buffer[..start]); + //Append the data before the search chars + writer2.Append(buffer[..start]); //Append the replacment - writer.Append(replace); + writer2.Append(replace); //Shift buffer to the end of the buffer = buffer[(start + searchLen)..]; - //search for next index + //search for next index beyond current index start = buffer.IndexOf(search); } while (start > -1); //Write remaining data - writer.Append(replace); + writer2.Append(replace); + + //Reset writer1 and advance it to the end of writer2 + writer.Reset(); + writer.Advance(writer2.Written); } /// diff --git a/lib/Utils/src/Memory/MemoryUtil.cs b/lib/Utils/src/Memory/MemoryUtil.cs index 02d2f0e..1e0d11a 100644 --- a/lib/Utils/src/Memory/MemoryUtil.cs +++ b/lib/Utils/src/Memory/MemoryUtil.cs @@ -280,12 +280,12 @@ namespace VNLib.Utils.Memory { Debug.Assert(Unsafe.IsNullRef(ref src) == false, "Null reference passed to ZeroByRef"); - //Convert to bytes - uint byteSize = ByteCount(elements); - ref byte byteRef = ref Unsafe.As(ref src); - - //Call init block - Unsafe.InitBlock(ref byteRef, 0, byteSize); + //Call init block on bytes + Unsafe.InitBlock( + ref Refs.AsByte(ref src, 0), + 0, + ByteCount(elements) + ); } /* diff --git a/lib/Utils/src/Resources/ResourceDeleteFailedException.cs b/lib/Utils/src/Resources/ResourceDeleteFailedException.cs index 8e796b5..499442c 100644 --- a/lib/Utils/src/Resources/ResourceDeleteFailedException.cs +++ b/lib/Utils/src/Resources/ResourceDeleteFailedException.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2022 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Utils @@ -23,7 +23,7 @@ */ using System; -using System.Runtime.Serialization; + namespace VNLib.Utils.Resources { @@ -35,6 +35,5 @@ namespace VNLib.Utils.Resources public ResourceDeleteFailedException() { } public ResourceDeleteFailedException(string message) : base(message) { } public ResourceDeleteFailedException(string message, Exception innerException) : base(message, innerException) { } - protected ResourceDeleteFailedException(SerializationInfo info, StreamingContext context) : base(info, context) { } } } \ No newline at end of file diff --git a/lib/Utils/src/Resources/ResourceUpdateFailedException.cs b/lib/Utils/src/Resources/ResourceUpdateFailedException.cs index b4b2b3a..447dc2e 100644 --- a/lib/Utils/src/Resources/ResourceUpdateFailedException.cs +++ b/lib/Utils/src/Resources/ResourceUpdateFailedException.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2022 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Utils @@ -23,7 +23,6 @@ */ using System; -using System.Runtime.Serialization; namespace VNLib.Utils.Resources { @@ -35,6 +34,5 @@ namespace VNLib.Utils.Resources public ResourceUpdateFailedException() { } public ResourceUpdateFailedException(string message) : base(message) { } public ResourceUpdateFailedException(string message, Exception innerException) : base(message, innerException) { } - protected ResourceUpdateFailedException(SerializationInfo info, StreamingContext context) : base(info, context) { } } -} \ No newline at end of file +} diff --git a/lib/Utils/src/VNLib.Utils.csproj b/lib/Utils/src/VNLib.Utils.csproj index d121183..54199e0 100644 --- a/lib/Utils/src/VNLib.Utils.csproj +++ b/lib/Utils/src/VNLib.Utils.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 VNLib.Utils VNLib.Utils true @@ -16,8 +16,8 @@ Vaughn Nugent Vaughn Nugent VNLib Utilities Library - Copyright © 2023 Vaughn Nugent - .NET/6.0 Utilities library for high-performance common operations. Utilities and abstractions for building and diagnosing native memory implementations. Dyanmic native library loading, IO, extensions, data encoding, resource access, and asynchronous cooperation primitives. + Copyright © 2024 Vaughn Nugent + .NET/8.0 Utilities library for high-performance common operations. Utilities and abstractions for building and diagnosing native memory implementations. Dyanmic native library loading, IO, extensions, data encoding, resource access, and asynchronous cooperation primitives. https://www.vaughnnugent.com/resources/software/modules/VNLib.Core https://github.com/VnUgE/VNLib.Core/tree/main/lib/Utils README.md diff --git a/lib/Utils/tests/VNLib.UtilsTests.csproj b/lib/Utils/tests/VNLib.UtilsTests.csproj index f8cb807..6a8a065 100644 --- a/lib/Utils/tests/VNLib.UtilsTests.csproj +++ b/lib/Utils/tests/VNLib.UtilsTests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable false true -- cgit