akkadotnet / akka.net

Canonical actor model implementation for .NET with local + distributed actors in C# and F#.
http://getakka.net
Other
4.67k stars 1.04k forks source link

Enforce Immutable Message Roslyn Enhancement #3376

Open nathvi opened 6 years ago

nathvi commented 6 years ago

I know that right now messages are only kept immutable by convention and are not enforced by the compiler. I'm thinking that it would be a cool project to work on an extension where you tag a class with a AkkaMessage Attribute and the extension could automatically throw an error if it wasn't completely immutable, and give a code fix to make it immutable.

Aaronontheweb commented 6 years ago

Wouldn't even need to tag a class - just seeing that this class has been passed through a Tell call would be enough to flag it as having to be immutable.

nathvi commented 6 years ago

Perhaps seeing that a class has been passed through Tell could mark the class with an AkkaMessage attribute and refactor all mutable properties as immutable as part of the code fix. This way if that class isn't currently being called with Tell, the developer still knows that it should be marked to enforce the immutable nature.

Horusiath commented 6 years ago

I think, that having some sort of [Immutable] attribute in core Akka repo would be useful in longer run. Even just to make that intent explicit.