|
5 | 5 |
|
6 | 6 | namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules |
7 | 7 | { |
| 8 | + using System; |
8 | 9 | using System.Threading; |
9 | 10 | using System.Threading.Tasks; |
10 | 11 | using Microsoft.CodeAnalysis.Testing; |
@@ -117,5 +118,61 @@ public static explicit operator TestClass({typeExpression} p1) |
117 | 118 |
|
118 | 119 | await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); |
119 | 120 | } |
| 121 | + |
| 122 | + [Fact] |
| 123 | + public async Task ValidateTuplesFromInterfaceAsync() |
| 124 | + { |
| 125 | + const string testCode = @" |
| 126 | +using System.Collections.Generic; |
| 127 | +
|
| 128 | +namespace Test { |
| 129 | + class StringTupleComparer : IEqualityComparer<(string, string)> |
| 130 | + { |
| 131 | + public bool Equals((string, string) x, (string, string) y) => throw null; |
| 132 | +
|
| 133 | + public int GetHashCode((string, string) obj) => throw null; |
| 134 | + } |
| 135 | +}"; |
| 136 | + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); |
| 137 | + } |
| 138 | + |
| 139 | + [Fact] |
| 140 | + public async Task ValidateTuplesFromExplicitInterfaceImplementationAsync() |
| 141 | + { |
| 142 | + const string testCode = @" |
| 143 | +using System.Collections.Generic; |
| 144 | +
|
| 145 | +namespace Test { |
| 146 | + class StringTupleComparer : IEqualityComparer<(string, string)> |
| 147 | + { |
| 148 | + bool IEqualityComparer<(string, string)>.Equals((string, string) x, (string, string) y) => throw null; |
| 149 | +
|
| 150 | + int IEqualityComparer<(string, string)>.GetHashCode((string, string) obj) => throw null; |
| 151 | + } |
| 152 | +}"; |
| 153 | + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); |
| 154 | + } |
| 155 | + |
| 156 | + [Fact] |
| 157 | + public async Task ValidateTuplesFromBaseClassAsync() |
| 158 | + { |
| 159 | + const string testCode = @" |
| 160 | +namespace Test { |
| 161 | + class A : B |
| 162 | + { |
| 163 | + public override (string, string) Run((string, string) x) => throw null; |
| 164 | +
|
| 165 | + public override (int, int) Run((int, int) y) => throw null; |
| 166 | + } |
| 167 | +
|
| 168 | + abstract class B |
| 169 | + { |
| 170 | + public abstract ([|string|], [|string|]) Run(([|string|], [|string|]) x); |
| 171 | +
|
| 172 | + public virtual ([|int|], [|int|]) Run(([|int|], [|int|]) y) => throw null; |
| 173 | + } |
| 174 | +}"; |
| 175 | + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); |
| 176 | + } |
120 | 177 | } |
121 | 178 | } |
0 commit comments