Skip to content

Commit

Permalink
Use Activator.CreateInstance in CosmosGrainStorage when record does n…
Browse files Browse the repository at this point in the history
…ot exist (#9277)

Use Activator.CreateInstance in CosmosGrainStorage to support types with primary constructors
  • Loading branch information
egil authored Jan 4, 2025
1 parent 4777dae commit 59e1608
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Azure/Orleans.Persistence.Cosmos/CosmosGrainStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public async Task ReadStateAsync<T>(string grainType, GrainId grainId, IGrainSta
}
else
{
grainState.State = ActivatorUtilities.CreateInstance<T>(_serviceProvider);
grainState.State = Activator.CreateInstance<T>();
grainState.RecordExists = false;
}

Expand All @@ -86,7 +86,7 @@ public async Task ReadStateAsync<T>(string grainType, GrainId grainId, IGrainSta
if (dce.StatusCode == HttpStatusCode.NotFound)
{
// State is new, just activate a default and return
grainState.State = ActivatorUtilities.CreateInstance<T>(_serviceProvider);
grainState.State = Activator.CreateInstance<T>();
grainState.RecordExists = false;
return;
}
Expand Down

0 comments on commit 59e1608

Please sign in to comment.