1
1
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2
2
// Licensed under the MIT License. See LICENSE in the project root for license information.
3
3
4
- #nullable disable
5
-
6
4
namespace StyleCop . Analyzers . Test . SpacingRules
7
5
{
6
+ using System . Collections . Generic ;
8
7
using System . Threading ;
9
8
using System . Threading . Tasks ;
9
+ using Microsoft . CodeAnalysis . CSharp ;
10
10
using Microsoft . CodeAnalysis . Testing ;
11
+ using StyleCop . Analyzers . Lightup ;
11
12
using StyleCop . Analyzers . SpacingRules ;
12
13
using Xunit ;
13
14
using static StyleCop . Analyzers . Test . Verifiers . StyleCopCodeFixVerifier <
@@ -19,6 +20,20 @@ namespace StyleCop.Analyzers.Test.SpacingRules
19
20
/// </summary>
20
21
public class SA1004UnitTests
21
22
{
23
+ public static IEnumerable < object [ ] > ParameterModifiers
24
+ {
25
+ get
26
+ {
27
+ yield return new [ ] { "out" } ;
28
+ yield return new [ ] { "ref" } ;
29
+
30
+ if ( LightupHelpers . SupportsCSharp72 )
31
+ {
32
+ yield return new [ ] { "in" } ;
33
+ }
34
+ }
35
+ }
36
+
22
37
[ Fact ]
23
38
public async Task TestFixedExampleAsync ( )
24
39
{
@@ -213,5 +228,33 @@ private void Method1(int x, int y)
213
228
214
229
await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
215
230
}
231
+
232
+ [ Theory ]
233
+ [ MemberData ( nameof ( ParameterModifiers ) ) ]
234
+ [ WorkItem ( 3817 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3817" ) ]
235
+ public async Task TestParameterModifierFirstOnLineAsync ( string keyword )
236
+ {
237
+ string testCode = $@ "
238
+ /// <summary>
239
+ /// Description of some remarks that refer to a method: <see cref=""SomeMethod(int, int,
240
+ /// { keyword } string)""/>.
241
+ /// </summary>
242
+ public class TypeName
243
+ {{
244
+ public void SomeMethod(int x, int y, { keyword } string z)
245
+ {{
246
+ throw new System.Exception();
247
+ }}
248
+ }}" ;
249
+
250
+ var languageVersion = ( LightupHelpers . SupportsCSharp8 , LightupHelpers . SupportsCSharp72 ) switch
251
+ {
252
+ // Make sure to use C# 7.2 if supported, unless we are going to default to something greater
253
+ ( false , true ) => LanguageVersionEx . CSharp7_2 ,
254
+ _ => ( LanguageVersion ? ) null ,
255
+ } ;
256
+
257
+ await VerifyCSharpDiagnosticAsync ( languageVersion , testCode , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
258
+ }
216
259
}
217
260
}
0 commit comments