[fpc-devel] .NET Reflection vs RTTI

Flávio Etrusco flavio.etrusco at gmail.com
Tue Nov 20 08:23:50 CET 2007


> (...)
> As far as the information itself that's available through RTTI / Reflection
> is concerned, the type information available in .NET is truly complete, down
> to every field and every method of every type. Also, the ability to
> associate any number of custom attributes with any of the entities that make
> up the type information in .NET is a very powerful tool.
>
> Another huge advantage of Reflection in .NET over RTTI as provided by Delphi
> and FPC is that given an instance of an object and a MethodInfo object
> describing any of the accessible methods of that object it is trivial to
> call that method using MethodInfo.Invoke(Instance, [Array, Of, Parameters]).
> (Access to fields, properties and event is similar easy using the respective
> *Info objects).
>
> The combination of this (truly complete type information, easy access,
> custom attributes) makes it rather trivial to e.g. tag private fields of a
> class with the [Serializable] attribute and use Reflection to serialize the
> class to/from a stream.
>
> Cheers,
> Thorsten
>

You forgot to complete: (...) but 99% of time the it just makes for
useless bloat ;-)

Cheers,
Flávio



More information about the fpc-devel mailing list