To force the linker to include your class into executable (often needed for RTTI) you can just write single line in the unit initialization to do that and there is no need for dummy functions or any external code to “use” the class.
unit uTest; interface type [...] TTest = class(...) ... end; implementation ... begin TTest.ClassName; // That's all you need end.
And you really do not need to define in each such unit a dumb empty procedure with a parameter and then call it as it’s done in some other sources. And do not say that calling ClassName on a class takes a lot of time and it’s not optimal! It takes only 63 ms for 1’000’000 calls and it will be never bottleneck of your app. Trust me. You will never have million classes… even close to that! If you have then it’s not a problem of ClassName call – it’s probably an architecture problem…
By the way: “TTest.ClassInfo;” will not work as it’s inline.
ClassParent will also work, since it is not inline.
LikeLike
Yes, it’s matter of taste 🙂
LikeLike