11// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
22// Licensed under the MIT License. See LICENSE in the project root for license information.
33
4- #nullable disable
5-
64namespace StyleCop . Analyzers . Test . CSharp7 . ReadabilityRules
75{
86 using System . Threading ;
97 using System . Threading . Tasks ;
108 using Microsoft . CodeAnalysis . Testing ;
119 using StyleCop . Analyzers . ReadabilityRules ;
10+ using StyleCop . Analyzers . Test . ReadabilityRules ;
1211 using Xunit ;
1312 using static StyleCop . Analyzers . Test . Verifiers . StyleCopCodeFixVerifier <
1413 StyleCop . Analyzers . ReadabilityRules . SA1141UseTupleSyntax ,
@@ -19,7 +18,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules
1918 /// </summary>
2019 /// <seealso cref="SA1141UseTupleSyntax"/>
2120 /// <seealso cref="SA1141CodeFixProvider"/>
22- public class SA1141CSharp7UnitTests
21+ public class SA1141CSharp7UnitTests : SA1141UnitTests
2322 {
2423 /// <summary>
2524 /// Verifies that member declarations containing ValueTuple will result in the proper diagnostics and fixes.
@@ -32,28 +31,28 @@ public async Task ValidateMemberDeclarationsWithValueTuplesAsync()
3231
3332public class TestClass
3433{
35- public ValueTuple<int, int> TestMethod(ValueTuple<double, double> value)
34+ public [| ValueTuple<int, int>|] TestMethod([| ValueTuple<double, double>|] value)
3635 {
3736 throw new NotImplementedException();
3837 }
3938
40- public System.ValueTuple<(int, int), int> TestMethod2(int p1, ValueTuple<System.ValueTuple<long, long>, long> p2, (ValueTuple<string, string>, string) p3)
39+ public [| System.ValueTuple<(int, int), int>|] TestMethod2(int p1, [| ValueTuple<System.ValueTuple<long, long>, long>|] p2, ([| ValueTuple<string, string>|] , string) p3)
4140 {
4241 throw new NotImplementedException();
4342 }
4443
45- public System.ValueTuple<int, int> TestProperty1 { get; set; }
44+ public [| System.ValueTuple<int, int>|] TestProperty1 { get; set; }
4645
47- public System.Collections.Generic.List<ValueTuple<int, int>> TestProperty2 { get; set; }
46+ public System.Collections.Generic.List<[| ValueTuple<int, int>|] > TestProperty2 { get; set; }
4847
49- public System.ValueTuple<int, long> this[int i] { get { return (1, 1l); } set { } }
48+ public [| System.ValueTuple<int, long>|] this[int i] { get { return (1, 1l); } set { } }
5049
51- public static explicit operator TestClass(System.ValueTuple<int, int> p1)
50+ public static explicit operator TestClass([| System.ValueTuple<int, int>|] p1)
5251 {
5352 throw new NotImplementedException();
5453 }
5554
56- public static implicit operator System.ValueTuple<int, int>(TestClass p1)
55+ public static implicit operator [| System.ValueTuple<int, int>|] (TestClass p1)
5756 {
5857 throw new NotImplementedException();
5958 }
@@ -92,21 +91,7 @@ public static implicit operator (int, int)(TestClass p1)
9291}
9392" ;
9493
95- DiagnosticResult [ ] expectedDiagnostics =
96- {
97- Diagnostic ( ) . WithLocation ( 5 , 12 ) ,
98- Diagnostic ( ) . WithLocation ( 5 , 44 ) ,
99- Diagnostic ( ) . WithLocation ( 10 , 12 ) ,
100- Diagnostic ( ) . WithLocation ( 10 , 67 ) ,
101- Diagnostic ( ) . WithLocation ( 10 , 120 ) ,
102- Diagnostic ( ) . WithLocation ( 15 , 12 ) ,
103- Diagnostic ( ) . WithLocation ( 17 , 44 ) ,
104- Diagnostic ( ) . WithLocation ( 19 , 12 ) ,
105- Diagnostic ( ) . WithLocation ( 21 , 47 ) ,
106- Diagnostic ( ) . WithLocation ( 26 , 37 ) ,
107- } ;
108-
109- await VerifyCSharpFixAsync ( testCode , expectedDiagnostics , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
94+ await VerifyCSharpFixAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
11095 }
11196
11297 /// <summary>
@@ -122,18 +107,18 @@ public class TestClass
122107{
123108 public void TestMethod()
124109 {
125- var test1 = new ValueTuple<int, int>(1, 2);
126- var test2 = new System.ValueTuple<int, int>(1, 2);
127- var test3 = new ValueTuple<ValueTuple<int, int>, int>(new ValueTuple<int, int>(3, 4), 2);
128- var test4 = new System.ValueTuple<int, System.ValueTuple<int, int>>(1, new System.ValueTuple<int, int>(2, 3)) ;
129- var test5 = (new ValueTuple<int, int>(3, 4), 2);
130- var test6 = new System.ValueTuple<int, System.ValueTuple<int, int>>(1, (2, 3));
131- var test7 = ValueTuple.Create(1, 2);
132- var test8 = ValueTuple.Create<int, double>(1, 2);
133- var test9 = System.ValueTuple.Create(1, new ValueTuple<int, double>(2, 3));
134- var test10 = ValueTuple.Create( ValueTuple.Create(1, 2, 3), 4);
135- var test11 = new ValueTuple<int, ValueTuple<int, int>>(1, ValueTuple.Create(2, 3));
136- var test12 = new System.ValueTuple<byte, int>(1, 2);
110+ var test1 = [| new ValueTuple<int, int>(1, 2)|] ;
111+ var test2 = [| new System.ValueTuple<int, int>(1, 2)|] ;
112+ var test3 = [| new ValueTuple<ValueTuple<int, int>, int>([| new ValueTuple<int, int>(3, 4)|] , 2)|] ;
113+ var test4 = [| new System.ValueTuple<int, System.ValueTuple<int, int>>(1, [| new System.ValueTuple<int, int>(2, 3)|])|] ;
114+ var test5 = ([| new ValueTuple<int, int>(3, 4)|] , 2);
115+ var test6 = [| new System.ValueTuple<int, System.ValueTuple<int, int>>(1, (2, 3))|] ;
116+ var test7 = [| ValueTuple.Create|] (1, 2);
117+ var test8 = [| ValueTuple.Create<int, double>|] (1, 2);
118+ var test9 = [| System.ValueTuple.Create|] (1, [| new ValueTuple<int, double>(2, 3)|] );
119+ var test10 = [| ValueTuple.Create|]([| ValueTuple.Create|] (1, 2, 3), 4);
120+ var test11 = [| new ValueTuple<int, ValueTuple<int, int>>(1, [| ValueTuple.Create|] (2, 3))|] ;
121+ var test12 = [| new System.ValueTuple<byte, int>(1, 2)|] ;
137122 }
138123}
139124" ;
@@ -160,28 +145,7 @@ public void TestMethod()
160145}
161146" ;
162147
163- DiagnosticResult [ ] expectedDiagnostics =
164- {
165- Diagnostic ( ) . WithLocation ( 7 , 21 ) ,
166- Diagnostic ( ) . WithLocation ( 8 , 21 ) ,
167- Diagnostic ( ) . WithLocation ( 9 , 21 ) ,
168- Diagnostic ( ) . WithLocation ( 9 , 63 ) ,
169- Diagnostic ( ) . WithLocation ( 10 , 21 ) ,
170- Diagnostic ( ) . WithLocation ( 10 , 80 ) ,
171- Diagnostic ( ) . WithLocation ( 11 , 22 ) ,
172- Diagnostic ( ) . WithLocation ( 12 , 21 ) ,
173- Diagnostic ( ) . WithLocation ( 13 , 21 ) ,
174- Diagnostic ( ) . WithLocation ( 14 , 21 ) ,
175- Diagnostic ( ) . WithLocation ( 15 , 21 ) ,
176- Diagnostic ( ) . WithLocation ( 15 , 49 ) ,
177- Diagnostic ( ) . WithLocation ( 16 , 22 ) ,
178- Diagnostic ( ) . WithLocation ( 16 , 40 ) ,
179- Diagnostic ( ) . WithLocation ( 17 , 22 ) ,
180- Diagnostic ( ) . WithLocation ( 17 , 67 ) ,
181- Diagnostic ( ) . WithLocation ( 18 , 22 ) ,
182- } ;
183-
184- await VerifyCSharpFixAsync ( testCode , expectedDiagnostics , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
148+ await VerifyCSharpFixAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
185149 }
186150
187151 /// <summary>
@@ -329,8 +293,8 @@ public class TestClass
329293{
330294 public void TestMethod(object input)
331295 {
332- var test1 = (ValueTuple<int, int>)input;
333- var test2 = (System.ValueTuple<System.ValueTuple<int, long>, byte>)input;
296+ var test1 = ([| ValueTuple<int, int>|] )input;
297+ var test2 = ([| System.ValueTuple<System.ValueTuple<int, long>, byte>|] )input;
334298 }
335299}
336300" ;
@@ -347,13 +311,7 @@ public void TestMethod(object input)
347311}
348312" ;
349313
350- DiagnosticResult [ ] expectedDiagnostics =
351- {
352- Diagnostic ( ) . WithLocation ( 7 , 22 ) ,
353- Diagnostic ( ) . WithLocation ( 8 , 22 ) ,
354- } ;
355-
356- await VerifyCSharpFixAsync ( testCode , expectedDiagnostics , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
314+ await VerifyCSharpFixAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
357315 }
358316
359317 /// <summary>
@@ -369,8 +327,8 @@ public class TestClass
369327{
370328 public void TestMethod()
371329 {
372- var test1 = default(ValueTuple<int, int>);
373- var test2 = default(System.ValueTuple<System.ValueTuple<int, long>, byte>);
330+ var test1 = default([| ValueTuple<int, int>|] );
331+ var test2 = default([| System.ValueTuple<System.ValueTuple<int, long>, byte>|] );
374332 }
375333}
376334" ;
@@ -387,13 +345,7 @@ public void TestMethod()
387345}
388346" ;
389347
390- DiagnosticResult [ ] expectedDiagnostics =
391- {
392- Diagnostic ( ) . WithLocation ( 7 , 29 ) ,
393- Diagnostic ( ) . WithLocation ( 8 , 29 ) ,
394- } ;
395-
396- await VerifyCSharpFixAsync ( testCode , expectedDiagnostics , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
348+ await VerifyCSharpFixAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
397349 }
398350
399351 /// <summary>
@@ -407,7 +359,7 @@ public async Task ValidateValueTupleUsageInDelegateAsync()
407359
408360public class TestClass
409361{
410- public delegate System.ValueTuple<int, bool> TestDelegate(ValueTuple<int, ValueTuple<int, long>> arg1, (long, double) arg2, (long, System.ValueTuple<bool, bool>) arg3);
362+ public delegate [| System.ValueTuple<int, bool>|] TestDelegate([| ValueTuple<int, ValueTuple<int, long>>|] arg1, (long, double) arg2, (long, [| System.ValueTuple<bool, bool>|] ) arg3);
411363}
412364" ;
413365
@@ -419,14 +371,7 @@ public class TestClass
419371}
420372" ;
421373
422- DiagnosticResult [ ] expectedDiagnostics =
423- {
424- Diagnostic ( ) . WithLocation ( 5 , 21 ) ,
425- Diagnostic ( ) . WithLocation ( 5 , 63 ) ,
426- Diagnostic ( ) . WithLocation ( 5 , 136 ) ,
427- } ;
428-
429- await VerifyCSharpFixAsync ( testCode , expectedDiagnostics , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
374+ await VerifyCSharpFixAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
430375 }
431376 }
432377}
0 commit comments