From bdee3105e869a3b01aea6edc9da3d4154de5ea50 Mon Sep 17 00:00:00 2001 From: David Shnayder Date: Sun, 21 Dec 2025 13:41:47 +0200 Subject: [PATCH 1/2] Address warnings --- src/ArrowDbCore/ArrowDb.cs | 4 ++-- src/ArrowDbCore/ArrowDbCore.csproj | 6 +++++- src/ArrowDbCore/ArrowDbTransactionScope.cs | 2 ++ src/ArrowDbCore/ChangeEventArgs.cs | 2 +- src/ArrowDbCore/Serializers/BaseFileSerializer.cs | 14 ++++++++++++-- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/ArrowDbCore/ArrowDb.cs b/src/ArrowDbCore/ArrowDb.cs index 5fef6f8..0d87f78 100644 --- a/src/ArrowDbCore/ArrowDb.cs +++ b/src/ArrowDbCore/ArrowDb.cs @@ -63,12 +63,12 @@ private void OnChangeInternal(ArrowDbChangeEventArgs args) { /// /// Thread-safe transaction depth tracker /// - internal long TransactionDepth = 0; + internal long TransactionDepth; /// /// A state epoch used to detect concurrent operations in hot write paths. /// - internal long StateEpoch = 0; + internal long StateEpoch; /// /// Private Ctor diff --git a/src/ArrowDbCore/ArrowDbCore.csproj b/src/ArrowDbCore/ArrowDbCore.csproj index 0cd47c4..ad63200 100644 --- a/src/ArrowDbCore/ArrowDbCore.csproj +++ b/src/ArrowDbCore/ArrowDbCore.csproj @@ -16,6 +16,10 @@ true + + $(NoWarn);CA1001 + + David Shnayder David Shnayder @@ -59,4 +63,4 @@ - \ No newline at end of file + diff --git a/src/ArrowDbCore/ArrowDbTransactionScope.cs b/src/ArrowDbCore/ArrowDbTransactionScope.cs index 17465f6..7bf6e4c 100644 --- a/src/ArrowDbCore/ArrowDbTransactionScope.cs +++ b/src/ArrowDbCore/ArrowDbTransactionScope.cs @@ -34,7 +34,9 @@ public async ValueTask DisposeAsync() { /// Disposes the scope and calls in a blocking operation /// public void Dispose() { +#pragma warning disable CA2012 var task = DisposeAsync(); +#pragma warning restore CA2012 if (task.IsCompleted) { return; } diff --git a/src/ArrowDbCore/ChangeEventArgs.cs b/src/ArrowDbCore/ChangeEventArgs.cs index f61456c..a0a577f 100644 --- a/src/ArrowDbCore/ChangeEventArgs.cs +++ b/src/ArrowDbCore/ChangeEventArgs.cs @@ -20,7 +20,7 @@ public sealed class ArrowDbChangeEventArgs : EventArgs { /// /// The type of change that occurred /// - public readonly ArrowDbChangeType ChangeType; + public ArrowDbChangeType ChangeType { get; init; } private ArrowDbChangeEventArgs(ArrowDbChangeType changeType) { ChangeType = changeType; diff --git a/src/ArrowDbCore/Serializers/BaseFileSerializer.cs b/src/ArrowDbCore/Serializers/BaseFileSerializer.cs index 798eba5..dd03266 100644 --- a/src/ArrowDbCore/Serializers/BaseFileSerializer.cs +++ b/src/ArrowDbCore/Serializers/BaseFileSerializer.cs @@ -5,10 +5,11 @@ namespace ArrowDbCore.Serializers; /// /// Provides a base implementation for file-based serializers that ensures atomic and multi-process safe writes. /// -public abstract class BaseFileSerializer : IDbSerializer { +public abstract class BaseFileSerializer : IDbSerializer, IDisposable { private readonly string _dbFilePath; private readonly string _tempFilePath; private readonly Mutex _mutex; + private bool _disposed; /// /// Initializes a new instance of the class. @@ -25,7 +26,7 @@ protected BaseFileSerializer(string path) { /// Finalizer to ensure the system-wide mutex is released when the serializer is garbage collected. /// ~BaseFileSerializer() { - _mutex.Dispose(); + Dispose(); } /// @@ -71,4 +72,13 @@ public ValueTask SerializeAsync(ConcurrentDictionary data) { /// The stream to read the data from. /// The deserialized dictionary. protected abstract ValueTask> DeserializeData(Stream stream); + + /// + public void Dispose() { + if (_disposed) return; + + _mutex.Dispose(); + _disposed = true; + GC.SuppressFinalize(this); + } } \ No newline at end of file From 2f3c2b1fd92ce36428346b1d0fc7dc994b04e7fc Mon Sep 17 00:00:00 2001 From: David Shnayder Date: Sun, 21 Dec 2025 13:43:02 +0200 Subject: [PATCH 2/2] Fix typos --- README.md | 2 +- src/ArrowDbCore/Readme.Nuget.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4dc230a..871936e 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ ArrowDb is a fast, lightweight, and type-safe key-value database designed for .N * Super-Lightweight (dll size is ~19KB - approximately 9X smaller than [UltraLiteDb](https://github.com/rejemy/UltraLiteDB)) * Ultra-Fast (1,000,000 random operations / ~98ms on M2 MacBook Pro) -* Minimal-Allocation (constant ~520 bytes for serialization any db size) +* Minimal-Allocation (constant ~520 bytes for serialization of any db size) * Thread-Safe and Concurrent * ACID compliant on transaction level * Type-Safe (no reflection - compile-time enforced via source-generated `JsonSerializerContext`) diff --git a/src/ArrowDbCore/Readme.Nuget.md b/src/ArrowDbCore/Readme.Nuget.md index b3db0de..123342e 100644 --- a/src/ArrowDbCore/Readme.Nuget.md +++ b/src/ArrowDbCore/Readme.Nuget.md @@ -4,7 +4,7 @@ A fast, lightweight, and type-safe key-value database designed for .NET. * Super-Lightweight (dll size is ~19KB - approximately 9X smaller than [UltraLiteDb](https://github.com/rejemy/UltraLiteDB)) * Ultra-Fast (1,000,000 random operations / ~98ms on M2 MacBook Pro) -* Minimal-Allocation (constant ~520 bytes for serialization any db size) +* Minimal-Allocation (constant ~520 bytes for serialization of any db size) * Thread-Safe and Concurrent * ACID compliant on transaction level * Type-Safe (no reflection - compile-time enforced via source-generated `JsonSerializerContext`)