Skip to content

Support detection of method groups passed as delegate arguments (method-as-value) in C# #82

@aalramadan

Description

@aalramadan

Stereocode currently does not recognize cases where a method is passed as a delegate using a method group. For example, OnWorkFinished here:

public class Worker
{
    public void Start(Action onFinished)
    {
        Console.WriteLine("Working...");
        onFinished(); // invoke callback
    }
}

public class Demo
{
    public void Run()
    {
        var worker = new Worker();

        // Passing a method *as a value*, without parentheses
        worker.Start(OnWorkFinished);
    }

    private void OnWorkFinished()
    {
        Console.WriteLine("Work finished!");
    }
}

In this pattern, the method is not invoked. Instead, the method itself is passed as a value (a delegate instance). This is valid C# and must be treated differently from a normal method call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions