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.77k stars 46 forks source link

Add C# 12 and .NET 8 polyfills #81

Closed Sergio0694 closed 10 months ago

Sergio0694 commented 1 year ago

Description

This PR adds the following polyfills for C# 12 and .NET 8:

dongle-the-gadget commented 1 year ago

I thought UnsafeAccessor is not allowed within non .NET 8 binaries?

WeihanLi commented 10 months ago

.NET 8 had released, so is there a plan get this merged?

Sergio0694 commented 10 months ago

Of course there is a plan, or this PR wouldn't exist. Just a little bit of patience, this is not my full time job 😅

Sergio0694 commented 10 months ago

Note: waiting on https://github.com/actions/runner-images/issues/8797.

Trinitek commented 10 months ago

Note: waiting on actions/runner-images#8797.

The image seems to be updated now.

sliekens commented 10 months ago

Hi @Sergio0694, is the namespace System.Runtime.CompilerServices2 a typo or was it intended for the InlineArrayAttribute?

Sergio0694 commented 10 months ago

It's intended. Roslyn matches the attribute by full name, and will not let you use it if it's in the correct one and the runtime does not support it. So the only way to make that compile is to put it into a different namespace. I'm doing the same for [UnmanagedCallersOnly].

sliekens commented 10 months ago

@Sergio0694 do you have any insight why InlineArrayAttribute shows up in my assembly's exported types but the other attributes don't? It's causing some neck pains with other tools which don't like it when I put types in the System namespace, e.g. https://github.com/dotnet/docfx/issues/9507

sliekens commented 10 months ago

Okay I see it's because InlineArrayAttribute visibility is always public, ignoring PolySharpUsePublicAccessibilityForGeneratedTypes. Is that a bug @Sergio0694 ?

Sergio0694 commented 10 months ago

It is, yeah. I'll go fix it when I have a minute, good find! 😅

sliekens commented 10 months ago

If it's just a matter of changing the visibility and bumping the version, I can make a PR.

Sergio0694 commented 10 months ago

Just needs changing the visibility, the version is set automatically by the CI when I create a release branch 🙂

sliekens commented 10 months ago

Voila #92

AvremelM commented 10 months ago

Sorry for the comment spam, but it's insane to me that C# 12 has been out for less than a month and you've already released polyfill support for it.

Thank you so much @Sergio0694 (and collaborators!) for this project.