Why is the C# SerializedAttribute is sealed?

Posted by ahmet alp balkan on Stack Overflow See other posts from Stack Overflow or by ahmet alp balkan
Published on 2012-11-09T22:21:05Z Indexed on 2012/11/09 23:00 UTC
Read the original article Hit count: 279

Filed under:

I was trying to create an attribute that implies [Serializable] but I noticed that this SerializableAttribute class is sealed.

In Java it was possible to create an interface (say, MyInterface) that is inherited from Serializable interface and so all the subclasses of MyInterface would also be serializable, even its sub-sub classes would be so.

Let's say I am creating an ORM and I want customers to annotate their entity classes as [DatabaseEntity] but in order to make sure that entities are serializable, I also need to ask them to attribute their classes with extra [Serializable] which does not look quite compact and neat.

I am wondering why SerializableAttribute class is sealed and why has Inherited=false which implies that subclasses of serializable class will not be serializable unless it is explicitly stated. What motives are behind these design choices?

© Stack Overflow or respective owner

Related posts about c#