C# - InternalsVisibleTo

By , 7/12/2015
(0 ratings)
Especially with the building of unit tests, it is often necessary to access private or internal types (classes, structs, enums, Interfaces). From the view of C# is it neither possible nor planned.

But it is possible with the InternalsVisibleTo Attribute. It makes all types as good as public for the specified Assembly.
Translate to VB
//if TestAssembly is not signated:
[assembly: InternalsVisibleTo("TestAssembly")]

//if TestAssembly is signated:
//TODO: replace MYPUBLICKEY with the public key of the certificate
[assembly: InternalsVisibleTo("TestOtherAssembly, PublicKey=MYPUBLICKEY")]

Comments

 

Log in, to comment!