-
Notifications
You must be signed in to change notification settings - Fork 4
Gendarme.Rules.Exceptions.MissingExceptionConstructorsRule(git)
Sebastien Pouliot edited this page Mar 2, 2011
·
1 revision
Assembly: Gendarme.Rules.Exceptions
Version: git
This rule will fire if an exception class is missing one or more of the following constructors:
- public E () is required for XML serialization. Public access is required in case the assembly uses CAS to prevent reflection on non-public members.
- public E (string message) is a .NET convention.
- public E (string message, ..., Exception inner) is a .NET convention.
- (non)public E (SerializationInfo info, StreamingContext context) is required for binary serialization.
Bad example:
public class GeneralException : Exception {
// access should be public
private GeneralException ()
{
}
}
Good example:
public class GeneralException : Exception {
public GeneralException ()
{
}
public GeneralException (string message) : base (message)
{
}
public GeneralException (string message, Exception inner) : base (message, inner)
{
}
protected GeneralException (SerializationInfo info, StreamingContext context) : base (info, 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!