Skip to content

Conversation

@vbreuss
Copy link
Contributor

@vbreuss vbreuss commented Jan 15, 2026

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.

Key Changes:

  • Updated all ReturnsAsync method signatures to return IReturnMethodSetupReturnBuilder instead of IReturnMethodSetup
  • Added comprehensive tests demonstrating the new fluent API capabilities with When and Only chaining
  • Updated API baseline files to reflect the new method signatures

@vbreuss vbreuss self-assigned this Jan 15, 2026
Copilot AI review requested due to automatic review settings January 15, 2026 16:23
@vbreuss vbreuss added the enhancement New feature or request label Jan 15, 2026
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 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 ReturnsAsync method signatures to return IReturnMethodSetupReturnBuilder instead of IReturnMethodSetup
  • Added comprehensive tests demonstrating the new fluent API capabilities with When and Only chaining
  • 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

@github-actions
Copy link

github-actions bot commented Jan 15, 2026

Test Results

    14 files  ± 0      14 suites  ±0   5m 53s ⏱️ +38s
 2 175 tests +10   2 174 ✅ +10  1 💤 ±0  0 ❌ ±0 
14 555 runs  +65  14 554 ✅ +65  1 💤 ±0  0 ❌ ±0 

Results for commit 30d938d. ± Comparison against base commit ecb3045.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Jan 15, 2026

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.3 LTS (Noble Numbat)
Intel Xeon Platinum 8370C CPU 2.80GHz (Max: 2.79GHz), 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.102
[Host] : .NET 10.0.2 (10.0.2, 10.0.225.61305), X64 RyuJIT x86-64-v4

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

Method Mean Error StdDev Gen0 Gen1 Allocated
Simple_Mockolate 1.635 μs 0.0355 μs 0.0332 μs 0.1507 - 3.72 KB
Simple_Moq 136.056 μs 1.0852 μs 1.0151 μs 0.4883 0.2441 14.56 KB
Simple_NSubstitute 6.076 μs 0.0427 μs 0.0399 μs 0.3662 - 9.14 KB
Simple_FakeItEasy 5.816 μs 0.0362 μs 0.0302 μs 0.3281 - 8.12 KB

Copilot AI review requested due to automatic review settings January 17, 2026 15:59
@vbreuss vbreuss force-pushed the topic/change-returntype-of-returnsasync branch from c6ec3fb to 30d938d Compare January 17, 2026 15:59
@vbreuss vbreuss enabled auto-merge (squash) January 17, 2026 15:59
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

Copilot reviewed 7 out of 7 changed files in this pull request and generated 10 comments.

}

[Fact]
public async Task ReturnsAsync_1Parameter_ShouldSupportWhenAndFor()
Copy link

Copilot AI Jan 17, 2026

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.

Suggested change
public async Task ReturnsAsync_1Parameter_ShouldSupportWhenAndFor()
public async Task ReturnsAsync_1Parameter_ShouldSupportWhenAndOnly()

Copilot uses AI. Check for mistakes.
}

[Fact]
public async Task ReturnsAsync_2Parameters_ShouldSupportWhenAndFor()
Copy link

Copilot AI Jan 17, 2026

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.

Suggested change
public async Task ReturnsAsync_2Parameters_ShouldSupportWhenAndFor()
public async Task ReturnsAsync_2Parameters_ShouldSupportWhenAndOnly()

Copilot uses AI. Check for mistakes.
}

[Fact]
public async Task ReturnsAsync_3Parameters_ShouldSupportWhenAndFor()
Copy link

Copilot AI Jan 17, 2026

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.

Suggested change
public async Task ReturnsAsync_3Parameters_ShouldSupportWhenAndFor()
public async Task ReturnsAsync_3Parameters_ShouldSupportWhenAndOnly()

Copilot uses AI. Check for mistakes.
}

[Fact]
public async Task ReturnsAsync_4Parameters_ShouldSupportWhenAndFor()
Copy link

Copilot AI Jan 17, 2026

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.

Suggested change
public async Task ReturnsAsync_4Parameters_ShouldSupportWhenAndFor()
public async Task ReturnsAsync_4Parameters_ShouldSupportWhenAndOnly()

Copilot uses AI. Check for mistakes.
}

[Fact]
public async Task ReturnsAsync_NoParameters_ShouldSupportWhenAndFor()
Copy link

Copilot AI Jan 17, 2026

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.

Suggested change
public async Task ReturnsAsync_NoParameters_ShouldSupportWhenAndFor()
public async Task ReturnsAsync_NoParameters_ShouldSupportWhenAndOnly()

Copilot uses AI. Check for mistakes.
}

[Fact]
public async Task ReturnsAsync_1Parameter_ShouldSupportWhenAndFor()
Copy link

Copilot AI Jan 17, 2026

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.

Suggested change
public async Task ReturnsAsync_1Parameter_ShouldSupportWhenAndFor()
public async Task ReturnsAsync_1Parameter_ShouldSupportWhenAndOnly()

Copilot uses AI. Check for mistakes.
}

[Fact]
public async Task ReturnsAsync_2Parameters_ShouldSupportWhenAndFor()
Copy link

Copilot AI Jan 17, 2026

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.

Suggested change
public async Task ReturnsAsync_2Parameters_ShouldSupportWhenAndFor()
public async Task ReturnsAsync_2Parameters_ShouldSupportWhenAndOnly()

Copilot uses AI. Check for mistakes.
}

[Fact]
public async Task ReturnsAsync_3Parameters_ShouldSupportWhenAndFor()
Copy link

Copilot AI Jan 17, 2026

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.

Suggested change
public async Task ReturnsAsync_3Parameters_ShouldSupportWhenAndFor()
public async Task ReturnsAsync_3Parameters_ShouldSupportWhenAndOnly()

Copilot uses AI. Check for mistakes.
}

[Fact]
public async Task ReturnsAsync_4Parameters_ShouldSupportWhenAndFor()
Copy link

Copilot AI Jan 17, 2026

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.

Suggested change
public async Task ReturnsAsync_4Parameters_ShouldSupportWhenAndFor()
public async Task ReturnsAsync_4Parameters_ShouldSupportWhenAndOnly()

Copilot uses AI. Check for mistakes.
}

[Fact]
public async Task ReturnsAsync_NoParameters_ShouldSupportWhenAndFor()
Copy link

Copilot AI Jan 17, 2026

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.

Suggested change
public async Task ReturnsAsync_NoParameters_ShouldSupportWhenAndFor()
public async Task ReturnsAsync_NoParameters_ShouldSupportWhenAndOnly()

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link

@vbreuss vbreuss merged commit 6711f57 into main Jan 17, 2026
12 checks passed
@vbreuss vbreuss deleted the topic/change-returntype-of-returnsasync branch January 17, 2026 16:07
@github-actions
Copy link

This is addressed in release v0.52.0.

@github-actions github-actions bot added the state: released The issue is released label Jan 17, 2026
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 The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent return type of ReturnsAsync

2 participants