This is usually done to circumvent overhead when using reflection, using information available only at run time.
Then you would use reflection, which can be slow depending on what you are doing, to create a new piece of code that works directly with the data provided to it, without using reflection.
Benefits:
Disadvantages:
- Hard to debug
- Hard to get right
- It's hard to read the code after
- Steep learning curve
Therefore, you need to make sure that it is really worth the price before proceeding with this.
Please note that this is a general answer. In the specific case that you are faced with, there is no way to answer the question of why this was done and what specific advantages (or disadvantages) you might have without seeing the code.
source share