You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Private reflection allows you to access private and internal members in other assemblies. Generally, it’s considered to be a bad thing to do, as it ties you to undocumented implementation details which can later break you. Also, it’s not usable in medium trust.
The purpose of this library is not to encourage anyone to use private reflection in situations where you would not have done it anyway. Instead, the purpose is to allow you to do it much more easily if you decide that you need to use it.
Putting it a different way, I’m not telling you to break the law, but I’m telling you how to break the law more efficiently if that’s what you’re into!
The scenario
Assume you are using an assembly that has code like this:
And assume you have an instance foo1 of the public class Foo1 and your evil self tells you that you want to call the private method GetOtherClass() and then get the SomeProp property off that.
Using reflection
Using plain old reflection this would be something like this:
Support for 'out' and 'ref' parameters is not available on .NET Core 1.x runtimes. This is a runtime limitation and results in a PlatformNotSupportedException.
About
Framework to drastically simplify your private reflection code using C# dynamic