Files
poli0981andClaude Opus 5.5 f345769e75 refactor: follow the analyzer suggestions SonarQube Cloud reports (#27)
The first CI-based analysis of main imported 104 info-level Roslyn
suggestions as issues (Sonar's own rules found nothing). Applied the fixes
the IDE offers, one diagnostic at a time:

- IDE0290: primary constructors (28 types). Fields stay readonly and are
  initialized from the parameters; <param> docs moved to the type.
- MVVMTK0042: [ObservableProperty] on public partial properties instead of
  fields (70 properties); initializers still set the backing field silently.
  UpdateViewModel's constructor now sets Status through the property, before
  anything subscribes.
- SYSLIB1054: CreateDirect3D11DeviceFromDXGIDevice uses [LibraryImport].
- IDE0007 / IDE0028: var, collection expression.
- Tests: index the monitor list directly (CA1826); seal
  ResxLocalizationServiceTests like the other disposable test classes (CA1816).
- Long primary-constructor parameter lists are wrapped one per line.
- CLAUDE.md: note that SonarQube Cloud reports these suggestions.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 06:38:16 +07:00

42 lines
1.5 KiB
C#

// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) CaptureImage Contributors
using Microsoft.Extensions.Time.Testing;
namespace CaptureImage.Core.Tests.TestSupport;
/// <summary>
/// A <see cref="FakeTimeProvider"/> that also reports every timer it hands out. A test can
/// wait until code under test is really blocked on <c>Task.Delay(…, timeProvider, …)</c>
/// before advancing the clock, so no advance is ever lost to a race.
/// </summary>
internal sealed class SignalingTimeProvider(DateTimeOffset start) : TimeProvider, IDisposable
{
private readonly SemaphoreSlim _timerCreated = new(0);
public FakeTimeProvider Fake { get; } = new(start);
public override TimeZoneInfo LocalTimeZone => Fake.LocalTimeZone;
public override long TimestampFrequency => Fake.TimestampFrequency;
public override DateTimeOffset GetUtcNow() => Fake.GetUtcNow();
public override long GetTimestamp() => Fake.GetTimestamp();
public override ITimer CreateTimer(TimerCallback callback, object? state, TimeSpan dueTime, TimeSpan period)
{
var timer = Fake.CreateTimer(callback, state, dueTime, period);
_timerCreated.Release();
return timer;
}
public void Advance(TimeSpan delta) => Fake.Advance(delta);
/// <summary>Wait for the next timer to be created; false on timeout.</summary>
public Task<bool> WaitForTimerAsync(CancellationToken cancellationToken) =>
_timerCreated.WaitAsync(TimeSpan.FromSeconds(10), cancellationToken);
public void Dispose() => _timerCreated.Dispose();
}