I don’t know much about the CIL, except that there is metadata in assemblies that record the type information.
Would it be possible to create some reflecting tool that is able to read a C# or VB.NET assembly and change its metadata so that all class members become public?
Would it be straightforward (e.g. change one or two bytes for each method in CIL)?
I don’t know much about the CIL, except that there is metadata in assemblies
Share
Yes, it is possible, but it is not always safe. There is code out there in the wild that uses the Reflection API to find types, methods, fields, etc. If the code explicitly looks for non-public ones, making them public will break the code. Similarly, if the code looks for the public ones and expects that the non-public ones are not included, once again making those public will break the code.
The best tool to do this that I know of is Mono.Cecil, which is an open-source library that can read, manipulate, and write .NET assemblies.