You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/LibrarySplit/MigrationGuideForSplit.md
+48-1Lines changed: 48 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -94,4 +94,51 @@ using BarResource1 = BarPackage::Namespace.Resource1;
94
94
95
95
varresourceFromFoo=newResource1(); // From Foo v1.0.0
96
96
varresourceFromBar=newBarResource1(); // From Bar v1.0.0
97
-
```
97
+
```
98
+
99
+
## Changes Required in Mocking
100
+
101
+
When migrating to the split libraries, only the mocking of **extension methods** that have moved to the new package is impacted. Mocking of instance methods and extension methods that remain in the original package will continue to work without changes.
102
+
103
+
If you are mocking an extension method that has moved, you will notice that the corresponding method on the original mockable resource (e.g. `MockableFooSubscriptionResource`) is now marked as `Obsolete`. The compiler warning will provide a message pointing to the new method location in the new package.
104
+
105
+
For example, if you were previously mocking an extension method on `SubscriptionResource` that was part of `Foo`, you might have had code like this:
> This method is obsolete. Call Bar.Mocking.MockableBarSubscriptionResource.GetResource1s instead.
124
+
125
+
To fix this, you need to update your mocking code to use the mockable resource from the new package (e.g. `MockableBarSubscriptionResource`). Apart from updating the type name and the namespace, the method signatures remain the same, so no other logic changes are required.
126
+
127
+
Here is an example of how to update your test code:
128
+
129
+
```diff
130
+
- using Foo.Mocking;
131
+
+ using Bar.Mocking;
132
+
133
+
// ...
134
+
135
+
var subscriptionMock = new Mock<SubscriptionResource>();
136
+
- var mockableSubscription = new Mock<MockableFooSubscriptionResource>();
137
+
+ var mockableSubscription = new Mock<MockableBarSubscriptionResource>();
0 commit comments