Skip to content

fix: support generic type in additional interfaces#475

Merged
vbreuss merged 2 commits into
mainfrom
topic/fix-generic-type-additional-interfaces
Feb 10, 2026
Merged

fix: support generic type in additional interfaces#475
vbreuss merged 2 commits into
mainfrom
topic/fix-generic-type-additional-interfaces

Conversation

@vbreuss

@vbreuss vbreuss commented Feb 10, 2026

Copy link
Copy Markdown
Member

This PR improves support for generic types in generated “additional interfaces” mock extensions and tightens up HTTP content/form-data matching behavior through updated tests and parsing.

Key Changes:

  • Add coverage for matching when a parameter also implements IHttpRequestMessagePropertyParameter<HttpContent?>.
  • Adjust multipart form-data extraction to preserve line endings/whitespace as read.
  • Sanitize generated extension names to handle generic type names (angle brackets).

@vbreuss vbreuss self-assigned this Feb 10, 2026
Copilot AI review requested due to automatic review settings February 10, 2026 18:46
@vbreuss vbreuss added the bug Something isn't working label Feb 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown

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 improves support for generic types in generated “additional interfaces” mock extensions and tightens up HTTP content/form-data matching behavior through updated tests and parsing.

Changes:

  • Add coverage for matching when a parameter also implements IHttpRequestMessagePropertyParameter<HttpContent?>.
  • Adjust multipart form-data extraction to preserve line endings/whitespace as read.
  • Sanitize generated extension names to handle generic type names (angle brackets).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
Tests/Mockolate.Tests/Web/ItExtensionsTests.IsHttpContentTests.WithFormDataTests.cs Adds an additional form-data test case for exact parameter matching.
Tests/Mockolate.Internal.Tests/WebTests.cs Adds test coverage for the “prefer IHttpRequestMessagePropertyParameter<T> match” path.
Source/Mockolate/Web/ItExtensions.HttpContent.WithFormData.cs Changes normalization in multipart form-data extraction (no longer trims line endings).
Source/Mockolate.SourceGenerators/Sources/Sources.ForMock.CombinationExtensions.cs Updates generated name sanitization to account for generic type syntax.

Comment thread Source/Mockolate/Web/ItExtensions.HttpContent.WithFormData.cs
@github-actions

github-actions Bot commented Feb 10, 2026

Copy link
Copy Markdown

Test Results

    21 files  ± 0      21 suites  ±0   5m 16s ⏱️ - 1m 58s
 2 719 tests + 1   2 718 ✅ + 1  1 💤 ±0  0 ❌ ±0 
18 256 runs  +14  18 255 ✅ +14  1 💤 ±0  0 ❌ ±0 

Results for commit ef10589. ± Comparison against base commit c7f0b1b.

This pull request removes 1 and adds 2 tests. Note that renamed tests count towards both.
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithFormDataTests ‑ ShouldEncodeValues(key: "x<>", value: "1<2> 3")
Mockolate.Internal.Tests.WebTests ‑ WhenParameterImplementsIHttpRequestMessagePropertyParameter_ShouldUseThisMatch
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithFormDataTests ‑ ShouldEncodeValues(key: "x<>", value: "1<2> 3 ")

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Feb 10, 2026

Copy link
Copy Markdown

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.3 LTS (Noble Numbat)
AMD EPYC 7763 2.63GHz, 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.672 μs 0.0198 μs 0.0175 μs 0.2270 - 3.73 KB
Simple_Moq 179.936 μs 1.8113 μs 1.6943 μs 0.4883 - 14.55 KB
Simple_NSubstitute 5.880 μs 0.0334 μs 0.0313 μs 0.5569 0.0076 9.14 KB
Simple_FakeItEasy 6.572 μs 0.0773 μs 0.0723 μs 0.4959 - 8.11 KB

@vbreuss vbreuss enabled auto-merge (squash) February 10, 2026 18:58
@sonarqubecloud

sonarqubecloud Bot commented Feb 10, 2026

Copy link
Copy Markdown

@vbreuss vbreuss merged commit 43525b7 into main Feb 10, 2026
12 checks passed
@vbreuss vbreuss deleted the topic/fix-generic-type-additional-interfaces branch February 10, 2026 19:03
@github-actions

Copy link
Copy Markdown

This is addressed in release v1.4.1.

@github-actions github-actions Bot added the state: released The issue is released label Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants