Skip to content

Refactor to support extension members #95

@oliverbooth

Description

@oliverbooth

As of C# 14.0, "extension everything" finally started to make its way into the language with the introduction of "extension members". This new construct allows the creation of extension properties and indexers, as well as static methods, properties, and indexers for a type.

For example, a static extension method might look like the following:

string result = string.Random(42);

static class Extensions
{
    extension (string)
    {
        public static string Random(int length) => new(Enumerable.Range(0, length).Select(_ => "abcdefghijklmnopqrstuvwxyz"[System.Random.Shared.Next(26)]).ToArray());
    }
}

This construct will be added to X10D in upcoming updates to add support for extension properties where appropriate, and static extension methods such as the above.

The language proposal for this feature can be found at https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/extensions

For implementation information, see: https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods

Sub-issues

Metadata

Metadata

Assignees

Labels

approvedThis issue has been approved by the developerenhancementNew feature or requestnet10.0Issue applies to .NET 10.net8.0Issue applies to .NET 8.net9.0Issue applies to .NET 9.triagedHigh-priority issuevNextThe next major version of X10D.

Projects

Status

To do

Relationships

None yet

Development

No branches or pull requests

Issue actions