Open Bouke opened 1 month ago
After adding PrivateAssets="all"
to the package reference, the repro is fixed: <PackageReference Include="PolySharp" Version="1.14.1" PrivateAssets="all" />
.
However that didn't solve the problem, but was in fact a result of me trying to produce a minimal repro. After adding net48
to the test project and adding PolySharp as a dependency, the problem re-appears:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net48;net8.0</TargetFrameworks>
<RootNamespace>Logging.Test</RootNamespace>
<LangVersion>12</LangVersion>
<PackageId>Library.Test</PackageId>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Library\Library.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="PolySharp" Version="1.14.1" PrivateAssets="all" />
</ItemGroup>
</Project>
This build error could then be fixed by adding a condition on the package reference: <PackageReference Include="PolySharp" Version="1.14.1" PrivateAssets="all" Condition="$(TargetFramework) != 'net8.0'" />
.
Removing the multi-targetting, but keeping PolySharp as a dependency, the error can be reproduced like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Logging.Test</RootNamespace>
<LangVersion>12</LangVersion>
<PackageId>Library.Test</PackageId>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Library\Library.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="PolySharp" Version="1.14.1" PrivateAssets="all" />
</ItemGroup>
</Project>
Is this something PolySharp would be able to support: consuming a library targeting netstandard2.0
which uses PolySharp, and then a project itself targeting net8.0
also using PolySharp?
Description (optional)
Using PolySharp in a
netstandard2.0
project that usesInternalsVisibleToAttribute
to expose internals to anothernet80
project, will cause that other project to fail to compile. This is because the types generated by PolySharp have internal visibility and collide with the typesnet80
provides.Reproduction Steps
I have a library project that targets
netstandard2.0
and I need to consume it from bothnet48
andnet80
targets:There are classes internal to the library that the test project needs to know about:
There is a test project that multi-target
net48
andnet80
. For simplicity we'll ignore the multi-targeting and only look at thenet80
consumer:Expected Behavior
Compiles.
Actual Behavior
System info
This section should contain useful info such as:
Additional context (optional)
N/A