refactor!: do not generate recursive mocks for methods or properties#348
refactor!: do not generate recursive mocks for methods or properties#348
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes the automatic recursive mock generation feature for interface properties and methods. Instead of generating mocks for all interface return types encountered in properties and methods, the generator now only creates mocks for explicitly requested types (with a special exception for HttpClient/HttpMessageHandler).
Key changes:
- Removed recursive traversal of property and method return types when discovering mockable types
- Updated test expectations to verify that recursive mocks are no longer generated
- Optimized the
processedTypesHashSet initialization by seeding it with initial types
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Tests/Mockolate.SourceGenerators.Tests/GeneralTests.cs | Updated test name and assertions to verify recursive mock generation no longer occurs |
| Source/Mockolate.SourceGenerators/MockGeneratorHelpers.cs | Removed property and method return type traversal logic; retained special HttpClient handling |
Test Results 14 files ±0 14 suites ±0 5m 36s ⏱️ +14s Results for commit 55df2d4. ± Comparison against base commit ed2a173. This pull request removes 2 and adds 2 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
🚀 Benchmark ResultsDetails
|
|
|
This is addressed in release v0.49.0. |



This PR removes the automatic recursive mock generation feature for interface properties and methods. Instead of generating mocks for all interface return types encountered in properties and methods, the generator now only creates mocks for explicitly requested types (with a special exception for HttpClient/HttpMessageHandler).
Key changes
processedTypesHashSet initialization by seeding it with initial types