-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does PolySharp support multitargeting? #48
Comments
PolySharp already supports this (eg. I'm personally using already in several multi-targeted projects, like you can see here: Sergio0694/ComputeSharp#471). I'm not entirely sure what's going on here. Are you able to provide a minimal repro? |
Maybe this has more to do with multiple projects rather than multiple targets. Is the injected code |
The fact you're only getting the error for a single type is very suspect. As in, it's easy to see that PolySharp does indeed skip types that already exist: if that wasn't the case you'd be getting dozens of errors, not just one for |
@Shane32 it is by default, yes, unless you explicitly set the "PolySharpUsePublicAccessibilityForGeneratedTypes" property. |
@Sergio0694 It may be due to the fact that the test project, where the build is failing, has references to two different projects both of which utilize InternalsVisibleTo back towards the test project... ?? |
Ah, yeah that makes sense. If the test project is, say, targeting .NET 6 (which has the attribute), but is referencing a project on, say, the .NET Standard 2.0 project, that project will have |
Attempting to reproduce now....... |
Anyway if the issue is in a test project this definitely doesn't seem related to PolySharp per se. The library is correctly generating only the polyfills that are needed on each TFM, if then this specific repo has some weird configuration with test projects and Closing this for now, happy to reopen in case more info is provided that links this to an actual issue in PolySharp 🙂 |
FYI, below is a sample. Removing ClassLibrary1<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>11</LangVersion>
</PropertyGroup>
<ItemGroup>
<InternalsVisibleTo Include="ConsoleApp1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="PolySharp" Version="1.10.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project> namespace ClassLibrary1
{
public class Class1
{
}
} ConsoleApp1<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ClassLibrary1\ClassLibrary1.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="PolySharp" Version="1.10.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project> // See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!"); |
I've got the same issue with IsExternalInit, also in a test project that references another project in the same repository. It's likely to prevent the use of PolySharp as a replacement for IsExternalInit and Nullable in Remora.Sdk for the time being - see Remora/Remora.Results#10 for the discussion. |
I recently saw this package and decided to try.
Config:
Output:
If I change reference to
then there are no errors.
I would like PolySharp does not require Conditional attribute on TFMs where all necessary attributes are present.
The text was updated successfully, but these errors were encountered: