Related to this question is, how does the generation of the AssemblyInfo work?
I have been putting InternalsVisibleTo
in the file of the first class of an assembly where I realize that it will be useful. It seems more appropriate to be in AssemblyInfo with the other assembly attributes, but I wouldn't want it to be overwritten inadvertently.
So, where should it go?
Assembly-level attributes can appear in any code file; however, by convention they are placed in the AssemblyInfo.cs file. This aids discoverability, as this is where people (or tools) will commonly look when investigating issues.
// AssemblyInfo.cs
[assembly: InternalsVisibleTo("YourProjectTests")]
I have been using InternalsVisibleTo
for many years and placing it in the AssemblyInfo file. I have never known it to be overwritten by tools i.e. Visual Studio (all editions).