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 . SpacingRules
75{
6+ using System . Collections . Generic ;
87 using System . Threading ;
98 using System . Threading . Tasks ;
9+ using Microsoft . CodeAnalysis . CSharp ;
1010 using Microsoft . CodeAnalysis . Testing ;
11+ using StyleCop . Analyzers . Lightup ;
1112 using StyleCop . Analyzers . SpacingRules ;
1213 using Xunit ;
1314 using static StyleCop . Analyzers . Test . Verifiers . StyleCopCodeFixVerifier <
@@ -19,6 +20,20 @@ namespace StyleCop.Analyzers.Test.SpacingRules
1920 /// </summary>
2021 public class SA1004UnitTests
2122 {
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+
2237 [ Fact ]
2338 public async Task TestFixedExampleAsync ( )
2439 {
@@ -213,5 +228,33 @@ private void Method1(int x, int y)
213228
214229 await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
215230 }
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+ }
216259 }
217260}
0 commit comments