Skip to content

Commit 2a93406

Browse files
Update SA1004 to allow doc comments to start with the readonly keyword
#3817
1 parent a1909e0 commit 2a93406

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1004CSharp12UnitTests.cs

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

44
namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules
55
{
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
using Microsoft.CodeAnalysis.Testing;
69
using StyleCop.Analyzers.Test.CSharp11.SpacingRules;
10+
using Xunit;
11+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
12+
StyleCop.Analyzers.SpacingRules.SA1004DocumentationLinesMustBeginWithSingleSpace,
13+
StyleCop.Analyzers.SpacingRules.SA1004CodeFixProvider>;
714

815
public partial class SA1004CSharp12UnitTests : SA1004CSharp11UnitTests
916
{
17+
[Fact]
18+
[WorkItem(3817, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3817")]
19+
public async Task TestParameterModifierReadOnlyFirstOnLineAsync()
20+
{
21+
string testCode = $@"
22+
/// <summary>
23+
/// Description of some remarks that refer to a method: <see cref=""SomeMethod(int, int, ref
24+
/// readonly string)""/>.
25+
/// </summary>
26+
public class TypeName
27+
{{
28+
public void SomeMethod(int x, int y, ref readonly string z)
29+
{{
30+
throw new System.Exception();
31+
}}
32+
}}";
33+
34+
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
35+
}
1036
}
1137
}

StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1004DocumentationLinesMustBeginWithSingleSpace.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ private static void HandleDocumentationCommentExteriorTrivia(SyntaxTreeAnalysisC
113113
case SyntaxKind.InKeyword:
114114
case SyntaxKind.OutKeyword:
115115
case SyntaxKind.RefKeyword:
116+
case SyntaxKind.ReadOnlyKeyword:
116117
if (!token.HasLeadingTrivia)
117118
{
118119
break;

0 commit comments

Comments
 (0)