diff --git a/.editorconfig b/.editorconfig index cd6889b2..981e8ba2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -174,6 +174,9 @@ dotnet_diagnostic.CA1056.severity = none # Validate arguments of public methods dotnet_diagnostic.CA1062.severity = none +# CancellationToken parameters must come last +dotnet_diagnostic.CA1068.severity = error + # Do not pass literals as localized parameters dotnet_diagnostic.CA1303.severity = suggestion diff --git a/src/UiPath.Caching/MultilayerCacheBase.LayeredEntry.cs b/src/UiPath.Caching/MultilayerCacheBase.LayeredEntry.cs index 70760915..fe517739 100644 --- a/src/UiPath.Caching/MultilayerCacheBase.LayeredEntry.cs +++ b/src/UiPath.Caching/MultilayerCacheBase.LayeredEntry.cs @@ -130,7 +130,7 @@ public ValueTask PublishSetAsync(TOptions options, VersionedWrite counted } /// A source that ends with or after ; is the budget's own source, set only when the clock is not the system one. - private static CancellationTokenSource LinkReadBudget(TimeProvider clock, CancellationToken ct, TimeSpan budget, out CancellationTokenSource? timeout) + private static CancellationTokenSource LinkReadBudget(TimeProvider clock, TimeSpan budget, CancellationToken ct, out CancellationTokenSource? timeout) { if (ReferenceEquals(clock, TimeProvider.System)) { @@ -266,7 +266,7 @@ private async ValueTask TryAdoptInnerAsync(CacheKey originalCacheKey, Date var rehydrate = policy.Rehydrate!; var options = shape.BuildOptions(originalCacheKey, entryExpiration, ct); var budget = RehydrationCoordinator.AdoptReadTimeout(rehydrate, duration); - var read = LinkReadBudget(cache._clock, ct, budget, out var timeout); + var read = LinkReadBudget(cache._clock, budget, ct, out var timeout); using var timeoutScope = timeout; using var readScope = read; var mark = cache.MarkInnerRead(options.CacheKey.Name, options.TopicKey); diff --git a/tests/UiPath.Caching.Migration.Tests/KeyMove/HashMoverTests.cs b/tests/UiPath.Caching.Migration.Tests/KeyMove/HashMoverTests.cs index e6437b33..3b658534 100644 --- a/tests/UiPath.Caching.Migration.Tests/KeyMove/HashMoverTests.cs +++ b/tests/UiPath.Caching.Migration.Tests/KeyMove/HashMoverTests.cs @@ -460,9 +460,9 @@ public async Task A_hash_move_reports_the_source_ttl_and_its_request_time() var result = await Target(kit).MoveAsync("k", TimeSpan.Zero, kit.Kit.Id, AlwaysOwned.Instance, (ttl, at) => seen.Add((ttl, at)), Ct); result.Moved.Should().BeTrue(); - var observed = seen.Should().ContainSingle().Subject; - observed.At.Should().Be(Start.ToUnixTimeMilliseconds()); - observed.Ttl.Should().BeInRange(1, (long)TimeSpan.FromMinutes(5).TotalMilliseconds); + var (ttl, at) = seen.Should().ContainSingle().Subject; + at.Should().Be(Start.ToUnixTimeMilliseconds()); + ttl.Should().BeInRange(1, (long)TimeSpan.FromMinutes(5).TotalMilliseconds); } [Theory] diff --git a/tests/UiPath.Caching.Tests/KeyMove/RedisSignals.cs b/tests/UiPath.Caching.Tests/KeyMove/RedisSignals.cs index df427a6f..6e38d040 100644 --- a/tests/UiPath.Caching.Tests/KeyMove/RedisSignals.cs +++ b/tests/UiPath.Caching.Tests/KeyMove/RedisSignals.cs @@ -39,15 +39,16 @@ public static async Task ObserveExpiryAsync(IConnectionMulti var subscriber = admin.GetSubscriber(); var channel = RedisChannel.Literal("__keyevent@0__:expired"); var expired = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - Action handler = (_, value) => + void OnExpired(RedisChannel _, RedisValue value) { if (value == key.ToString()) { expired.TrySetResult(); } - }; - await subscriber.SubscribeAsync(channel, handler); - return new ExpirySubscription(admin, server, subscriber, channel, handler, before, expired.Task); + } + + await subscriber.SubscribeAsync(channel, OnExpired); + return new ExpirySubscription(admin, server, subscriber, channel, OnExpired, before, expired.Task); } internal sealed class ExpirySubscription(ConnectionMultiplexer admin, IServer server, ISubscriber subscriber, RedisChannel channel, Action handler, string before, Task expired) : IAsyncDisposable