Skip to content

UseAutoProperty generates invalid code when using ref on the field #25429

@Neme12

Description

@Neme12
class Class
{
    int value;
    int Value
    {
        get { return value; }
    }

    void M()
    {
        ref int x = ref value;
    }
}

applying the code fix results in:

class Class
{
    int Value { get; set; }
    
    void M()
    {
        ref int x = ref Value;
    }
}

which doesn't compile because Value doesn't return by ref.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEBugResolution-FixedThe bug has been fixed and/or the requested behavior has been implemented

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions