Skip to content

IDE0007 when enum name is the same as variable name #26894

@MSeifert04

Description

@MSeifert04

Version Used:

Not sure what version is meant but I'm using Visual Studio 15.7.1, I hope that helps.

Steps to Reproduce:

Config:

csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = true:suggestion

Code:

enum A { B, C };

public void Fun()
{
    A A = A.B;
}

Expected Behavior:

No IDE0007 and no suggested "code fix".

Actual Behavior:

It suggests to replace A with var but that would lead to code that won't compile (Cannot use local variable before it's declared).

After code fix:

enum A { B, C };

public void Fun()
{
    var A = A.B;
}

Metadata

Metadata

Assignees

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