[release-notes] C# in .NET 11 Preview 5#10426
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| In this preview, projects that declare unions need the compiler support types available to the compilation: | ||
|
|
||
| ```csharp | ||
| namespace System.Runtime.CompilerServices; | ||
|
|
||
| [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false)] | ||
| public sealed class UnionAttribute : Attribute { } | ||
|
|
||
| public interface IUnion | ||
| { | ||
| object? Value { get; } | ||
| } | ||
| ``` |
There was a problem hiding this comment.
Tagging @eiriktsarpalis
I had a notification that these types are now in the .NET 11 Preview 5 libraries, and projects no longer need to provide polyfills. Can you confirm or correct?
Related: Is System.Runtime.CompilerServices the correct namespace after API review (for both UnionAttribute and IUnion).
| In this preview, projects that define closed classes also need the compiler support attribute available to the compilation: | ||
|
|
||
| ```csharp | ||
| namespace System.Runtime.CompilerServices; | ||
|
|
||
| [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] | ||
| public sealed class ClosedAttribute : Attribute { } | ||
| ``` |
There was a problem hiding this comment.
My understanding is that this hasn't gone through API review yet, so this polyfill is necessary. Can you confirm?
There was a problem hiding this comment.
We got it approved last week: dotnet/runtime#128161 (comment)
I would recommend removing mention of closed types in the Preview 5 article until their implementation has been finalized.
There was a problem hiding this comment.
Preview 5 will need polyfill of ClosedAttribute.
We renamed to IsClosedTypeAttribute (and API review approved that name) after shipping preview 5, and are now working on some adjustments to the metadata representation to try and get in for preview 6.
At that point I would consider it fairly stable from end user POV.
This is the first preview where we're talking about unsafe evolution. Talk about the feature, and then add only the changes in preview 5.
C# release notes for .NET 11 Preview 5.
This component PR targets the base milestone branch
release-notes/11.0-preview5(umbrella PR: #10421). Review and edit the markdown here in isolation — when this PR merges into the base branch, the changes roll up into the umbrella PR.Draft generated with the
release-notesskill in this repo. Verify feature selection, code samples, API names, and contributor attributions before marking ready for review.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com