Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / DevOps / testing

Exposing internal members to other projects

4.86/5 (7 votes)
26 Jan 2011CPOL 19.2K  
Exposing internal members to other projects
Sometimes, it is needed to expose some attribute of a class that is internal or sometimes it is needed to expose an internal class. Basically, it is needed to carry out Unit testing as generally we have unit test code residing in another project.

We can expose an internal class or any internal attribute of a class by using the following attribute:
[assembly: InternalsVisibleTo("AssemblyNameOfTheProjectToWhichTheInternalOfThisClassWillBeVisible, PublicKey= 0000public key of assembly(optional)000")]
public class MyInternalWillBeExposedToSpecificOutsideProject
{
    internal void SomeMethod()
    { 
       .....
       .....
    }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)