Skip to content

Quick fix of editorconfig based naming rule continues to report error after applying fix #2039

Open
@hackf5

Description

@hackf5

I'm using VS Code 1.52 on Windows with Omnisharp v1.23.7 (my visual studio version of MSBuild is 1.8.2.56705, dont know if this is relevant.

.editorconfig

# C# files
[*.cs]

#### Naming styles ####

##  Naming rules

# private fields (_foo)
dotnet_naming_rule.private_field_members_should_be_camel_case_begins_with_underscore.severity = warning
dotnet_naming_rule.private_field_members_should_be_camel_case_begins_with_underscore.symbols = private_field_members
dotnet_naming_rule.private_field_members_should_be_camel_case_begins_with_underscore.style = camel_case_begins_with_underscore

## Symbol specifications

# fields
dotnet_naming_symbols.private_field_members.applicable_kinds = field
dotnet_naming_symbols.private_field_members.applicable_accessibilities = private
dotnet_naming_symbols.private_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.camel_case_begins_with_underscore.required_prefix = _
dotnet_naming_style.camel_case_begins_with_underscore.required_suffix =
dotnet_naming_style.camel_case_begins_with_underscore.word_separator =
dotnet_naming_style.camel_case_begins_with_underscore.capitalization = camel_case

# Diagnostics
dotnet_diagnostic.IDE1006.severity = warning

CSPROJ

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
  </PropertyGroup>

</Project>

C# class

    public class Class1
    {
        private int foo;

        public int Foo => this.foo;
    }

The rule violation is correctly identified. When I select Fix Name Violation: _foo the class is correctly modified.

    public class Class1
    {
        private int _foo;

        public int Foo => this._foo;
    }

However the warning does not go away, the message is

Naming rule violation: Prefix '_' does not match expected prefix '_' [quickfixbugs, quickfixbugs]csharp(IDE1006)

(restarting Omnisharp makes the warning go away)

If I select this the the class becomes

    public class Class1
    {
        private int _oo;

        public int Foo => this._oo;
    }

It is now happy, but this is wrong.

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