I blogged before about how to use the [InternalsVisibleTo] in your .NET Standard/.NET Core project. Today I discovered an alternative approach where you specify the attribute information in your csproj file:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<TargetFramework>netstandard2.0</TargetFramework> | |
</PropertyGroup> | |
<ItemGroup> | |
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute"> | |
<_Parameter1>ProxyBuilder</_Parameter1> | |
</AssemblyAttribute> | |
</ItemGroup> | |
</Project> |
During compilation of your project an AssemblyInfo.cs file is generated (take a look at your object folder):
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------------------------------ | |
// <auto-generated> | |
// This code was generated by a tool. | |
// Runtime Version:4.0.30319.42000 | |
// | |
// Changes to this file may cause incorrect behavior and will be lost if | |
// the code is regenerated. | |
// </auto-generated> | |
//------------------------------------------------------------------------------ | |
using System; | |
using System.Reflection; | |
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ProxyBuilder")] | |
// Generated by the MSBuild WriteCodeFragment class. | |