Skip to content

IDE0044 "Make field readonly" false positive when used in ref return #33009

@Tragetaschen

Description

@Tragetaschen

Version Used:
16.0.0 Preview 2.0

Steps to Reproduce:

public class C
{
    private int a, b; // IDE0044
    private ref int select(bool c) => ref (c ? ref a : ref b);
    public void Test() => select(true) = 3;
}

Expected Behavior:
The members are mutated. Marking them readonly breaks the code, so IDE0044 shouldn't trigger.

Actual Behavior:
IDE0044 is falsely triggered.

Metadata

Metadata

Assignees

Labels

Area-IDEBugFeature - IDE0044Make field readonlyIDE-CodeStyleBuilt-in analyzers, fixes, and refactoringsResolution-FixedThe bug has been fixed and/or the requested behavior has been implemented

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions