Sergio0694 / PolySharp

PolySharp provides generated, source-only polyfills for C# language features, to easily use all runtime-agnostic features downlevel. Add a reference, set your C# version to latest and have fun! 🚀

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Requires last .NET and VS. What is the sense?

arteny opened this issue · comments

commented

It doesn't work on my environment with VS 2019 (last version) and .NET 4.8
error : The PolySharp source generators have been disabled on the current configuration, as they need Roslyn 4.3 in order to work. PolySharp requires the source generators to run in order to process shaders, so the library cannot be used without a more up to date IDE (eg. VS 2022 17.3 or greater) or .NET SDK version (.NET 6.0.400 SDK or greater).
========== Build: 0 succeeded, 1 failed ==========

If I use VS2022 and .NET 7 I can use all features without this package, so what the sense of using this package if it doesn't work for lower .NET/VS?

You need to have a recent SDK, it doesn't mean you need to target a recent TFM 🙂

Like the docs and that message say, you need at least the .NET 6.0.400 SDK (ie. either VS 2022 17.3+ or a recent version of Rider if you're using an IDE), but then you can very well still target eg. .NET Framework or some other older TFM if you want. The issue is just you having the build tools to run the generators from PolySharp, not about what framework you use at runtime.

commented

Ok, I'll try to install laterst SDK, thanks.

commented

Installed latest .NET 7 SDK, restarted VS, rebuilded project, exactly same error is shown.

What version of VS are you using? You need at least VS 2022 17.3.
Just installing the .NET SDK on its own isn't enough. That only works when building from terminal.

A colleague is getting the same error using Rider 2023.3.3 for .NET Framework 4.8 project. The project builds fine for me and in CI/CD. Do you have any pointers on how to investigate further or fix the issue please?

He has the following installed:

.NET Framework Version: 4.8.1 and .NET 2.1.102, 2.1.200, 2.1.201, 2.1.202, 2.1.403, 2.1.526, 2.1.700, 2.1.701, 3.1.426, 5.0.104, 5.0.214, 5.0.303, 5.0.404, 5.0.408, 6.0.126, 6.0.418, 8.0.101.

JetBrains Rider 2023.3.3
Build #RD-233.14015.60, built on January 18, 2024
Runtime version: 17.0.9+7-b1087.11 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10.0
.NET Core v7.0.10 x64 (Server GC)

Visual Studio 2017, 2019 and 2022 (17.8.5) on my machine.

We finally realised what the issues was! The wrong MSBuild version was selected in the the Rider settings. Updated this to use the version shipped with Rider and it works!

image

This is still a solid issue for me.
I'm unable to use latest VS nor Rider. Our team is bound to VS Extension, which is shipped for VS 2017 only (with some support for 2019). Extension author does not plan any upgrades nor fixes in any future.

While we can build the project in VS 2022 or Rider and run it, once we need to use the extension to create special proprieritary winforms (SAP b1) - we are unable to as project does not build and extension does not run.
This blocks us from using Polysharp.

P.S. Is there a way to tell VS 2019 to use globally installed dotnet (.NET 8 is installed)?

UPD: Well, we did manage to enable and use LangVersion 9, however without missing BCL it is not much difference from 7.3. At least we now have basics of nullable context! (Without nullable annotation attributes such as NotNullWhen and so on, miss them so much...)