InternalsVisibleTo.MSBuild Save

Enables declaring 'InternalsVisibleTo' items in a .NET project file, rather than declaring them to an AssemblyInfo.cs file.

Project README

InternalsVisibleTo.MSBuild

NuGet version

Enables declaring InternalsVisibleTo items in a .NET project file, rather than declaring them in an AssemblyInfo.cs file.

IMPORTANT: starting with .NET 5.0, the SDK already provides support for this. You don't need this package if you're using the .NET 5.0 SDK or later.

How to use

  1. Install the InternalsVisibleTo.MSBuild NuGet package.

  2. Edit your csproj file and add <InternalsVisibleTo> items in your project for each assembly that should have access to the internals of the current project:

      <ItemGroup>
        <InternalsVisibleTo Include="$(AssemblyName).UnitTests" />
        <InternalsVisibleTo Include="SomeOtherAssembly" />
        <InternalsVisibleTo Include="StronglyNamedAssembly, PublicKey=0123....." />
      </ItemGroup>
    

    This will generate the appropriate InternalsVisibleTo attributes for your assembly.

    Alternatively, you can also use <InternalsVisibleToSuffix> to specify that assemblies named $(AssemblyName).<suffix> will have access to the internals of the current project:

      <ItemGroup>
        <!-- $(AssemblyName).UnitTests will have access to the internals of this project -->
        <InternalsVisibleToSuffix Include=".UnitTests" />
      </ItemGroup>
    

Note

In fact, it's already possible to declare InternalsVisibleTo attributes in the project file without this package, but the syntax is ugly and hard to remember:

  <ItemGroup>
    <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
      <_Parameter1>SomeOtherAssembly</_Parameter1>
    </AssemblyAttribute>
  </ItemGroup>

This package just makes things easier by transforming <InternalsVisibleTo> elements into appropriate <AssemblyAttribute> elements.

Open Source Agenda is not affiliated with "InternalsVisibleTo.MSBuild" Project. README Source: thomaslevesque/InternalsVisibleTo.MSBuild
Stars
28
Open Issues
0
Last Commit
2 years ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating