Skip to content

code fix of IDE0002 produces invalid code when a constant has same name as its type #45739

@aayjaychan

Description

@aayjaychan

Version Used:
Visual Studio 2019 16.6.2

Steps to Reproduce:

using System;

namespace N
{
    public class C
    {
        public const DateTimeKind DateTimeKind = System.DateTimeKind.Utc;
    }
}

Expected Behavior:
no suggestion is provided

Actual Behavior:
code fix suggested, which simplifies code to

using System;

namespace N
{
    public class C
    {
        public const DateTimeKind DateTimeKind = DateTimeKind.Utc;
    }
}

which causes error

CS0110 The evaluation of the constant value for 'C.DateTimeKind' involves a circular definition

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions