Skip to content

Add C# 12 and .NET 8 polyfills#81

Merged
Sergio0694 merged 12 commits into
mainfrom
dev/net8-polyfills
Nov 22, 2023
Merged

Add C# 12 and .NET 8 polyfills#81
Sergio0694 merged 12 commits into
mainfrom
dev/net8-polyfills

Conversation

@Sergio0694

@Sergio0694 Sergio0694 commented Aug 20, 2023

Copy link
Copy Markdown
Owner

Description

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

  • [RequiresLocation]
  • [CollectionBuilder]
  • [UnsafeAccessor]
  • [Experimental]
  • [InlineArray]

@Sergio0694 Sergio0694 added the infrastructure Build/packaging related changes label Aug 20, 2023
@Sergio0694 Sergio0694 changed the title Remove .NET Core 3.1 TFMs Add C# 12 and .NET 8 polyfills Aug 20, 2023
@Sergio0694 Sergio0694 added enhancement New feature or request and removed infrastructure Build/packaging related changes labels Aug 20, 2023
@Sergio0694 Sergio0694 marked this pull request as draft August 20, 2023 18:18
@dongle-the-gadget

Copy link
Copy Markdown
Contributor

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

@WeihanLi

Copy link
Copy Markdown

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

@Sergio0694

Copy link
Copy Markdown
Owner Author

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 😅

Comment thread README.md Outdated
@Sergio0694

Copy link
Copy Markdown
Owner Author

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

@Trinitek

Copy link
Copy Markdown

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

The image seems to be updated now.

@Sergio0694 Sergio0694 marked this pull request as ready for review November 22, 2023 20:01
@Sergio0694 Sergio0694 merged commit 2a6e35e into main Nov 22, 2023
@Sergio0694 Sergio0694 deleted the dev/net8-polyfills branch November 22, 2023 21:15
@sliekens

sliekens commented Dec 4, 2023

Copy link
Copy Markdown
Contributor

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

@Sergio0694

Copy link
Copy Markdown
Owner Author

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

sliekens commented Dec 5, 2023

Copy link
Copy Markdown
Contributor

@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. dotnet/docfx#9507

@sliekens

sliekens commented Dec 5, 2023

Copy link
Copy Markdown
Contributor

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

@Sergio0694

Copy link
Copy Markdown
Owner Author

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

@sliekens

sliekens commented Dec 5, 2023

Copy link
Copy Markdown
Contributor

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

@Sergio0694

Copy link
Copy Markdown
Owner Author

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

@sliekens

sliekens commented Dec 5, 2023

Copy link
Copy Markdown
Contributor

Voila #92

@AvremelM

AvremelM commented Dec 5, 2023

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants