Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,25 @@

namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules
{
using System.Threading;
using System.Threading.Tasks;
using StyleCop.Analyzers.Test.CSharp10.OrderingRules;
using Xunit;
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
StyleCop.Analyzers.OrderingRules.SA1206DeclarationKeywordsMustFollowOrder,
StyleCop.Analyzers.OrderingRules.SA1206CodeFixProvider>;

public class SA1206CSharp11CodeFixProviderUnitTests : SA1206CSharp10CodeFixProviderUnitTests
{
[Fact]
[WorkItem(3589, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3589")]
public async Task VerifyFileKeywordReorderingInClassDeclarationAsync()
{
var testCode = $"static unsafe {{|#0:file|}} class TestClass {{}}";
var fixedTestCode = $"file static unsafe class TestClass {{}}";

var expected = Diagnostic().WithLocation(0).WithArguments("file", "unsafe");
await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.2.0-4.final" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.4.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" PrivateAssets="all" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace StyleCop.Analyzers.OrderingRules
{
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using StyleCop.Analyzers.Lightup;

internal static class ModifierOrderHelper
{
Expand All @@ -21,7 +22,7 @@ internal enum ModifierType
None,

/// <summary>
/// Represents any of access modifiers, i.e <see langword="public"/>, <see langword="protected"/>, <see langword="internal"/>, <see langword="private"/>.
/// Represents any of access modifiers, i.e <see langword="public"/>, <see langword="protected"/>, <see langword="internal"/>, <see langword="private"/>, <see langword="file"/>.
/// </summary>
Access,

Expand All @@ -46,6 +47,7 @@ internal static ModifierType GetModifierType(SyntaxToken modifier)
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.InternalKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKindEx.FileKeyword:
result = ModifierType.Access;
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ internal static class SyntaxKindEx
public const SyntaxKind NotKeyword = (SyntaxKind)8440;
public const SyntaxKind ManagedKeyword = (SyntaxKind)8445;
public const SyntaxKind UnmanagedKeyword = (SyntaxKind)8446;
public const SyntaxKind FileKeyword = (SyntaxKind)8449;
public const SyntaxKind NullableKeyword = (SyntaxKind)8486;
public const SyntaxKind EnableKeyword = (SyntaxKind)8487;
public const SyntaxKind WarningsKeyword = (SyntaxKind)8488;
Expand Down