[WIP] Add support for wrapping concrete instances in Mockolate#226
[WIP] Add support for wrapping concrete instances in Mockolate#226
Conversation
Co-authored-by: vbreuss <[email protected]>
|
@copilot retry |
- Added WrappedInstance property to MockRegistration - Implemented InvokeWrappedMethod to delegate calls to wrapped instance via reflection - Added Mock.Wrap<T> methods in source generator - Added GenerateWrapped partial method generation - Wrapping is currently supported for interfaces and delegates - Classes with constructors throw helpful error message Co-authored-by: vbreuss <[email protected]>
- Added constructor to generated MockFor classes that accepts MockRegistration - Updated GenerateWrapped to use new constructor for interfaces - Added comprehensive tests for wrap functionality - 2 out of 5 wrap tests passing (setup and verification work) - Delegation to wrapped instance needs debugging (3 tests failing) Co-authored-by: vbreuss <[email protected]>
I've continued the implementation of Mock.Wrap functionality. Here's the current status: Completed:
Test Results:
Next Steps: |
Test Results 5 files - 9 5 suites - 9 41s ⏱️ - 2m 41s For more details on these failures, see this check. Results for commit f645a4d. ± Comparison against base commit f4b9357. This pull request removes 4 and adds 5 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
|
@copilot: Please rebase this PR onto |
I've successfully rebased the PR onto Changes Made:
The branch is rebased locally (commits: a61ab22, 6658ffc, 1691330, 04d6f5f, 1262bff on top of main@69355bd). However, I cannot force-push due to authentication restrictions. To complete the force-push: Or I can create a fresh commit that will automatically push if you'd prefer that approach. |
|
Made obsolete by #293 |
Implementation Plan: Support Wrapping a Concrete Instance
WrappedInstanceproperty toMockRegistrationto store wrapped instancesMock.Wrap<T>method in Sources.cs that generates static method for wrappingCurrent Implementation Status
Completed:
WrappedInstanceproperty toMockRegistrationto store the wrapped instanceInvokeWrappedMethodto delegate calls to wrapped instance via reflectionMock.Wrap<T>(T instance)andMock.Wrap<T>(T instance, MockBehavior mockBehavior)static methodsGenerateWrappedpartial method in source generatorMockRegistrationMatchtoItfollowing main branch refactoringKnown Limitations:
Test Results:
Architecture Notes:
For interfaces, a new constructor accepting
MockRegistrationwas added to generated MockFor classesThe wrapped instance is stored in
MockRegistrationand accessed during method/property invocationWhen no setup exists for a method,
InvokeWrappedMethoduses reflection to call the wrapped instanceSuppressed IL2075 trimming warnings for dynamic method invocation on wrapped instances
Updated to use
IInteractiveMethodSetupfollowing main branch API changesFixes Support wrapping a concrete instance #181
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.