Reflection is a tremendously powerful concept in .NET, which every C# developer, sooner or later, ends up working with. It is very useful for a lot of perfectly honest scenarios such as for example assembly scanning, type discovery or all kinds of application composability features.
However, it can also be used to circumvent the public API surface of the dependencies you consume – to modify them or gain access to things that the author of your dependency didn’t exactly envision. That said, this process of “hacking around” is very typical for C# development world and, albeit somewhat risky, it sometimes might be the only way out of a coding jam you are in.
Things start to get interesting if you are forced to implement a non-public (for example internal) interface. At that point, the “basic” reflection can’t help anymore, so let’s have a look at how we can do it.