Share internal members with another assembly

Published by on
Tags:

I though I would quickly document an assembly attribute that I find incredibly useful. It the InternalVisibleTo attribute:

   38 [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("assembly name")]



This allows the assembly you specified to see all internal types for the current assembly. This is incredibly useful for unit testing. I normally find this works great if my Framework has some sort of contact class. Normally I don’t want developers being able to specify how the context is built but when unit testing I may want to mock it. Using this method I can expose the internal workings of the context for unit testing but know that when it gets deployed the rest of the world will not be able to fiddle with it.

For more info visit:

http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx

Add comment

 

Projects

Have you read?

Repositories and factories - Creating a simple entity.



Blogs by date