Sharpify.Data
2.4.0
See the version list below for details.
dotnet add package Sharpify.Data --version 2.4.0
NuGet\Install-Package Sharpify.Data -Version 2.4.0
<PackageReference Include="Sharpify.Data" Version="2.4.0" />
paket add Sharpify.Data --version 2.4.0
#r "nuget: Sharpify.Data, 2.4.0"
// Install Sharpify.Data as a Cake Addin #addin nuget:?package=Sharpify.Data&version=2.4.0 // Install Sharpify.Data as a Cake Tool #tool nuget:?package=Sharpify.Data&version=2.4.0
CHANGELOG
v2.4.0
- Added an overload for
Remove
which takes in aFunc<string, bool> keySelector
, this function is more optimized then using if you were to iterate yourself and call the oldRemove
as this one will execute serialization only once at the end, and only if removals actually happened (selector actually matched at least one key).- The new
Remove
method also has an overload that accepts astring? preFilter
as well, which can be used to only check keys that start withpreFilter
(thekeySelector
doesn't need to account for it, it will applied to a slice if thepreFilter
is matched), if leftnull
it will be ignored. - This addition was also propagated to both implementations of the
IDatabaseFilter<T>
, i.eMemoryPackDatabaseFilter<T>
andFlexibleDatabaseFilter<T>
, both of which modify the incoming delegate to the use the filtered key, enabling simple delegate matches without relying on implementation details, they don't have the option to use apreFilter
as they themselves use the statically generated type filters they create.
- The new
- To accommodate the
Remove
methods,MemoryPackDatabaseFilter<T>
andFlexibleDatabaseFilter<T>
now create apublic static readonly string KeyFilter
property, which is the prefix they append to the keys, this is used internally forRemove
but perhaps the could help if you need to inherit from these classes and override theRemove
method.- Both of them also use
KeyFilter
internally to generate the filtered keys in a slightly more efficient way to before. - The
static readonly
field that contained the generic type name was also removed as it was integrated intoKeyFilter
at with no additional cost.
- Both of them also use
Reminder: Workaround for broken NativeAot support from MemoryPack
As of writing this, MemoryPack's NativeAot support is broken, for any type that isn't already in their cached types, the MemoryPackFormatterProvider
uses reflection to get the formatter, which fails in NativeAot.
As a workaround, we need to add the formatters ourselves, to do this, take any 1 static entry point, that activates before the database is loaded, and add this:
// for every T type that relies on MemoryPack for serialization, and their inheritance hierarchy
// This includes types that implement IMemoryPackable (i.e types that are decorated with MemoryPackable)
MemoryPackFormatterProvider.Register<T>();
// If the type is a collection or dictionary use the other corresponding overloads:
MemoryPackFormatterProvider.RegisterCollection<TCollection, TElement>();
// or
MemoryPackFormatterProvider.RegisterDictionary<TDictionary, TKey, TValue>();
// and so on...
// for all overloads check peek the definition of MemoryPackFormatterProvider, or their Github Repo
Note: Make sure you don't create a new static constructor in those types, MemoryPack
already creates those, you will need to find a different entry point.
With this the serializer should be able to bypass the part using reflection, and thus work even on NativeAot.
P.S. The base type of the Database is already registered the same way on its own static constructor.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- MemoryPack (>= 1.21.0)
- Sharpify (>= 1.7.3)
-
net8.0
- MemoryPack (>= 1.21.0)
- Sharpify (>= 1.7.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.6.0 | 87 | 11/13/2024 |
2.5.0 | 87 | 7/30/2024 |
2.4.1 | 88 | 6/3/2024 |
2.4.0 | 86 | 5/30/2024 |
2.3.0 | 129 | 4/17/2024 |
2.2.0 | 136 | 3/2/2024 |
2.1.3 | 118 | 1/25/2024 |
2.1.2 | 107 | 1/25/2024 |
2.1.1 | 111 | 1/25/2024 |
2.1.0 | 131 | 1/25/2024 |
2.0.2 | 107 | 1/23/2024 |
2.0.1 | 108 | 1/22/2024 |
2.0.0 | 103 | 1/20/2024 |
1.1.0 | 120 | 1/15/2024 |
1.0.3 | 129 | 1/8/2024 |
1.0.2 | 134 | 1/5/2024 |
1.0.1 | 128 | 1/4/2024 |
1.0.0 | 124 | 1/4/2024 |