How is ImmutableObjectAttribute used?

Posted by Thomas Levesque on Stack Overflow See other posts from Stack Overflow or by Thomas Levesque
Published on 2009-11-06T23:34:57Z Indexed on 2010/05/31 4:42 UTC
Read the original article Hit count: 333

Filed under:
|

I was looking for a built-in attribute to specify that a type is immutable, and I found only System.ComponentModel.ImmutableObjectAttribute.

Using Reflector, I checked where it was used, and it seems that the only public class that uses it is System.Drawing.Image... WTF? It could have been used on string, int or any of the primitive types, but Image is definitely not immutable, there are plenty of ways to alter its internal state (using a Graphics or the Bitmap.SetPixel method for instance).

So the only class in the BCL that is explicitly declared as immutable, is mutable! Or am I missing something?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about immutability