Skip to content

Commit 84aabb2

Browse files
author
Dirk Lemstra
committed
Fixed false report for named tuple elements.
1 parent 7cf7332 commit 84aabb2

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1101CSharp7UnitTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,31 @@
33

44
namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules
55
{
6+
using System.Threading;
7+
using System.Threading.Tasks;
68
using StyleCop.Analyzers.Test.ReadabilityRules;
9+
using Xunit;
710

811
public class SA1101CSharp7UnitTests : SA1101UnitTests
912
{
13+
/// <summary>
14+
/// Verifies that a value tuple is handled properly.
15+
/// </summary>
16+
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
17+
[Fact]
18+
[WorkItem(2534, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2534")]
19+
public async Task TestValueTupleAsync()
20+
{
21+
var testCode = @"public class Foo
22+
{
23+
protected (bool a, bool b) Bar()
24+
{
25+
return (a: true, b: false);
26+
}
27+
}
28+
";
29+
30+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
31+
}
1032
}
1133
}

StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1101PrefixLocalCallsWithThis.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ private static void HandleSimpleName(SyntaxNodeAnalysisContext context)
8383
// this is handled separately
8484
return;
8585

86+
case SyntaxKind.MemberBindingExpression:
87+
case SyntaxKind.NameColon:
8688
case SyntaxKind.PointerMemberAccessExpression:
8789
// this doesn't need to be handled
8890
return;
@@ -122,10 +124,6 @@ private static void HandleSimpleName(SyntaxNodeAnalysisContext context)
122124

123125
break;
124126

125-
case SyntaxKind.MemberBindingExpression:
126-
// this doesn't need to be handled
127-
return;
128-
129127
default:
130128
break;
131129
}

0 commit comments

Comments
 (0)