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! 🚀
MIT License
1.81k stars 48 forks source link

Show case of PolySharp benefits? #105

Open apm1grb opened 3 months ago

apm1grb commented 3 months ago

It would be beneficial to have some examples of how using PolySharp helps. I'm keen to provide a presentation for my colleagues that underlines the pros of PolySharp. A demo code base - one project without PolySharp (and with errors) and one with PolySharp (and without errors) - would be helpful. Also, some words about typical alternatives might be helpful to advertise the adoption of PolySharp.

In my case, I mentioned spontaneously the helpful polyfill for record types and immediately got the feedback from the team: It makes no difference whether we add a reference to PolySharp or provide a class IsExternalInit. Okay, my fault for not having the best sample, but also other samples on various internet resources underline benefits of PolySharp, that are not really benefits of PolySharp, instead they come with Latest.

TrubbleAC commented 2 months ago

Not exactly a comparison but you might be able to get some use out of PolySharp.Playground - it at least highlights what features are explicitly supported by PolySharp with code samples for each feature. It breaks things out by version, as well as whether or not the feature uses a polyfill or is compiler-only.

Sergio0694 commented 2 months ago

"It makes no difference whether we add a reference to PolySharp or provide a class IsExternalInit."

I mean, they're not wrong, but they're also missing the whole point of PolySharp: which is precisely to avoid having to do that for every feature you care about. You just use the package, and then you can just forget about it and use features normally.

Also worth noting:

This project literally exists because I was tired of copying yet another polyfill type in the Microsoft Store repo 😆

rabejens commented 2 days ago

My key point is: I have to use .net Standard 2.0 for some libraries because we have some legacy stuff that still needs the old .net Framework. With PolySharp, I can just set the language version to 12 and use most of the new C# features anyway and don't have to remember whether I can use a newer feature or not.