Skip to content

Find All References doesn't find usages of checked user-defined operators #60216

@AlekseyTs

Description

@AlekseyTs
class Program
{
    static void Main()
    {
        var x = new C();
        var y = new C();

        var z1 = -x;

        var z2 = x + y;

        string z3 = (string)x;

        ;

        checked
        {
            z1 = -y;
            z2 = y + x;
            z3 = (string)x;

            ;
        }

        System.Action a1 = D;
        System.Action a2 = D;

        var b = ReferenceEquals(a1, a2);
    }

    static void D() { }
}

class C
{
    /// <summary>
    /// <see cref="operator +(C, C)"/>
    /// <see cref="operator -(C)"/>
    /// <see cref="explicit operator string(C)"/>
    /// <see cref="operator checked +(C, C)"/>
    /// <see cref="operator checked -(C)"/>
    /// <see cref="explicit operator checked string(C)"/>
    /// </summary>
    public string F;

    public static C operator checked -(C x) => new C { F = "checked -" };
    public static C operator -(C x) => new C { F = "regular -" };

    public static C operator checked +(C x, C y) => new C { F = "checked +" };
    public static C operator +(C x, C y) => new C { F = "regular +" };

    public static explicit operator checked string(C x) => "checked string";

    public static explicit operator string(C y) => "regular string";
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions