I’ve just purchased a licence for NDepend (note to self: In future respond promptly to emails offering free licences, don’t lose them). Using it to examine one of my personal projects has suggested a number of classes which could potentially be made internal. This would require adding the InternalsVisibleToAttribute to the assembly in order to allow the test assembly to access the classes. This leads to the question: Is this valid behaviour? This is not a question to which I currently have a good answer.
Some general thoughts on the matter:
- Making implementations internal ensures only the interfaces are used which aids in separation of concerns
- Internal implementations aren’t going to show up in Intellisense. I’m not sure this has ever really been a problem for me though, even on larger projects.
- Reaching into the internals of an assembly to test it doesn’t seem to me to be proper test practice. This may be mitigated if it’s only so that the class may be accessed, not to reach deep into its implementation.
As I don’t really have an answer I’m going to try it and see what happens. This is a benefit of personal projects, being wrong isn’t likely to irritate people. If anyone has an opinion on this throw it into the comments.