Skip to content

Commit e4e210e

Browse files
committed
feat: add new rule SA1317
- add a diagnostic - add an empty CodeFixProvider - add unit tests - add documentation #2057
1 parent f5843ae commit e4e210e

File tree

16 files changed

+886
-0
lines changed

16 files changed

+886
-0
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/TaskHelper.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ namespace StyleCop.Analyzers.Helpers
1313

1414
internal static class TaskHelper
1515
{
16+
public static readonly Task CompletedTask = Task.FromResult(0);
17+
1618
public static bool IsTaskReturningMethod(SemanticModel semanticModel, MethodDeclarationSyntax methodDeclarationSyntax, CancellationToken cancellationToken)
1719
{
1820
return IsTaskType(semanticModel, methodDeclarationSyntax.ReturnType, cancellationToken);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
#nullable disable
5+
6+
namespace StyleCop.Analyzers.NamingRules
7+
{
8+
using System.Collections.Immutable;
9+
using System.Composition;
10+
using System.Threading.Tasks;
11+
using Microsoft.CodeAnalysis;
12+
using Microsoft.CodeAnalysis.CodeActions;
13+
using Microsoft.CodeAnalysis.CodeFixes;
14+
using Microsoft.CodeAnalysis.CSharp;
15+
using StyleCop.Analyzers.Helpers;
16+
17+
/// <summary>
18+
/// Implements a code fix for <see cref="SA1317IdentifierShouldBeNamedOnlyWithLatinLetters"/>.
19+
/// </summary>
20+
/// <remarks>
21+
/// <para>To fix a violation of this rule, replace non-Latin letters with appropriate Latin letters.</para>
22+
/// </remarks>
23+
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(SA1317CodeFixProvider))]
24+
[Shared]
25+
internal class SA1317CodeFixProvider : CodeFixProvider
26+
{
27+
/// <inheritdoc/>
28+
public override ImmutableArray<string> FixableDiagnosticIds { get; } =
29+
ImmutableArray.Create(SA1317IdentifierShouldBeNamedOnlyWithLatinLetters.DiagnosticId);
30+
31+
/// <inheritdoc/>
32+
public override FixAllProvider GetFixAllProvider()
33+
{
34+
return null;
35+
}
36+
37+
/// <inheritdoc/>
38+
public override async Task RegisterCodeFixesAsync(CodeFixContext context)
39+
{
40+
await TaskHelper.CompletedTask.ConfigureAwait(false);
41+
}
42+
}
43+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
#nullable disable
5+
6+
namespace StyleCop.Analyzers.Test.CSharp10.NamingRules
7+
{
8+
using StyleCop.Analyzers.Test.CSharp9.NamingRules;
9+
10+
public partial class SA1317CSharp10UnitTests : SA1317CSharp9UnitTests
11+
{
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
#nullable disable
5+
6+
namespace StyleCop.Analyzers.Test.CSharp11.NamingRules
7+
{
8+
using StyleCop.Analyzers.Test.CSharp10.NamingRules;
9+
10+
public partial class SA1317CSharp11UnitTests : SA1317CSharp10UnitTests
11+
{
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
#nullable disable
5+
6+
namespace StyleCop.Analyzers.Test.CSharp12.NamingRules
7+
{
8+
using StyleCop.Analyzers.Test.CSharp11.NamingRules;
9+
10+
public partial class SA1317CSharp12UnitTests : SA1317CSharp11UnitTests
11+
{
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
#nullable disable
5+
6+
namespace StyleCop.Analyzers.Test.CSharp13.NamingRules
7+
{
8+
using StyleCop.Analyzers.Test.CSharp12.NamingRules;
9+
10+
public partial class SA1317CSharp13UnitTests : SA1317CSharp12UnitTests
11+
{
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
#nullable disable
5+
6+
namespace StyleCop.Analyzers.Test.CSharp7.NamingRules
7+
{
8+
using StyleCop.Analyzers.Test.NamingRules;
9+
10+
public partial class SA1317CSharp7UnitTests : SA1317UnitTests
11+
{
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
#nullable disable
5+
6+
namespace StyleCop.Analyzers.Test.CSharp8.NamingRules
7+
{
8+
using StyleCop.Analyzers.Test.CSharp7.NamingRules;
9+
10+
public partial class SA1317CSharp8UnitTests : SA1317CSharp7UnitTests
11+
{
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
#nullable disable
5+
6+
namespace StyleCop.Analyzers.Test.CSharp9.NamingRules
7+
{
8+
using StyleCop.Analyzers.Test.CSharp8.NamingRules;
9+
10+
public partial class SA1317CSharp9UnitTests : SA1317CSharp8UnitTests
11+
{
12+
}
13+
}

0 commit comments

Comments
 (0)