Skip to content

Comments

refactor!: consolidate callback signatures between property and indexer setups#289

Merged
vbreuss merged 1 commit intomainfrom
topic/consolidate-callbacks-properties-indexers
Dec 8, 2025
Merged

refactor!: consolidate callback signatures between property and indexer setups#289
vbreuss merged 1 commit intomainfrom
topic/consolidate-callbacks-properties-indexers

Conversation

@vbreuss
Copy link
Contributor

@vbreuss vbreuss commented Dec 8, 2025

This PR refactors the callback signature order for both property and indexer setups, moving the value parameter to the end for consistency. Previously, property OnSet callbacks received (oldValue, newValue) while indexer callbacks placed the value first. The refactoring standardizes all callbacks to place indexer parameters first, followed by the value parameter last, matching common C# patterns where input parameters precede output/state parameters.

Key Changes

  • Property OnSet callbacks simplified from (oldValue, newValue) to just (newValue), removing access to the old value
  • Indexer callback signatures reordered to place the value parameter last: (TValue, T1, T2, ...) becomes (T1, T2, ..., TValue)
  • Updated API documentation with detailed remarks explaining parameter order
  • Comprehensive test updates reflecting the new signatures

@vbreuss vbreuss self-assigned this Dec 8, 2025
Copilot AI review requested due to automatic review settings December 8, 2025 14:22
@vbreuss vbreuss added the breaking change The changes require a new major version label Dec 8, 2025
@vbreuss vbreuss changed the title refactor!: consolidate callback signatures between property and index… refactor!: consolidate callback signatures between property and indexer setups Dec 8, 2025
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

This PR refactors the callback signature order for both property and indexer setups, moving the value parameter to the end for consistency. Previously, property OnSet callbacks received (oldValue, newValue) while indexer callbacks placed the value first. The refactoring standardizes all callbacks to place indexer parameters first, followed by the value parameter last, matching common C# patterns where input parameters precede output/state parameters.

Key Changes

  • Property OnSet callbacks simplified from (oldValue, newValue) to just (newValue), removing access to the old value
  • Indexer callback signatures reordered to place the value parameter last: (TValue, T1, T2, ...) becomes (T1, T2, ..., TValue)
  • Updated API documentation with detailed remarks explaining parameter order
  • Comprehensive test updates reflecting the new signatures

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Tests/Mockolate.Tests/MockProperties/SetupPropertyTests.OnSetTests.cs Updated property setup tests to use new single-parameter OnSet signature, removing old value tracking
Tests/Mockolate.Tests/MockIndexers/SetupIndexerTests.ReturnsThrowsTests.cs Updated indexer getter callback tests to reflect parameter reordering (value moved to end)
Tests/Mockolate.Tests/MockIndexers/SetupIndexerTests.OnSetTests.cs Updated indexer setter callback tests with reordered parameters (value moved to end)
Tests/Mockolate.Api.Tests/Expected/Mockolate_netstandard2.0.txt Updated API baseline for .NET Standard 2.0 with new callback signatures
Tests/Mockolate.Api.Tests/Expected/Mockolate_net8.0.txt Updated API baseline for .NET 8.0 with new callback signatures
Tests/Mockolate.Api.Tests/Expected/Mockolate_net10.0.txt Updated API baseline for .NET 10.0 with new callback signatures
Source/Mockolate/Setup/PropertySetup.cs Refactored property setup implementation to remove old value from callbacks and use single-parameter signature
Source/Mockolate/Setup/Interfaces.PropertySetup.cs Updated property setup interface to remove old value parameter from OnSet signatures
Source/Mockolate/Setup/Interfaces.IndexerSetup.cs Updated indexer setup interfaces with reordered parameters and enhanced documentation
Source/Mockolate/Setup/IndexerSetup.cs Refactored indexer setup implementation with new parameter ordering (value moved to end)
Source/Mockolate.SourceGenerators/Sources/Sources.IndexerSetups.cs Updated source generator to produce indexer setups with new parameter ordering

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 8, 2025

@vbreuss vbreuss enabled auto-merge (squash) December 8, 2025 14:26
@github-actions
Copy link

github-actions bot commented Dec 8, 2025

Test Results

    14 files  ±0      14 suites  ±0   5m 5s ⏱️ +17s
 1 505 tests ±0   1 504 ✅ ±0  1 💤 ±0  0 ❌ ±0 
10 024 runs  ±0  10 023 ✅ ±0  1 💤 ±0  0 ❌ ±0 

Results for commit 2ec49ac. ± Comparison against base commit a3341a9.

@vbreuss vbreuss merged commit c12edb5 into main Dec 8, 2025
12 checks passed
@vbreuss vbreuss deleted the topic/consolidate-callbacks-properties-indexers branch December 8, 2025 14:28
@github-actions
Copy link

github-actions bot commented Dec 8, 2025

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.3 LTS (Noble Numbat)
AMD EPYC 7763 2.45GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.100
[Host] : .NET 10.0.0 (10.0.0, 10.0.25.52411), X64 RyuJIT x86-64-v3

Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15
LaunchCount=1 WarmupCount=10

Method Mean Error StdDev Gen0 Gen1 Allocated
Simple_Mockolate 1.466 μs 0.0108 μs 0.0096 μs 0.2213 - 3.62 KB
Simple_Moq 172.976 μs 1.1707 μs 1.0951 μs 0.4883 - 14.55 KB
Simple_NSubstitute 5.463 μs 0.0318 μs 0.0265 μs 0.5569 0.0076 9.14 KB
Simple_FakeItEasy 6.038 μs 0.0272 μs 0.0241 μs 0.4959 - 8.11 KB

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

This is addressed in release v0.42.0.

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

Labels

breaking change The changes require a new major version state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add overload for OnSet with only one parameter

1 participant