Skip to content

Instantly share code, notes, and snippets.

@lanwin
Created November 24, 2012 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lanwin/4138801 to your computer and use it in GitHub Desktop.
Save lanwin/4138801 to your computer and use it in GitHub Desktop.
Immutable type checking for Simon
class Mutable {
}
[Immutable]
public class ImmutableB
{
public readonly A = new ImmutableA();
}
[Immutable]
public class ImmutableA
{
public readonly M = new Mutable(); // here should the build stop and tell you that you can not use mutable types inside of immutable types.
}
// Immutable are all types with Immutable attribute + a whitelist of framework types or types from other assemblies.
@lanwin
Copy link
Author

lanwin commented Nov 24, 2012

The detection also need to go far beyond. Like:

  • No public fields
  • No setts
  • No method should change the internal state after construction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment