[InternalsVisibleTo("Microsoft.Build.Engine.Unittest")]
I was spelunking the .NET framework 2.0 and noticed the following assembly attribute on 'Microsoft.Build.Engine'.
[assembly: InternalsVisibleTo("Microsoft.Build.Engine.Unittest")]
I knew this feature was planned, but I didn't realise it was live in the .NET 2.0 beta 1 bits. I tried creating a project 'Library' with the attribute [assembly: InternalsVisibleTo("Library.Tests")], then added the project 'Library.Tests' with a reference to 'Library'. Low and behold my 'Library' project's internal types and members start showing up using intellisense in 'Library.Tests'.
I then wondered if I could create a project called 'Microsoft.Build.Engine.Unittest' and have the internals of 'Microsoft.Build.Engine' show up. I tried this but was initially discouraged when they didn't show up with intellisense. It does however work if you add the code manually. As a proof of concept, create a project called 'Microsoft.Build.BuildEngine.Unittest' and add the following code.
using Microsoft.Build.BuildEngine;
class Spelunking
{
string[] spelunk() { return Utilities.SplitSemiColonSeparatedList("split;me"); }
}
Right click inside the method and 'Run Test(s)' (assuming you're using NUnitAddIn). In the output window you should see.
------ Test started: Assembly: Microsoft.Build.Engine.Unittest.dll ------
[0]: split
[1]: me
1 succeeded, 0 failed, 0 skipped, took 0.30 seconds.
I've searched all assemblies in .NET 2.0 beta 1 for any that use 'InternalsVisibleTo' and came up with the following list. The first one is interesting because 'MSBuild' is an EXE assembly. It turns out we can finally add EXE assemblies as project references without hacking the .csproj file. =o)
MSBuild
[assembly: InternalsVisibleTo("MSBuild.Unittest")]
Microsoft.Build.VisualJSharp
[assembly: InternalsVisibleTo("Microsoft.Build.VisualJSharp_UT")]
Microsoft.Build.Utilities
[assembly: InternalsVisibleTo("Microsoft.Build.Utilities.Unittest")]
Microsoft.Build.Tasks
[assembly: InternalsVisibleTo("Microsoft.Build.Tasks.Unittest")]
Microsoft.Build.Engine
[assembly: InternalsVisibleTo("Microsoft.Build.Engine.Unittest")]
Microsoft.Build.Conversion
[assembly: InternalsVisibleTo("Microsoft.Build.Conversion.Unittest")]
System.Web.RegularExpressions
[assembly: InternalsVisibleTo("System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
System.Data
[assembly: InternalsVisibleTo("UdtExtensions, Version=9.0.242.0, PublicKeyToken=89845dcd8080cc91")]