Skip to content

Conversation

BillWagner
Copy link
Member

@BillWagner BillWagner commented Jan 27, 2025

Fixes #44003: Ref structs can explicitly implement an interface. However, those methods are only callable from a generic method that allows ref structs on a type parameter. Otherwise, they require a boxing conversion, which violates ref safety.

Fixes #44508: Ref struct types don't need to, and in fact can't provide a specific implementation of a static method with a default implementation declared in an interface.


Internal previews

📄 File 🔗 Preview link
docs/csharp/language-reference/builtin-types/ref-struct.md ref structure types (C# reference)
docs/csharp/whats-new/csharp-13.md What's new in C# 13

Fixes dotnet#44003

Ref structs can explicitly implement an interface. However, those methods are only callable from a generic method that allows ref structs on a type parameter. Otherwise, they require a boxing conversion, which violates ref safety.

Fixes dotnet#44508 Ref struct types don't need to, and in fact can't provide a specific implementation of a static method with a default implementation declared in an interface.
@BillWagner BillWagner requested a review from a team as a code owner January 27, 2025 19:40
@dotnetrepoman dotnetrepoman bot added this to the January 2025 milestone Jan 27, 2025
@BillWagner BillWagner requested a review from gewarren January 27, 2025 19:40
@dotnet-policy-service dotnet-policy-service bot added okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. dotnet-csharp/svc whats-new/subsvc lang-reference/subsvc labels Jan 27, 2025
@BillWagner BillWagner merged commit 0f2a449 into dotnet:main Jan 27, 2025
13 checks passed
@BillWagner BillWagner deleted the ref-structs-and-interfaces branch January 27, 2025 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet-csharp/svc lang-reference/subsvc okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. whats-new/subsvc
Projects
None yet
2 participants