From 0d67174810e4742bf19c6af04086f13a84fa1f1e Mon Sep 17 00:00:00 2001 From: Cosmin Staicu Date: Sun, 29 Nov 2026 22:27:51 +0200 Subject: [PATCH 1/2] fix(sonar): clear the open issues on main and make CA1068 an error - LinkReadBudget takes its CancellationToken after the budget. - HashMoverTests deconstructs the observed tuple. - RedisSignals uses a local function for the expiry handler. Signed-off-by: Cosmin Staicu --- .editorconfig | 3 +++ src/UiPath.Caching/MultilayerCacheBase.LayeredEntry.cs | 4 ++-- .../KeyMove/HashMoverTests.cs | 6 +++--- tests/UiPath.Caching.Tests/KeyMove/RedisSignals.cs | 6 ++++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.editorconfig b/.editorconfig index cd6889b2d..981e8ba23 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 707609159..fe517739e 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 e6437b33b..3b6585343 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 df427a6f5..7fce32e7f 100644 --- a/tests/UiPath.Caching.Tests/KeyMove/RedisSignals.cs +++ b/tests/UiPath.Caching.Tests/KeyMove/RedisSignals.cs @@ -39,13 +39,15 @@ 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(); } - }; + } + + Action handler = OnExpired; await subscriber.SubscribeAsync(channel, handler); return new ExpirySubscription(admin, server, subscriber, channel, handler, before, expired.Task); } From 55592f8f220abcf396b8351f3381086e599f6495 Mon Sep 17 00:00:00 2001 From: Cosmin Staicu Date: Sun, 29 Nov 2026 23:09:45 +0200 Subject: [PATCH 2/2] test(key-move): pass the expiry handler as a method group Signed-off-by: Cosmin Staicu --- tests/UiPath.Caching.Tests/KeyMove/RedisSignals.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/UiPath.Caching.Tests/KeyMove/RedisSignals.cs b/tests/UiPath.Caching.Tests/KeyMove/RedisSignals.cs index 7fce32e7f..6e38d0405 100644 --- a/tests/UiPath.Caching.Tests/KeyMove/RedisSignals.cs +++ b/tests/UiPath.Caching.Tests/KeyMove/RedisSignals.cs @@ -47,9 +47,8 @@ void OnExpired(RedisChannel _, RedisValue value) } } - Action handler = OnExpired; - 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