Declaring InternalsVisibleTo in the csproj

Declaring InternalsVisibleTo in the csproj

Declaring InternalsVisibleTo in the csproj

  • 0 minute read

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 without adding any NuGet package:

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>