5

I applied InternalsVisibleTo to one of my projects in order for its internals to be visible for test projects. However, (this is weird I know) I need to mark a few internal classes so that they won't be visible to the projects which is indicated through InternalsVisibleTo.

Is there any attribute I can apply for this that the compiler is aware of?

Nix
  • 57,072
  • 29
  • 149
  • 198
tugberk
  • 57,477
  • 67
  • 243
  • 335
  • Make the class private instead? – RJ Lohan Jan 21 '13 at 00:23
  • @RJLohan Then, other classes cannot use it. This is the whole point of internal access modifier. – tugberk Jan 21 '13 at 00:24
  • I'm not sure it's possible. The alternative is to move those classes into their own assembly. – Simon Whitehead Jan 21 '13 at 00:26
  • @SimonWhitehead yep I thought about that but I don't really wanna do that either :s – tugberk Jan 21 '13 at 00:30
  • 2
    Since InternalsVisibleTo can only be used at the assembly level, and internal is the only way to make a class public except for other assemblies, I don't think it's possible. Only way is moving those types. Think it over, maybe these types make sense living in a separate assembly. – Androiderson Jan 21 '13 at 01:08
  • @AndersonSilva thanks! I ended up separating the test projects so that I won't reference both projects as I was getting compile errors. – tugberk Jan 21 '13 at 01:20

1 Answers1

5

Anderson Silva is correct. There is no way to do this. You should consider moving the types to a new assembly. Alternatively, you could think about applying the [EditorBrowsable(EditorBrowsableState.Never)] attribute to hide the types from IntelliSense, although if the user knows about them, the code will compile.

Kevin Pilch
  • 11,485
  • 1
  • 39
  • 41