Declaring InternalsVisibleTo in the csproj
While I prefer testing the public API of an assembly, it’s sometimes useful to test the implementation details.
Starting with .NET 5, you can use the
1
2
3
4
5
6
7
8
9
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<InternalsVisibleTo Include="$(AssemblyName).Tests" />
</ItemGroup>
</Project>