Skip to content

Commit 879c4a8

Browse files
authored
feat!: add ReactiveUI.Primitives support (#1227)
* feat!: add ReactiveUI.Primitives support - Compile the shared source against ReactiveUI.Primitives so Akavache.X publishes IObservable<RxVoid> and ISequencer, with no System.Reactive at runtime - Add Akavache.X.Reactive: the same files under REACTIVE_SHIM against ReactiveUI.Primitives.Reactive, publishing IObservable<Unit> and IScheduler - Shift every Akavache namespace to Akavache.Reactive.* on that leaf so both packages can be referenced side by side - Drop the in-repo fused-sink forks now that Primitives ships the same operators - Route the RxVoid and bool returns at the Advanced singleton sinks - Track the public surface of both leaves per target framework - Move every package pin to its current release BREAKING CHANGE: the Akavache.* packages now speak ReactiveUI.Primitives. Public signatures return IObservable<RxVoid> and take ISequencer where they previously used System.Reactive's Unit and IScheduler. Consumers already on System.Reactive should switch to the matching Akavache.*.Reactive package, whose surface is unchanged apart from the Akavache.Reactive.* namespace. * fix: wait for cache operations in tests instead of cancelling them SubscribeAndComplete disposes its subscription as soon as Subscribe returns, so any source that has not finished synchronously is cancelled. The deleted in-repo helper of the same name never disposed, so operations ran to completion; swapping to the Primitives one silently changed that. CacheDatabase.ResetForTests runs Shutdown and only clears _instance from the Do on completion, so a cancelled reset leaves a half-torn-down sqlite worker behind and wedges the next test. In a NotInParallel assembly that stalls the rest of the run. - Use WaitForCompletion at all 471 call sites: blocks until the operation finishes, rethrows its error, and gives up after 30s rather than hanging * refactor: delete the fused sinks Primitives replaced Removing the in-repo operator forks left their backing observables with no caller. RunAllObservable and TrySelectObservable had none at all; CatchReturnObservable and WhereSelectObservable were kept alive only by their own test files. Primitives supplies and tests all four. - Delete RunAllObservable, TrySelectObservable, CatchReturnObservable and WhereSelectObservable, plus the two test files that existed solely for them - Repoint the remaining crefs at the ReactiveExtensions members that took over * fix: stop the encrypted settings tests holding two connections to one database Both tests kept the store the builder created alive while opening a second store on the same encrypted file, so the second connection's CREATE TABLE raced the first and failed with SQLITE_BUSY. The error went unnoticed while it was being swallowed; WaitForCompletion surfaces it. - Dispose the builder-created store, and its file handles, before opening the fresh store the write goes through
1 parent 8f118ca commit 879c4a8

874 files changed

Lines changed: 44070 additions & 3696 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/Akavache.Core/Akavache.csproj‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,19 @@
1010
<ItemGroup>
1111
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
1212
<PackageReference Include="Splat.Builder" />
13-
<PackageReference Include="System.Reactive" />
13+
<PackageReference Include="ReactiveUI.Primitives" ExcludeAssets="analyzers" />
1414
<PackageReference Include="System.Memory" Condition="$(TargetFramework.StartsWith('net4'))" />
1515
</ItemGroup>
16+
17+
<!-- Akavache's own namespaces, turned into global usings by Directory.Build.targets (shifted to
18+
Akavache.Reactive.* on the .Reactive leaf). -->
19+
<ItemGroup>
20+
<AkavacheInternalUsing Include="Akavache" />
21+
<AkavacheInternalUsing Include="Akavache.Core" />
22+
<AkavacheInternalUsing Include="Akavache.Core.Observables" />
23+
<AkavacheInternalUsing Include="Akavache.Helpers" />
24+
<AkavacheInternalUsing Include="Akavache.Settings" />
25+
</ItemGroup>
1626
<ItemGroup>
1727
<InternalsVisibleTo Include="Akavache.HttpDownloader.Tests" />
1828
<InternalsVisibleTo Include="Akavache.Integration.Tests" />

‎src/Akavache.Core/AkavacheBuilderExtensions.cs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
using System.Diagnostics.CodeAnalysis;
66
using System.IO.IsolatedStorage;
77
using System.Reflection;
8-
using Akavache.Core;
9-
using Akavache.Helpers;
108
using Splat;
119
using Splat.Builder;
1210

11+
#if REACTIVE_SHIM
12+
namespace Akavache.Reactive;
13+
#else
1314
namespace Akavache;
15+
#endif
1416

1517
/// <summary>Provides extension methods for configuring Akavache cache database with Splat application builders.</summary>
1618
public static class AkavacheBuilderExtensions

‎src/Akavache.Core/AkavacheSqliteException.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
// ReactiveUI Association Incorporated licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for full license information.
44

5+
#if REACTIVE_SHIM
6+
namespace Akavache.Reactive;
7+
#else
58
namespace Akavache;
9+
#endif
610

711
/// <summary>
812
/// Raised when a native SQLite call returns a non-success result code. Carries the raw

‎src/Akavache.Core/CacheDatabase.cs‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
// See the LICENSE file in the project root for full license information.
44

55
using System.Diagnostics.CodeAnalysis;
6-
using Akavache.Core;
7-
using Akavache.Core.Observables;
86

7+
#if REACTIVE_SHIM
8+
namespace Akavache.Reactive;
9+
#else
910
namespace Akavache;
11+
#endif
1012

1113
/// <summary>
1214
/// CacheDatabase is the main entry point for interacting with Akavache. It provides
@@ -19,9 +21,9 @@ public static class CacheDatabase
1921
private static IAkavacheInstance? _instance;
2022

2123
/// <summary>Gets or sets the Scheduler used for task pools.</summary>
22-
public static IScheduler TaskpoolScheduler
24+
public static ISequencer TaskpoolScheduler
2325
{
24-
get => field ?? TaskPoolScheduler.Default;
26+
get => field ?? TaskPoolSequencer.Default;
2527
set;
2628
}
2729

@@ -79,13 +81,13 @@ public static IScheduler TaskpoolScheduler
7981
/// all data is properly saved.
8082
/// </summary>
8183
/// <returns>An observable that completes when shutdown is finished.</returns>
82-
public static IObservable<Unit> Shutdown()
84+
public static IObservable<RxVoid> Shutdown()
8385
{
8486
// Snapshot to avoid concurrent modification issues during shutdown.
8587
var instance = Volatile.Read(ref _instance);
8688
if (instance is null)
8789
{
88-
return CachedObservables.UnitDefault;
90+
return ImmutableReturnRxVoidSignal.Instance;
8991
}
9092

9193
// Dispose registered blob caches and settings stores synchronously.
@@ -103,7 +105,7 @@ public static IObservable<Unit> Shutdown()
103105

104106
try
105107
{
106-
List<IObservable<Unit>> flushTasks =
108+
List<IObservable<RxVoid>> flushTasks =
107109
[
108110
FlushOrComplete(instance.UserAccount),
109111
FlushOrComplete(instance.LocalMachine),
@@ -115,7 +117,7 @@ public static IObservable<Unit> Shutdown()
115117
}
116118
catch (Exception ex)
117119
{
118-
return Observable.Throw<Unit>(ex);
120+
return new ImmediateThrowSignal<RxVoid>(ex);
119121
}
120122
}
121123

@@ -294,11 +296,11 @@ public static IAkavacheBuilder CreateBuilder() =>
294296

295297
/// <summary>Resets all CacheDatabase state for testing purposes.</summary>
296298
/// <returns>An observable that completes once shutdown and reset are done.</returns>
297-
internal static IObservable<Unit> ResetForTests()
299+
internal static IObservable<RxVoid> ResetForTests()
298300
{
299301
var shutdown = Volatile.Read(ref _instance) is not null
300-
? Shutdown().Catch<Unit, Exception>(static _ => Observable.Return(Unit.Default))
301-
: Observable.Return(Unit.Default);
302+
? Shutdown().Catch<RxVoid, Exception>(static _ => ImmutableReturnRxVoidSignal.Instance)
303+
: ImmutableReturnRxVoidSignal.Instance;
302304

303305
return shutdown.Do(static _ =>
304306
{
@@ -314,8 +316,8 @@ internal static IObservable<Unit> ResetForTests()
314316
/// </summary>
315317
/// <param name="cache">The cache occupying one of the instance's four slots, if any.</param>
316318
/// <returns>An observable that completes once the flush finishes.</returns>
317-
internal static IObservable<Unit> FlushOrComplete(IBlobCache? cache) =>
318-
cache?.Flush() ?? CachedObservables.UnitDefault;
319+
internal static IObservable<RxVoid> FlushOrComplete(IBlobCache? cache) =>
320+
cache?.Flush() ?? ImmutableReturnRxVoidSignal.Instance;
319321

320322
/// <summary>Internal method to set the instance.</summary>
321323
/// <param name="builder">The configured instance.</param>

‎src/Akavache.Core/CacheEntry.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
// ReactiveUI Association Incorporated licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for full license information.
44

5+
#if REACTIVE_SHIM
6+
namespace Akavache.Reactive;
7+
#else
58
namespace Akavache;
9+
#endif
610

711
/// <summary>
812
/// Represents an entry in a memory cache. The synthesized record equality is

‎src/Akavache.Core/CheckpointMode.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
// ReactiveUI Association Incorporated licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for full license information.
44

5+
#if REACTIVE_SHIM
6+
namespace Akavache.Reactive;
7+
#else
58
namespace Akavache;
9+
#endif
610

711
/// <summary>
812
/// Defines the durability and performance characteristics of a checkpoint operation.

‎src/Akavache.Core/Core/AkavacheBuilder.cs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
// See the LICENSE file in the project root for full license information.
44

55
using System.Reflection;
6-
using Akavache.Settings;
76
using Splat;
87

8+
#if REACTIVE_SHIM
9+
namespace Akavache.Reactive.Core;
10+
#else
911
namespace Akavache.Core;
12+
#endif
1013

1114
/// <summary>Provides the default implementation of the Akavache builder interface for configuring cache instances.</summary>
1215
internal class AkavacheBuilder : IAkavacheBuilder

‎src/Akavache.Core/Core/CachedObservables.cs‎

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎src/Akavache.Core/Core/FileLocationOption.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
// ReactiveUI Association Incorporated licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for full license information.
44

5+
#if REACTIVE_SHIM
6+
namespace Akavache.Reactive.Core;
7+
#else
58
namespace Akavache.Core;
9+
#endif
610

711
/// <summary>File Location Option.</summary>
812
public enum FileLocationOption

‎src/Akavache.Core/Core/KeyMetadata.NonGeneric.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
// ReactiveUI Association Incorporated licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for full license information.
44

5+
#if REACTIVE_SHIM
6+
namespace Akavache.Reactive.Core;
7+
#else
58
namespace Akavache.Core;
9+
#endif
610

711
/// <summary>
812
/// Non-generic companion holding the pure per-<see cref="Type"/> reflection logic used by

0 commit comments

Comments
 (0)
⌂ 换网址