-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: change return type of ReturnsAsync to IReturnMethodSetupReturnBuilder
#366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 changes the return type of the ReturnsAsync extension methods from IReturnMethodSetup to IReturnMethodSetupReturnBuilder to support fluent chaining with builder methods like When and Only.
Changes:
- Updated all
ReturnsAsyncmethod signatures to returnIReturnMethodSetupReturnBuilderinstead ofIReturnMethodSetup - Added comprehensive tests demonstrating the new fluent API capabilities with
WhenandOnlychaining - Updated API baseline files to reflect the new method signatures
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| Source/Mockolate/ReturnsAsyncExtensions.cs | Changed return type from IReturnMethodSetup to IReturnMethodSetupReturnBuilder for all ReturnsAsync methods |
| Source/Mockolate.SourceGenerators/Sources/Sources.ReturnsAsyncExtensions.cs | Updated source generator to emit IReturnMethodSetupReturnBuilder return type |
| Tests/Mockolate.Tests/ReturnsAsyncExtensionsTests.cs | Added tests verifying When and Only can be chained after ReturnsAsync |
| Tests/Mockolate.SourceGenerators.Tests/Sources/ReturnsAsyncExtensionsTests.cs | Updated test expectations to validate new return type in generated code |
| Tests/Mockolate.Api.Tests/Expected/Mockolate_netstandard2.0.txt | Updated API baseline for .NET Standard 2.0 |
| Tests/Mockolate.Api.Tests/Expected/Mockolate_net8.0.txt | Updated API baseline for .NET 8.0 |
| Tests/Mockolate.Api.Tests/Expected/Mockolate_net10.0.txt | Updated API baseline for .NET 10.0 |
🚀 Benchmark ResultsDetails
|
c6ec3fb to
30d938d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 10 comments.
| } | ||
|
|
||
| [Fact] | ||
| public async Task ReturnsAsync_1Parameter_ShouldSupportWhenAndFor() |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test method name uses 'For' but the test uses Only(1). The method should be named 'ReturnsAsync_1Parameter_ShouldSupportWhenAndOnly' to accurately reflect what is being tested.
| public async Task ReturnsAsync_1Parameter_ShouldSupportWhenAndFor() | |
| public async Task ReturnsAsync_1Parameter_ShouldSupportWhenAndOnly() |
| } | ||
|
|
||
| [Fact] | ||
| public async Task ReturnsAsync_2Parameters_ShouldSupportWhenAndFor() |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test method name uses 'For' but the test uses Only(1). The method should be named 'ReturnsAsync_2Parameters_ShouldSupportWhenAndOnly' to accurately reflect what is being tested.
| public async Task ReturnsAsync_2Parameters_ShouldSupportWhenAndFor() | |
| public async Task ReturnsAsync_2Parameters_ShouldSupportWhenAndOnly() |
| } | ||
|
|
||
| [Fact] | ||
| public async Task ReturnsAsync_3Parameters_ShouldSupportWhenAndFor() |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test method name uses 'For' but the test uses Only(1). The method should be named 'ReturnsAsync_3Parameters_ShouldSupportWhenAndOnly' to accurately reflect what is being tested.
| public async Task ReturnsAsync_3Parameters_ShouldSupportWhenAndFor() | |
| public async Task ReturnsAsync_3Parameters_ShouldSupportWhenAndOnly() |
| } | ||
|
|
||
| [Fact] | ||
| public async Task ReturnsAsync_4Parameters_ShouldSupportWhenAndFor() |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test method name uses 'For' but the test uses Only(1). The method should be named 'ReturnsAsync_4Parameters_ShouldSupportWhenAndOnly' to accurately reflect what is being tested.
| public async Task ReturnsAsync_4Parameters_ShouldSupportWhenAndFor() | |
| public async Task ReturnsAsync_4Parameters_ShouldSupportWhenAndOnly() |
| } | ||
|
|
||
| [Fact] | ||
| public async Task ReturnsAsync_NoParameters_ShouldSupportWhenAndFor() |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test method name uses 'For' but the test uses Only(1). The method should be named 'ReturnsAsync_NoParameters_ShouldSupportWhenAndOnly' to accurately reflect what is being tested.
| public async Task ReturnsAsync_NoParameters_ShouldSupportWhenAndFor() | |
| public async Task ReturnsAsync_NoParameters_ShouldSupportWhenAndOnly() |
| } | ||
|
|
||
| [Fact] | ||
| public async Task ReturnsAsync_1Parameter_ShouldSupportWhenAndFor() |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test method name uses 'For' but the test uses Only(1). The method should be named 'ReturnsAsync_1Parameter_ShouldSupportWhenAndOnly' to accurately reflect what is being tested.
| public async Task ReturnsAsync_1Parameter_ShouldSupportWhenAndFor() | |
| public async Task ReturnsAsync_1Parameter_ShouldSupportWhenAndOnly() |
| } | ||
|
|
||
| [Fact] | ||
| public async Task ReturnsAsync_2Parameters_ShouldSupportWhenAndFor() |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test method name uses 'For' but the test uses Only(1). The method should be named 'ReturnsAsync_2Parameters_ShouldSupportWhenAndOnly' to accurately reflect what is being tested.
| public async Task ReturnsAsync_2Parameters_ShouldSupportWhenAndFor() | |
| public async Task ReturnsAsync_2Parameters_ShouldSupportWhenAndOnly() |
| } | ||
|
|
||
| [Fact] | ||
| public async Task ReturnsAsync_3Parameters_ShouldSupportWhenAndFor() |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test method name uses 'For' but the test uses Only(1). The method should be named 'ReturnsAsync_3Parameters_ShouldSupportWhenAndOnly' to accurately reflect what is being tested.
| public async Task ReturnsAsync_3Parameters_ShouldSupportWhenAndFor() | |
| public async Task ReturnsAsync_3Parameters_ShouldSupportWhenAndOnly() |
| } | ||
|
|
||
| [Fact] | ||
| public async Task ReturnsAsync_4Parameters_ShouldSupportWhenAndFor() |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test method name uses 'For' but the test uses Only(1). The method should be named 'ReturnsAsync_4Parameters_ShouldSupportWhenAndOnly' to accurately reflect what is being tested.
| public async Task ReturnsAsync_4Parameters_ShouldSupportWhenAndFor() | |
| public async Task ReturnsAsync_4Parameters_ShouldSupportWhenAndOnly() |
| } | ||
|
|
||
| [Fact] | ||
| public async Task ReturnsAsync_NoParameters_ShouldSupportWhenAndFor() |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test method name uses 'For' but the test uses Only(1). The method should be named 'ReturnsAsync_NoParameters_ShouldSupportWhenAndOnly' to accurately reflect what is being tested.
| public async Task ReturnsAsync_NoParameters_ShouldSupportWhenAndFor() | |
| public async Task ReturnsAsync_NoParameters_ShouldSupportWhenAndOnly() |
|
|
This is addressed in release v0.52.0. |



This PR changes the return type of the
ReturnsAsyncextension methods fromIReturnMethodSetuptoIReturnMethodSetupReturnBuilderto support fluent chaining with builder methods likeWhenandOnly.Key Changes:
ReturnsAsyncmethod signatures to returnIReturnMethodSetupReturnBuilderinstead ofIReturnMethodSetupWhenandOnlychainingReturnsAsync#365