Friend assemblies (or how to make internals visible to other assemblies)

As you know, the internal modifier denotes that types and type members are only accessible by code from the same assembly.

Therefore the DoSomething method in the following is not visible to other assemblies but can be using by code within the assembly which contains this type

public class MyClass
{
   internal int DoSomething()
   {
   }
}

In some cases it’s useful to have internal types or type members visible to other assemblies, but limited to only those assemblies. These assemblies are known as friend assemblies.

To denote the friend assemblies we add the InternalsVisibleTo attribute to the assembly who hosts the internals and specify the friend assembly in the following manner

[assembly: InternalsVisibleTo("FriendAssembly")]

Now the FriendAssembly can access the DoSomething method on type MyClass.