diff --git a/ChangeLog.md b/ChangeLog.md index 885098b015..39c4c2d486 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix analyzer [RCS0049](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS0049) ([PR](https://github.com/dotnet/roslynator/pull/1386)) - Fix analyzer [RCS1159](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1159) ([PR](https://github.com/dotnet/roslynator/pull/1390)) +- Fix analyzer [RCS1019](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1019) ([PR](https://github.com/dotnet/roslynator/pull/1402)) - Fix code fix for [CS8600](https://josefpihrt.github.io/docs/roslynator/fixes/CS8600) changing the wrong type when casts or `var` are involved ([PR](https://github.com/dotnet/roslynator/pull/1393) by @jroessel) ## [4.10.0] - 2024-01-24 diff --git a/src/CSharp/CSharp/ModifierKindComparer.cs b/src/CSharp/CSharp/ModifierKindComparer.cs index 3f05ff2d3e..de90b1adc8 100644 --- a/src/CSharp/CSharp/ModifierKindComparer.cs +++ b/src/CSharp/CSharp/ModifierKindComparer.cs @@ -22,47 +22,51 @@ public virtual int GetRank(SyntaxKind kind) case SyntaxKind.NewKeyword: return 0; case SyntaxKind.PublicKeyword: - return 1; + return 10; case SyntaxKind.PrivateKeyword: - return 2; + return 20; case SyntaxKind.ProtectedKeyword: - return 3; + return 30; case SyntaxKind.InternalKeyword: - return 4; + return 40; +#if ROSLYN_4_4 + case SyntaxKind.FileKeyword: + return 50; +#endif case SyntaxKind.ConstKeyword: - return 5; + return 60; case SyntaxKind.StaticKeyword: - return 6; + return 70; case SyntaxKind.VirtualKeyword: - return 7; + return 80; case SyntaxKind.SealedKeyword: - return 8; + return 90; case SyntaxKind.OverrideKeyword: - return 9; + return 100; case SyntaxKind.AbstractKeyword: - return 10; + return 110; case SyntaxKind.ReadOnlyKeyword: - return 11; + return 120; case SyntaxKind.ExternKeyword: - return 12; + return 130; case SyntaxKind.UnsafeKeyword: - return 13; + return 140; case SyntaxKind.FixedKeyword: - return 14; + return 150; case SyntaxKind.VolatileKeyword: - return 15; + return 160; case SyntaxKind.AsyncKeyword: - return 16; + return 170; case SyntaxKind.PartialKeyword: - return 17; + return 180; case SyntaxKind.ThisKeyword: - return 18; + return 190; case SyntaxKind.RefKeyword: - return 19; + return 200; case SyntaxKind.OutKeyword: - return 20; + return 210; case SyntaxKind.InKeyword: - return 21; + return 220; default: { Debug.Fail($"unknown modifier '{kind}'"); diff --git a/src/Tests/Analyzers.Tests/RCS1019OrderModifiersTests.cs b/src/Tests/Analyzers.Tests/RCS1019OrderModifiersTests.cs new file mode 100644 index 0000000000..e03b428f9b --- /dev/null +++ b/src/Tests/Analyzers.Tests/RCS1019OrderModifiersTests.cs @@ -0,0 +1,24 @@ +// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Threading.Tasks; +using Microsoft.CodeAnalysis; +using Roslynator.CSharp.CodeFixes; +using Roslynator.Testing.CSharp; +using Xunit; + +namespace Roslynator.CSharp.Analysis.Tests; + +public class RCS1019OrderModifiersTests : AbstractCSharpDiagnosticVerifier +{ + public override DiagnosticDescriptor Descriptor { get; } = DiagnosticRules.OrderModifiers; + + [Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.OrderModifiers)] + public async Task Test() + { + await VerifyNoDiagnosticAsync(""" +file static class C +{ +} +"""); + } +}