Skip to content

Convert anonymous delegate to lambda expression #122

@ElemarJR

Description

@ElemarJR

This:

System.Action a = delegate { System.Console.WriteLine(); };
System.Action<int> b = delegate (int i) { i++; };
System.Func<int, int> c = delegate (int i) { return i; };
System.Func<int, int> d = delegate (int i)
{
    i++;
    return i;
};

Becomes:

System.Action a = () => System.Console.WriteLine();
System.Action<int> b = (int i) => i++;
System.Func<int, int> c = (int i) => i;
System.Func<int, int> d = (int i) =>
{
    i++;
    return i;
};

Diagnostic id: CC0107
Severity: Hidden
Category: Refactoring

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions