roslynator
roslynator copied to clipboard
RCS1019 IDE0036 Inconsistency
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?
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.
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.
@JosefPihrt How do I disable an IDExxxx warning in VSCode?
@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
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 (https://github.com/OmniSharp/omnisharp-roslyn/issues/1711#issuecomment-743796889).
This issue is still a thing with
public new void ABC() { }
that violates RCS1019
new public void ABC() { }
violates IDE0036
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.