Skip to content

Comments

feat: make HttpContent parameter optional#454

Merged
vbreuss merged 4 commits intomainfrom
topic/make-httpcontent-parameter-optional
Feb 1, 2026
Merged

feat: make HttpContent parameter optional#454
vbreuss merged 4 commits intomainfrom
topic/make-httpcontent-parameter-optional

Conversation

@vbreuss
Copy link
Contributor

@vbreuss vbreuss commented Feb 1, 2026

This PR enhances the HttpClient mocking API by making the HttpContent parameter optional in setup and verification methods for POST, PUT, and PATCH operations. It also removes nullability from non-optional parameters across HTTP methods to improve type safety.

Key Changes:

  • Made content parameter optional with default value null for POST/PUT/PATCH operations
  • Removed nullability (?) from requestUri and content parameters in overloads that accept CancellationToken
  • Updated internal parameter handling to use null-coalescing operator with It.IsAny<T>() for optional parameters
  • Added tests to verify HttpContent parameter matching behavior

@vbreuss vbreuss self-assigned this Feb 1, 2026
@vbreuss vbreuss added the enhancement New feature or request label Feb 1, 2026
Copilot AI review requested due to automatic review settings February 1, 2026 09:44
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 enhances the HttpClient mocking API by making the HttpContent parameter optional in setup and verification methods for POST, PUT, and PATCH operations. It also removes nullability from non-optional parameters across HTTP methods to improve type safety.

Changes:

  • Made content parameter optional with default value null for POST/PUT/PATCH operations
  • Removed nullability (?) from requestUri and content parameters in overloads that accept CancellationToken
  • Updated internal parameter handling to use null-coalescing operator with It.IsAny<T>() for optional parameters
  • Added tests to verify HttpContent parameter matching behavior

Reviewed changes

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

Show a summary per file
File Description
Tests/Mockolate.Internal.Tests/WebTests.cs Added tests for HttpContent parameter matching edge cases
Tests/Mockolate.Api.Tests/Expected/Mockolate_*.txt Updated API surface snapshots to reflect the new optional parameter signatures
Source/Mockolate/Web/HttpClientExtensions.cs Simplified internal parameter handling by removing nullable logic
Source/Mockolate/Web/HttpClientExtensions.Setup.*.cs Made content parameter optional and updated parameter nullability in Setup methods
Source/Mockolate/Web/HttpClientExtensions.Verify.*.cs Made content parameter optional and updated parameter nullability in Verify methods

@github-actions
Copy link

github-actions bot commented Feb 1, 2026

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.3 LTS (Noble Numbat)
AMD EPYC 7763 3.07GHz, 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-v3

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

Method Mean Error StdDev Gen0 Gen1 Allocated
Simple_Mockolate 1.522 μs 0.0201 μs 0.0188 μs 0.2270 - 3.73 KB
Simple_Moq 179.077 μs 1.5129 μs 1.2633 μs 0.4883 - 14.55 KB
Simple_NSubstitute 5.686 μs 0.0710 μs 0.0664 μs 0.5493 0.0076 9.09 KB
Simple_FakeItEasy 6.346 μs 0.0696 μs 0.0651 μs 0.4959 - 8.11 KB

Copilot AI review requested due to automatic review settings February 1, 2026 09:51
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 21 out of 21 changed files in this pull request and generated no new comments.

@vbreuss vbreuss force-pushed the topic/make-httpcontent-parameter-optional branch from 16393dc to e4f0e18 Compare February 1, 2026 09:52
Copilot AI review requested due to automatic review settings February 1, 2026 09:52
@vbreuss vbreuss enabled auto-merge (squash) February 1, 2026 09:52
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 21 out of 21 changed files in this pull request and generated no new comments.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 1, 2026

@github-actions
Copy link

github-actions bot commented Feb 1, 2026

Test Results

    21 files  ± 0      21 suites  ±0   6m 34s ⏱️ +43s
 2 516 tests + 3   2 515 ✅ + 3  1 💤 ±0  0 ❌ ±0 
16 877 runs  +21  16 876 ✅ +21  1 💤 ±0  0 ❌ ±0 

Results for commit e4f0e18. ± Comparison against base commit 3e827a0.

@vbreuss vbreuss merged commit bd2c949 into main Feb 1, 2026
12 checks passed
@vbreuss vbreuss deleted the topic/make-httpcontent-parameter-optional branch February 1, 2026 09:57
@github-actions
Copy link

github-actions bot commented Feb 1, 2026

This is addressed in release v1.2.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 The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant