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)?
views:
91answers:
4Would it theoretically be possible to manipulate a .NET assembly so that everything becomes public?
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.
If the assembly has a strong name, then you won't be able to substitute your modified assembly for the original.
Proof by example: When you are using a debugger, you can see the private members of objects, including those imported from other assemblies.