Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3740685
feat: V12 API changes, test coverage improvements, and codebase moder…
glennawatson Apr 11, 2026
93cd15d
test: refactor test executor into base class and split SettingsBase h…
glennawatson Apr 13, 2026
2e01e28
test: dispose previous Splat locator when resetting test state
glennawatson Apr 13, 2026
af8fc17
test: inject cache resolvers, cover Settings fallbacks, replace TestH…
glennawatson Apr 13, 2026
021bd9c
test: switch native SQLite tests to in-memory, individualise parallel…
glennawatson Apr 13, 2026
903437b
chore: editorconfig strictness sweep, structure cleanup, and test fixes
glennawatson Apr 13, 2026
893b215
further updates
glennawatson Apr 13, 2026
928113c
refactor: simplify null checks and logic flow, modernize codebase
glennawatson Apr 13, 2026
6f7cc1e
refactor: remove unused files, modernize code, and improve test coverage
glennawatson Apr 13, 2026
f8f0de3
refactor: modernize and streamline test implementations
glennawatson Apr 13, 2026
c488beb
refactor: update .editorconfig settings, simplify serializer logic, a…
glennawatson Apr 13, 2026
b57f3d3
refactor: update code coverage include pattern for Akavache DLLs
glennawatson Apr 13, 2026
eae33e9
refactor: update code coverage include patterns for DLLs and executables
glennawatson Apr 13, 2026
730f7ed
refactor: simplify code coverage configuration by removing unnecessar…
glennawatson Apr 13, 2026
e6a7785
refactor: streamline Dispose methods and enhance test coverage for Ca…
glennawatson Apr 13, 2026
a120374
refactor: update null equality checks in CacheEntry and LoginInfo tes…
glennawatson Apr 13, 2026
9d13997
refactor: remove null equality tests for CacheEntry and LoginInfo to …
glennawatson Apr 13, 2026
2e402c7
refactor: add comment to clarify disposal of managed resources in Dat…
glennawatson Apr 13, 2026
af6962d
refactor: remove unused Microsoft.Extensions.Logging namespace and ad…
glennawatson Apr 13, 2026
f8d6182
refactor: add DoesNotReturnAttribute polyfill and clean up conditiona…
glennawatson Apr 13, 2026
add59aa
refactor: improve compatibility and performance across various compon…
glennawatson Apr 13, 2026
081093e
refactor: enhance regex handling for BSON date serialization across t…
glennawatson Apr 13, 2026
0ccff1f
refactor: clean up conditional compilation and improve code organizat…
glennawatson Apr 13, 2026
c3dc0cf
refactor: improve settings store retrieval logic and remove unused re…
glennawatson Apr 13, 2026
55dc138
Fix the logger reference
glennawatson Apr 13, 2026
32b502b
test: add TestExecutor attribute to backward compatibility tests
glennawatson Apr 13, 2026
14c47fe
Make all tests run non-parallel in the main tests project.
glennawatson Apr 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ Settings are automatically persisted and will survive app updates, making them p
- **[Serializers](docs/serializers.md)** - System.Text.Json vs Newtonsoft.Json comparison
- **[Cache Types](docs/cache-types.md)** - UserAccount, LocalMachine, Secure, and InMemory caches
- **[Basic Operations](docs/basic-operations.md)** - CRUD operations and error handling
- **[Migration Guide](docs/migration-v10-to-v11.md)** - Upgrading from V10.x to V11.1
- **[Migration: V10 → V11](docs/migration-v10-to-v11.md)** - Upgrading from V10.x to V11.x
- **[Migration: V11 → V12](docs/migration-v11-to-v12.md)** - Upgrading from V11.x to V12.x
- **[Settings Management](docs/settings.md)** - Complete Akavache.Settings guide
- **[Platform Notes](docs/platform-notes.md)** - Platform-specific guidance
- **[Performance](docs/performance.md)** - Benchmarks and optimization tips
Expand Down
93 changes: 93 additions & 0 deletions docs/migration-v11-to-v12.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Migration from V11 to V12

This guide covers the changes between Akavache V11 and V12.

## Breaking Changes

#### System.Text.Json package split

`Akavache.SystemTextJson` has been split into two packages:

- **`Akavache.SystemTextJson`** - Pure System.Text.Json serializer (JSON only, no Newtonsoft dependency). AOT-compatible.
- **`Akavache.SystemTextJson.Bson`** - BSON format support using Newtonsoft.Json.Bson for encoding. Use this if you need to read/write BSON data with STJ.

**If you were using `SystemJsonBsonSerializer` or `UseSystemJsonBsonSerializer()`:**

```diff
- // v11: Single package
- using Akavache.SystemTextJson;
+ // v12: Add reference to Akavache.SystemTextJson.Bson
+ using Akavache.SystemTextJson; // SystemJsonBsonSerializer lives here (same namespace)
+ using Akavache.SystemTextJson.Bson; // Builder extensions (UseSystemJsonBsonSerializer)
```

Add a package/project reference to `Akavache.SystemTextJson.Bson`. The `SystemJsonBsonSerializer` class remains in the `Akavache.SystemTextJson` namespace so most code using the type directly won't need changes. Builder extension methods (`UseSystemJsonBsonSerializer`) moved to the `Akavache.SystemTextJson.Bson` namespace.

**If you were using only `SystemJsonSerializer` or `WithSerializerSystemTextJson()`:**

No changes needed. The `Akavache.SystemTextJson` package no longer pulls in Newtonsoft.Json.

#### SystemJsonBsonSerializer no longer inherits SystemJsonSerializer

`SystemJsonBsonSerializer` now uses composition instead of inheritance. It implements `ISerializer` directly and delegates JSON operations to an internal `SystemJsonSerializer` instance. Code that relied on `SystemJsonBsonSerializer is SystemJsonSerializer` will need updating.

#### AOT-safe `JsonTypeInfo` overloads live in Akavache.SystemTextJson, not ISerializer

`ISerializer` in `Akavache.Core` stays deliberately serializer-agnostic — it knows nothing about `System.Text.Json` and does not expose any `JsonTypeInfo<T>` overloads. The base interface still defines just the two reflection-based members:

```csharp
[RequiresUnreferencedCode("...")]
[RequiresDynamicCode("...")]
T? Deserialize<T>(byte[] bytes);

[RequiresUnreferencedCode("...")]
[RequiresDynamicCode("...")]
byte[] Serialize<T>(T item);
```

The AOT-safe `JsonTypeInfo<T>` path is provided by extension methods in the `Akavache.SystemTextJson.Bson` package (which transitively brings in `Akavache.SystemTextJson`). Importing the `Akavache.SystemTextJson` namespace gives you:

```csharp
using Akavache.SystemTextJson;

// At call sites, the call looks identical to an instance method:
var bytes = serializer.Serialize(myModel, AppJsonContext.Default.MyModel);
var result = serializer.Deserialize<MyModel>(bytes, AppJsonContext.Default.MyModel);
```

Under the hood the extension methods type-check the runtime serializer:

- `SystemJsonSerializer` → routes to its static `DeserializeAot` / `SerializeAot` methods (pure `JsonTypeInfo` path, no reflection)
- `SystemJsonBsonSerializer` → routes through the same path (BSON cannot be AOT-encoded, so the AOT overload emits plain JSON bytes)
- Any other `ISerializer` (for example Newtonsoft-backed) → throws `NotSupportedException`, because those implementations do not have an AOT path. Use the non-typed `Deserialize<T>(byte[])` / `Serialize<T>(T)` overloads on Newtonsoft.

This indirection keeps `Akavache.Core` free of a hard dependency on `System.Text.Json`, so Newtonsoft-only consumers do not transitively pull it in.

#### Trim/AOT attributes still apply to the reflection path

The `[RequiresUnreferencedCode]` and `[RequiresDynamicCode]` attributes remain on the reflection-based `ISerializer.Deserialize<T>(byte[])` / `ISerializer.Serialize<T>(T)` members — they have not been removed. Callers that publish with trimming or NativeAOT will still see the analyzer warnings for those methods, which is intentional: the correct AOT-safe path is the `JsonTypeInfo<T>` extension method described above.

### New Features

#### AOT-safe serialization with JsonTypeInfo

`SystemJsonSerializer` now implements the `JsonTypeInfo<T>` overloads for fully AOT-compatible serialization:

```csharp
// Define your serializer context
[JsonSerializable(typeof(MyModel))]
public partial class AppJsonContext : JsonSerializerContext { }

// Use AOT-safe overloads
var serializer = new SystemJsonSerializer();
var bytes = serializer.Serialize(myModel, AppJsonContext.Default.MyModel);
var result = serializer.Deserialize(bytes, AppJsonContext.Default.MyModel);
```

#### Universal serializer registry

The `UniversalSerializer` fallback mechanism now uses an explicit registry instead of runtime type discovery. Serializer packages register themselves automatically when configured through builder methods. For manual registration:

```csharp
UniversalSerializer.RegisterSerializer(() => new SystemJsonSerializer());
```
5 changes: 4 additions & 1 deletion src/Akavache.Benchmarks.V10/Akavache.Benchmarks.V10.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
<OutputType>Exe</OutputType>
<TargetFrameworks>net9.0</TargetFrameworks>
<IsPackable>false</IsPackable>

<!-- Benchmarks for legacy V10 APIs which use reflection by design - not AOT-compatible -->
<IsAotCompatible>false</IsAotCompatible>
<EnableTrimAnalyzer>false</EnableTrimAnalyzer>
<EnableAotAnalyzer>false</EnableAotAnalyzer>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/Akavache.Core/Akavache.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
<InternalsVisibleTo Include="Akavache.EncryptedSqlite3" />
<InternalsVisibleTo Include="Akavache.NewtonsoftJson" />
<InternalsVisibleTo Include="Akavache.SystemTextJson" />
<InternalsVisibleTo Include="Akavache.SystemTextJson.Bson" />
<InternalsVisibleTo Include="Akavache.Drawing" />
<InternalsVisibleTo Include="Akavache.Settings" />
<InternalsVisibleTo Include="Akavache.Tests" />
<InternalsVisibleTo Include="Akavache.Settings.Tests" />
<InternalsVisibleTo Include="Akavache.V10toV11" />
</ItemGroup>
</Project>
Loading
Loading