Does merging assemblies change the scope of the internal keyword?
I'm fairly certain that it wouldn't have an effect (or at least one that would matter) since anyone referencing the final assembly wouldn't be able to access internal classes anyway.
This might be a hypothetical question with no real world value, but I was curious nontheless.
Edit: I do mean with ILMerge, not combining source code into a single buildable assembly.
Yes once the assemblies are merged, they get access to each others internal classes. This is specifically leveraged by some obfuscators to make public calls between assemblies into internal calls and then obfuscate them making it more secure. Reference: SmartAssembly
On a side note, using ILMerge, you can use the /internalize command line switch which will make all public classes in assemblies other than the primary assembly internal, which removes public interfaces from the end-user's eye but still the assemblies function normally.
Assuming you are not running with full-trust , any types that were merged into the final assembly with the internal types would now be able to access the public members of the internal types.
So given assembly A:
public class MyClassA { ... }
and assembly B:
internal class MyClassB { ... }
MyClassA may not have permission to reflect the public members of MyClassB. If they were merged into the same assembly, then MyClassA may gain such a permission.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With