Serializer (for PersistentState) does not use AliasAttribute on State type
- Dominant language
- C#
- Stars
- 10.9k
- Forks
- 2.1k
- Avg merge
- 14h 42m
- Merged PRs (30d)
- 354
Description
(Orleans version: 7.1.1)
Maybe my understanding of this topic is incorrect, but i believe this behaviour is not good:
I want to give my state types an alias (as suggested in the docs) so that those types can be refactored/renamed without breaking existing persisted grain states.
Example:
```csharp
public class TestGrain : Grain, ITestGrain
{
private IPersistentState GrainState { get; }
public TestGrain([PersistentState("TestGrainState", "defaultStore")] IPersistentState grainState)
{
GrainState = grainState;
}
public async Task Init()
{
this.GrainState.State = new TestState
{
SomeField = "something",
SomeOtherField = "something else"
};
await this.GrainState.WriteStateAsync();
}
}
```
```csharp
[Alias("myalias")]
[GenerateSerializer]
public class TestState
{
[Id(0)]
public string SomeField { get; set; }
[Id(1)]
public string SomeOtherField { get; set; }
}
```
however, the full type names are serialized to storage, and (de)serialization breaks if those are renamed:
```json
{"$id":"1","$type":"WebApplication1.TestState, WebApplication1","SomeField":"something","SomeOtherField":"something else"}
```
Is this a bug or is there a better way to make serialization refactoring-safe?
Contributor guide
Assessment
This issue has not been assessed yet.