After loading mscorlib. dll with Reflector, we can see that the Finalize method in the System. Object Class is modified with override.
The Object is the root class and it is obviously impossible to rewrite other methods. Here the results generated by the decompilation tool are incorrect. Let's verify this:
Everyone knows that in order to reduce the burden on developers, C # provides a special syntax for the Finalize method definition. This syntax is used to define the Finalize method, the compiler can automatically generate appropriate exception handling code and call the Finalize method of the base class!
The source code of the Finalize method of the Object class is as follows:
~ Object ()
{
}
We can see that this method has nothing to do!
We use the ILDasm tool to view the IL code:
. Method family hidebysig virtual instance void
Finalize () cel managed
{
. Custom instance void System. Runtime. ConstrainedExecution. ReliabilityContractAttribute:. ctor (valuetype System. Runtime. ConstrainedExecution. Consistency,
Valuetype System. Runtime. ConstrainedExecution. Cer) = (01 00 03 00 00 02 00 00 00 00 00)
// Code size 1 (0x1)
. Maxstack 8
IL_0000: ret
} // End of method Object: Finalize
This is actually a Virtual method, not an override method.
In general classes (if needed), this method is rewritten to add the terminator implementation.
Reflector may not parse the Object class correctly. Therefore, the decompilation result of Reflector is incorrect here, which is not another override method.
Please kindly advise!