I would like to make all my public variables variables/methods/classes internal when compiling my Visual Studio project. The source code would not change but when the compiled library is done, it should only have internal access. Is this possible?
I have “InternalsVisibleTo(“ClassLibrary”) ” set inthe Assembly info file for all the projects, however, I would not like to run a replace all on “public ” to “internal “. Does anyone know if there is away around this? So when I compile, build my project, the release project is only allowing internal access.
Thank you and have a nice day,
Joe
I think you have misunderstood the use of the
InternalsVisibleToattribute. It is used to allow code in another assembly to access types and members declared asinternal.Say you have AssemblyA, in which you have
internal class SomeClass. Then you have AssemblyB. The code in AssemblyB cannot useSomeClass, since it isinternalin AssemblyA. You can then, in AssemblyA, useInternalsVisibleToto grant access for AssemblyB to use theinternaltypes and members of AssemblyA.If you simply want to make the code internal to AssemblyA, you will need to declare the types accordingly from the start; there are no shortcuts for that.