-
Notifications
You must be signed in to change notification settings - Fork 4
Gendarme.Rules.Design.FinalizersShouldBeProtectedRule(2.10)
Sebastien Pouliot edited this page Jan 22, 2011
·
2 revisions
Assembly: Gendarme.Rules.Design
Version: 2.10
This rule verifies that finalizers are only visible to the type's family (e.g. protected in C#). If they are not family then they can be called from user code which could lead to problems. Note that this restriction is enforced by the C# and VB.NET compilers but other compilers may not do so.
Bad example (IL):
.class family auto ansi beforefieldinit BadPublicFinalizer extends
[mscorlib]System.Object
{
.method public hidebysig instance void Finalize() cil managed
{
// ...
}
}
Good example (C#):
public class GoodProtectedFinalizer {
// compiler makes it protected
~GoodProtectedFinalizer ()
{
}
}
Good example (IL):
.class family auto ansi beforefieldinit GoodProtectedFinalizer extends
[mscorlib]System.Object
{
.method family hidebysig instance void Finalize() cil managed
{
// ...
}
}
Note that this page was autogenerated (3/17/2011 9:31:58 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!