DEV Community

Discussion on: Reflection via source generators

Collapse
 
ergisgjergji profile image
ergisgjergji • Edited

Question: can you explain the reason as to why is it faster? Doesn't your library use Reflection internally?

Collapse
 
timur_kh profile image
Timur Kh • Edited

I believe full-fat reflection is unavailable when source code generators kick in (and this is why generics are such a pain). From a quick glance over the code, the library appears to analyse class structure and generate metadata at compile time.
Then it uses .GetProperties extension to fetch it as if it was reflected upon. But in fact all it does is a dictionary lookup. Hence speed

Collapse
 
ergisgjergji profile image
ergisgjergji

Ah, all right then. Good job and thanks for the sharing :)