Skip to content

feat: add Stopwatch support to ITimeSystem#943

Merged
vbreuss merged 3 commits intomainfrom
topic/add-stopwatch-support
Feb 20, 2026
Merged

feat: add Stopwatch support to ITimeSystem#943
vbreuss merged 3 commits intomainfrom
topic/add-stopwatch-support

Conversation

@vbreuss
Copy link
Member

@vbreuss vbreuss commented Feb 20, 2026

Adds a System.Diagnostics.Stopwatch abstraction to ITimeSystem, enabling both RealTimeSystem and MockTimeSystem consumers to create/use stopwatches through a testable interface.

Key Changes:

  • Introduces IStopwatch and IStopwatchFactory and wires them into ITimeSystem, RealTimeSystem, and MockTimeSystem.
  • Implements real wrappers (StopwatchFactory/StopwatchWrapper) and mock implementations (StopwatchFactoryMock/StopwatchMock), plus parity and unit tests.
  • Adds a feature flag for Stopwatch.GetElapsedTime (.NET 8 or higher)
  • Adjusts build/project configuration (conditional PackageReference vs ProjectReference for the Interface project, pipeline + versioning tweaks).

@vbreuss vbreuss self-assigned this Feb 20, 2026
@vbreuss vbreuss added the enhancement New feature or request label Feb 20, 2026
@github-actions
Copy link

github-actions bot commented Feb 20, 2026

Test Results

 1 files   -      51   1 suites   - 51   0s ⏱️ - 36m 1s
13 tests  -  64 419  12 ✅  -  60 805  1 💤  -  3 614  0 ❌ ±0 
13 runs   - 133 311  12 ✅  - 118 768  1 💤  - 14 543  0 ❌ ±0 

Results for commit 1252944. ± Comparison against base commit 0ba083b.

♻️ This comment has been updated with latest results.

@vbreuss vbreuss force-pushed the topic/add-stopwatch-support branch from 7af03b5 to 01e3f72 Compare February 20, 2026 14:40
@vbreuss vbreuss marked this pull request as ready for review February 20, 2026 14:40
Copilot AI review requested due to automatic review settings February 20, 2026 14:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a System.Diagnostics.Stopwatch abstraction to ITimeSystem, enabling both RealTimeSystem and MockTimeSystem consumers to create/use stopwatches through a testable interface.

Changes:

  • Introduces IStopwatch and IStopwatchFactory and wires them into ITimeSystem, RealTimeSystem, and MockTimeSystem.
  • Implements real wrappers (StopwatchFactory/StopwatchWrapper) and mock implementations (StopwatchFactoryMock/StopwatchMock), plus parity and unit tests.
  • Adjusts build/project configuration (conditional PackageReference vs ProjectReference for the Interface project, feature flag for Stopwatch.GetElapsedTime, pipeline + versioning tweaks).

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
Tests/Testably.Abstractions.Tests/TimeSystem/StopwatchTests.cs New time-system tests for IStopwatch behavior.
Tests/Testably.Abstractions.Tests/TimeSystem/StopwatchFactoryTests.cs New tests for IStopwatchFactory static-like members and GetElapsedTime (feature-gated).
Tests/Testably.Abstractions.Tests/Testably.Abstractions.Tests.csproj Debug uses Interface ProjectReference; non-Debug uses PackageReference.
Tests/Testably.Abstractions.Testing.Tests/TimeSystem/StopwatchMockTests.cs New mock-specific precision test for tick-based elapsed behavior.
Tests/Testably.Abstractions.Testing.Tests/Testably.Abstractions.Testing.Tests.csproj Debug uses Interface ProjectReference; non-Debug uses PackageReference.
Tests/Testably.Abstractions.Parity.Tests/Testably.Abstractions.Parity.Tests.csproj Debug uses Interface ProjectReference; non-Debug uses PackageReference; refactors Compression reference group.
Tests/Testably.Abstractions.Parity.Tests/TestHelpers/Parity.cs Adds parity configuration for Stopwatch comparisons.
Tests/Testably.Abstractions.Parity.Tests/ParityTests.cs Adds parity test for IStopwatch/IStopwatchFactory vs System.Diagnostics.Stopwatch.
Tests/Helpers/Testably.Abstractions.TestHelpers/Testably.Abstractions.TestHelpers.csproj Debug uses Interface ProjectReference; non-Debug uses PackageReference.
Source/Testably.Abstractions/TimeSystem/TimerFactory.cs Fixes incorrect <inheritdoc> cref for Wrap(Timer).
Source/Testably.Abstractions/TimeSystem/StopwatchWrapper.cs New real wrapper implementing IStopwatch.
Source/Testably.Abstractions/TimeSystem/StopwatchFactory.cs New real factory implementing IStopwatchFactory.
Source/Testably.Abstractions/Testably.Abstractions.csproj Debug uses Interface ProjectReference; non-Debug uses PackageReference.
Source/Testably.Abstractions/RealTimeSystem.cs Adds Stopwatch factory property and initialization.
Source/Testably.Abstractions.Testing/TimeSystem/TimerFactoryMock.cs Fixes incorrect <inheritdoc> cref for Wrap(Timer).
Source/Testably.Abstractions.Testing/TimeSystem/StopwatchMock.cs New mock stopwatch implementation based on mocked time provider.
Source/Testably.Abstractions.Testing/TimeSystem/StopwatchFactoryMock.cs New mock stopwatch factory implementing IStopwatchFactory.
Source/Testably.Abstractions.Testing/Testably.Abstractions.Testing.csproj Debug uses Interface ProjectReference; non-Debug uses PackageReference.
Source/Testably.Abstractions.Testing/MockTimeSystem.cs Adds Stopwatch property; renames internal timer factory field for clarity.
Source/Testably.Abstractions.Testing/Helpers/ExceptionFactory.cs Adds NotSupported exception factory for stopwatch wrapping in mock.
Source/Testably.Abstractions.Interface/TimeSystem/IStopwatchFactory.cs New public stopwatch factory abstraction.
Source/Testably.Abstractions.Interface/TimeSystem/IStopwatch.cs New public stopwatch abstraction.
Source/Testably.Abstractions.Interface/ITimeSystem.cs Adds Stopwatch property to the time system abstraction.
Source/Testably.Abstractions.Compression/Testably.Abstractions.Compression.csproj Debug uses Interface ProjectReference; non-Debug uses PackageReference.
Source/Testably.Abstractions.AccessControl/Testably.Abstractions.AccessControl.csproj Debug uses Interface ProjectReference; non-Debug uses PackageReference.
Source/Directory.Build.props Sets a local build Version fallback (intended to be overridden in pipeline).
Pipeline/Build.cs Changes default BuildScope (affects CI target gating).
Feature.Flags.props Adds FEATURE_STOPWATCH_GETELAPSEDTIME for net8+.

@vbreuss vbreuss force-pushed the topic/add-stopwatch-support branch from 2ff34a7 to 96ed83d Compare February 20, 2026 15:25
@vbreuss vbreuss force-pushed the topic/add-stopwatch-support branch from 96ed83d to 1252944 Compare February 20, 2026 15:29
@vbreuss vbreuss merged commit bcc0254 into main Feb 20, 2026
12 checks passed
@vbreuss vbreuss deleted the topic/add-stopwatch-support branch February 20, 2026 15:36
@github-actions
Copy link

This is addressed in release v5.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request state: released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants