An MSBuild task that modifies existing assemblies to add InternalsVisibleTo attributes, remove sealed modifiers, or add virtual keywords.
Add the NuGet package to your project:
<PackageReference Include="AssemblyPatcher">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>Add an InternalsVisibleTo attribute to SomeAssembly with OwnAssembly as the assembly name:
<ItemGroup>
<AddInternalsVisibleTo Include="SomeAssembly" AssemblyName="OwnAssembly" />
</ItemGroup>Remove sealed modifiers from types in SomeAssembly:
<ItemGroup>
<RemoveSealedFrom Include="SomeAssembly" />
<!-- or filtered -->
<RemoveSealedFrom Include="SomeAssembly" TypeNames="SomeAssembly.TypeA;SomeAssembly.Folder.*" />
</ItemGroup>Add virtual keywords in SomeAssembly:
<ItemGroup>
<AddVirtualTo Include="SomeAssembly" />
<!-- or filtered -->
<AddVirtualTo Include="SomeAssembly" MemberNames="SomeAssembly.TypeA;SomeAssembly.Types::Member*" />
</ItemGroup>MIT