Skip to content

IDE0032 should not be reported for volatile fields #25379

@azyobuzin

Description

@azyobuzin

Version Used: Visual Studio Community 15.6.1

Steps to Reproduce:
Here is the example code.

class Class1
{
    private volatile int _field1;

    public int Property1
    {
        get { return this._field1; }
        set { this._field1 = value; }
    }

    public int Property2 { get; set; }
}

Property1 is a wrapper for _field1, which has volatile modifier. Property2 is a normal auto property, which is written for comparison.

Visual Studio says _field1 can be an auto property.

Screenshot of Code Action

Expected Behavior: This suggestion should not be shown because the field has volatile modifier.

The way to access to volatile fields is different from the way to access to normal fields. Access to volatile fields needs volatile. prefix in IL. So the field cannot be an auto property in the present case.

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