Skip to content

Feature: C#-style extension method support #9

@TIHan

Description

@TIHan

C#-style extension method support:

public static class MyExtensions
{
    public static void MyExtensionMethod(this string str) { }
}

Can only be consumed explicitly at the moment:

main(): () =
    let str = "a string"
    MyExtensions.MyExtensionMethod(str)

We should add support that would look like this:

main(): () =
    let str = "a string"
    str.MyExtensionMethod()

Also, we need to consider adding support for C#14-style extension members:

public static class MyExtensions
{
    extension(string str)
    {
        // Method
        public void MyExtensionMethod() { }
        // Property
        string PlusOne => $"{str}1";
    }
}

Note: It's likely that once we handle C#-style extension methods, that C#14-style extension members will fit naturally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions