Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are There Any Non-UnitTesting Scenarios Where InternalsVisibleTo is Acceptable

It seems like using this attribute for anything other than unit testing of non-public methods/properties would be a huge code smell. Are there any legitimate uses of the InternalsVisibleTo attribute to achieve something that might be otherwise impossible/too cumbersome using standard design patterns?

like image 958
Joel B Avatar asked Dec 26 '22 21:12

Joel B


2 Answers

We used it in building the Microsoft Surface SDK so that certain platform assemblies could talk to each other without opening up unwanted public APIs. Though this did create a burden of having manually ensure that these libs were only using "approved" internal things from each other.

like image 166
Robert Levy Avatar answered Dec 31 '22 16:12

Robert Levy


Could be used to share code between your own assemblies that you do not want to publicly expose to the outside.

like image 24
Darin Dimitrov Avatar answered Dec 31 '22 15:12

Darin Dimitrov