Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCS1019 IDE0036 Inconsistency #427

Open
nnpcYvIVl opened this issue Aug 16, 2018 · 7 comments
Open

RCS1019 IDE0036 Inconsistency #427

nnpcYvIVl opened this issue Aug 16, 2018 · 7 comments

Comments

@nnpcYvIVl
Copy link
Contributor

nnpcYvIVl commented Aug 16, 2018

If I use the recommended editorconfig settings concerning modifier order at: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#example-editorconfig-file

# Modifier preferences
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion

Reviewing the following code: RCS1019 wants new to come before public, IDE0036 wants new to come after public.

namespace RCS1019_IDE0036_Inconsistency
{
    public class Console
    {
        public new bool Equals => true;

        new public bool ReferenceEquals => true;
    }
}

Is this by design or should RCS1019 be changed to match Microsoft's IDE0036 default recommendation?

@josefpihrt
Copy link
Collaborator

I use C# Language Specification 5.0 (page 307) as a reference for this analyzer.

Changing the order of modifiers would be a breaking change.

@wiz0u
Copy link

wiz0u commented Dec 10, 2018

I have a similar issue:
protected abstract override bool Check(out string reason); causes RCS1019, and
protected override abstract bool Check(out string reason); causes IDE0036

I've read C# Language Specification 5.0 (page 307), and nowhere does it speak about the order of modifiers, it merely list them in no particular order and gives some rules about them.
I also read this StackOverflow discussion, and MS documentation about EditorConfig ; in particular the section about csharp_preferred_modifier_order default value:

csharp_preferred_modifier_order IDE0036 C# public, private, protected, internal, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async:none

I understand changing this could be somewhat annoying to users (but these exotic combinations of modifiers are quite rare so it shouldn't raise many location of code to fix), but I wouldn't consider it a 'breaking change' as it wouldn't break existing code.

@marcospgp
Copy link

@josefpihrt How do I disable an IDExxxx warning in VSCode?

@josefpihrt
Copy link
Collaborator

@marcospgp Either in ruleset file:

    <Rule Id="IDExxxx" Action="None" />

or in editorconfig:

dotnet_diagnostic.IDExxx.severity = none

https://docs.microsoft.com/en-us/visualstudio/code-quality/use-roslyn-analyzers?view=vs-2019

@marcospgp
Copy link

I believe I tried using the ruleset file and it didn't work. I ended up adding the rule to the .editorconfig file at the project root (as you also mentioned), but Omnisharp currently has an issue where updates to the C# project files cause it to forget all the rules until VSCode is restarted. This should be fixed in the next release as per @filipw (OmniSharp/omnisharp-roslyn#1711 (comment)).

@mcflux
Copy link

mcflux commented Jun 21, 2021

This issue is still a thing with
public new void ABC() { }
that violates RCS1019
new public void ABC() { }
violates IDE0036

@BenjaminBrienen
Copy link
Contributor

I am having the same IDE0036 consistency issue as @mcflux. Roslynator should provide (documented) configuration so that we can solve this without disabling an analyzer.

@josefpihrt josefpihrt self-assigned this Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants