On this page.... RSS 2.0 | Atom 1.0 | CDF
# Tuesday, April 18, 2006

I just ran across a new feature of .NET 2.0 that's pretty nifty if you've ever had a need for it.  They have a new attribute, InternalsVisibleToAttribute, that allows you to tell an assembly who its friends are.  This feature, as you might imagine, is dubbed friend assemblies, and it means what it sounds like--friend assemblies can access internal code in the assembly that the attribute is applied to.  This is particularly useful in two scenarios I've run into:

1) You want to easily unit test internals.  Yes, there is some disagreement as to whether that's the right way to test things, but at least you can do it if you need to (and in my experience, you occasionally do).

2) You've neatly packaged code in separate assemblies that are related and need internal access but make sense to be packaged separately.

It seems like kind of a hack, but I think it is a nice one.

Tuesday, April 18, 2006 10:25:35 PM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [0]  | 
Comments are closed.

The opinions expressed herein are solely my own personal opinions, founded or unfounded, rational or not, and you can quote me on that.

Thanks to the good folks at dasBlog!

Copyright © 2019 J. Ambrose Little