-
Notifications
You must be signed in to change notification settings - Fork 4
Gendarme.Rules.Serialization.MissingSerializationConstructorRule(git)
Sebastien Pouliot edited this page Mar 2, 2011
·
1 revision
Assembly: Gendarme.Rules.Serialization
Version: git
This rule checks for types that implement System.ISerializable but don't provide a serialization constructor. The constructor is required in order to make the type serializeable but cannot be enforced by the interface. The serialization constructor should be private for sealed types and protected for unsealed types.
Bad example:
[Serializable]
public class Bad : ISerializable {
public void GetObjectData (SerializationInfo info, StreamingContext context)
{
}
}
Good example (sealed):
[Serializable]
public sealed class Good : ISerializable {
private ClassWithConstructor (SerializationInfo info, StreamingContext context)
{
}
public void GetObjectData (SerializationInfo info, StreamingContext context)
{
}
}
Good example:
[Serializable]
public class Good : ISerializable {
protected ClassWithConstructor (SerializationInfo info, StreamingContext context)
{
}
public void GetObjectData (SerializationInfo info, StreamingContext context)
{
}
}
- This rule is available since Gendarme 2.0
You can browse the latest source code of this rule on github.com
Note that this page was autogenerated (3/17/2011 1:55:44 PM) based on the xmldoc
comments inside the rules source code and cannot be edited from this wiki.
Please report any documentation errors, typos or suggestions to the
Gendarme Mailing List. Thanks!