-
Notifications
You must be signed in to change notification settings - Fork 4
Gendarme.Rules.Correctness.FinalizersShouldCallBaseClassFinalizerRule(2.10)
Sebastien Pouliot edited this page Jan 22, 2011
·
2 revisions
Assembly: Gendarme.Rules.Correctness
Version: 2.10
This rule is used to warn the developer that a finalizer does not call the base class finalizer. In C#, this is enforced by compiler but some .NET languages (like IL) may allow such behavior.
Bad example (IL):
.assembly extern mscorlib
{
.ver 1:0:5000:0
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
}
.class public auto ansi beforefieldinit BadFinalizer extends [mscorlib]System.Object
{
.method family virtual hidebysig instance void Finalize() cil managed
{
// no base call so rule will fire here
}
}
Good example (C#):
public class GoodFinalizer {
~GoodFinalizer ()
{
// C# compiler will insert base.Finalize () call here
// so any compiler-generated code will be valid
}
}
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!