Question: Can ImmutableAttribute be used on return values?
- Dominant language
- C#
- Stars
- 10.9k
- Forks
- 2.1k
- Avg merge
- 15h 1m
- Merged PRs (30d)
- 345
Description
The [documentation](https://learn.microsoft.com/en-us/dotnet/orleans/host/configuration-guide/serialization-immutability) states that "method signatures can include `ImmutableAttribute` on a per-parameter basis." But what about return values?
``` csharp
public interface ISummerGrain : IGrain
{
// `values` will not be copied. But what about the return value?
[return: Immutable]
ValueTask> Sum([Immutable] List values);
}
```
Note also that the [documentation](https://learn.microsoft.com/en-us/dotnet/api/orleans.concurrency.immutableattribute?view=orleans-3.0&viewFallbackFrom=orleans-7.0) for `ImmutableAttribute` is only available for v3.6.0. There is nothing available for v7.x.
After downloading the NuGet package, I was able to see that `ImmutableAttribute` is has the `ReturnValue` attribute target, meaning that the above is syntactically valid. But I'd like to confirm that the Orleans runtime actually recognizes and respects `ImmutableAttribute` applied to a grain method return value. If so, it would also be great if the documentation were to state that explicitly.
Contributor guide
Assessment
This issue has not been assessed yet.