Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the callback API for properties and indexers by introducing a mandatory Do method, replacing the previous pattern where OnGet and OnSet directly accepted callbacks. This is a breaking change that improves API clarity and consistency.
Key Changes:
- Changed
OnGetandOnSetfrom methods accepting callbacks to properties returning setup interfaces - Introduced
IPropertyGetterSetup/IPropertySetterSetupandIIndexerGetterSetup/IIndexerSetterSetupinterfaces withDomethods - Updated all test files to use the new
OnGet.Do(...)andOnSet.Do(...)syntax
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/Mockolate.Tests/Protected/ProtectedMockTests.cs | Updated protected indexer tests to use new .Do() callback API |
| Tests/Mockolate.Tests/MockProperties/SetupPropertyTests.OnSetTests.cs | Updated property setter tests to use OnSet.Do(...) instead of OnSet(...) |
| Tests/Mockolate.Tests/MockProperties/SetupPropertyTests.OnGetTests.cs | Updated property getter tests to use OnGet.Do(...) instead of OnGet(...) |
| Tests/Mockolate.Tests/MockIndexers/SetupIndexerTests.OnSetTests.cs | Updated indexer setter tests to use new OnSet.Do(...) pattern across all parameter counts |
| Tests/Mockolate.Tests/MockIndexers/SetupIndexerTests.OnGetTests.cs | Updated indexer getter tests to use new OnGet.Do(...) pattern across all parameter counts |
| Tests/Mockolate.Api.Tests/Expected/Mockolate_netstandard2.0.txt | Updated API baseline to reflect new property/indexer setup interfaces |
| Tests/Mockolate.Api.Tests/Expected/Mockolate_net8.0.txt | Updated API baseline for .NET 8 target |
| Tests/Mockolate.Api.Tests/Expected/Mockolate_net10.0.txt | Updated API baseline for .NET 10 target |
| Source/Mockolate/Setup/PropertySetup.cs | Implemented new OnGet/OnSet properties and explicit interface implementations for Do methods |
| Source/Mockolate/Setup/Interfaces.PropertySetup.cs | Introduced IPropertyGetterSetup and IPropertySetterSetup interfaces, refactored IPropertySetup |
| Source/Mockolate/Setup/Interfaces.IndexerSetup.cs | Introduced IIndexerGetterSetup and IIndexerSetterSetup interfaces for all parameter counts |
| Source/Mockolate/Setup/IndexerSetup.cs | Implemented new indexer setup pattern with OnGet/OnSet properties and explicit interface implementations |
| Source/Mockolate.SourceGenerators/Sources/Sources.IndexerSetups.cs | Updated source generator to produce new interface definitions and implementations |
|
🚀 Benchmark ResultsDetails
|
|
This is addressed in release v0.42.0. |



This PR refactors the callback API for properties and indexers by introducing a mandatory
Domethod, replacing the previous pattern whereOnGetandOnSetdirectly accepted callbacks. This is a breaking change that improves API clarity and consistency.Key Changes:
OnGetandOnSetfrom methods accepting callbacks to properties returning setup interfacesIPropertyGetterSetup/IPropertySetterSetupandIIndexerGetterSetup/IIndexerSetterSetupinterfaces withDomethodsOnGet.Do(...)andOnSet.Do(...)syntaxDofor callbacks #284