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: docs/orleans/grains/grain-versioning/backward-compatibility-guidelines.md
+9-7Lines changed: 9 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Writing backward compatible code can be hard and difficult to test. This article
10
10
11
11
## Never change the signature of existing methods
12
12
13
-
Because of the way on how Orleans serializer work, you should never change the signature
13
+
Because of how the Orleans serializer works, you should never change the signature
14
14
of existing methods.
15
15
16
16
The following example is correct:
@@ -57,7 +57,9 @@ public interface IMyGrain : IGrainWithIntegerKey
57
57
```
58
58
59
59
> [!IMPORTANT]
60
-
> You should not do this change in your code, as it's an example of a bad practice that leads to very bad side-effects. This is an example of what can happen if you just rename the parameter names: let's say that we have the two following interface version deployed in the cluster:
60
+
> Do NOT make this change in your code, as it's an example of a bad practice that leads to very bad side effects.
61
+
62
+
This is an example of what can happen if you just rename the parameter names. Assume you have the following two interface versions deployed in the cluster:
61
63
62
64
```csharp
63
65
[Version(1)]
@@ -72,12 +74,12 @@ public interface IMyGrain : IGrainWithIntegerKey
72
74
[Version(2)]
73
75
publicinterfaceIMyGrain : IGrainWithIntegerKey
74
76
{
75
-
// return a - b
77
+
// return b - a
76
78
Task<int> Subtract(intb, inta);
77
79
}
78
80
```
79
81
80
-
This methods seems identical. But if the client was called with V1, and the request is
82
+
These methods seem identical. But if the client was called with V1, and the request is
81
83
handled by a V2 activation:
82
84
83
85
```csharp
@@ -89,7 +91,7 @@ This is due to how the internal Orleans serializer works.
89
91
90
92
## Avoid changing existing method logic
91
93
92
-
It can seems obvious, but you should be very careful when changing the body of an existing method.
94
+
It can seem obvious, but you should be very careful when changing the body of an existing method.
93
95
Unless you are fixing a bug, it is better to just add a new method if you need to modify the code.
94
96
95
97
Example:
@@ -128,7 +130,7 @@ public interface MyGrain : IMyGrain
128
130
129
131
## Do not remove methods from grain interfaces
130
132
131
-
Unless you are sure that they are no longer used, you should not remove methods from the grain interface.
133
+
Unless you are sure that they're no longer used, you should not remove methods from the grain interface.
132
134
If you want to remove methods, this should be done in 2 steps:
133
135
134
136
1. Deploy V2 grains, with V1 method marked as `Obsolete`
@@ -155,7 +157,7 @@ If you want to remove methods, this should be done in 2 steps:
0 commit comments