I have extension method
public static T DeepClone<T>(this T source) where T : ISerializable
{
..
}
When I added "where T : ISerializable" I get error on all classes that uses DeepClone() having [Serializable] attribute.
- What is the problem?
EDIT:
- I know that my classes should implement ISerializable to work. But is there any difference in serialized output when using ISerializable vs [Serializable]?
There are two ways you can make a type serializable.
In your case, you only consider the first one.
To solve this, just let the serializer handle error reporting. It will throw error for any object that is not serializable.