How to verify that the descendent class overrides all virtual methods?

Context

In DelphiAST there is a base class: TmwSimplePasParthat parses Delphi code.
In addition, there is a class: TPasSyntaxTreeBuilderthat should override each method in the base class.

Question

Is there a way to verify that the descendent class has overridden every virtual method in the base class?
It would be nice to be able to argue.

TPasSyntaxTreeBuilder.Create;
begin
  Assert(Self.OverridenMethods.Count = (BaseClass.VirtualMethodCount - TObject.VirtualMethodCount)); 
  ....

Please note that I'm talking about all virtual methods, and not just abstract ones (without using abstract methods, it gives a warning).

+4
source share
1 answer

Look at the VMT class slots and compare them again with the base class VMT slots.

Spring4D ( Spring.VirtualClass.pas):

function IsVirtualMethodOverride(baseClass, classType: TClass; method: Pointer): Boolean;

, VMT - .

FWIW: , , .

+7

Source: https://habr.com/ru/post/1686342/


All Articles