Skip to content

Commit b97e869

Browse files
committed
Update SA1615 for partial methods
1 parent ef88138 commit b97e869

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1615CSharp9UnitTests.cs

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

44
namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules
55
{
6+
using System.Threading;
7+
using System.Threading.Tasks;
68
using StyleCop.Analyzers.Test.CSharp8.DocumentationRules;
9+
using Xunit;
10+
using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier<StyleCop.Analyzers.DocumentationRules.SA1615ElementReturnValueMustBeDocumented>;
711

812
public partial class SA1615CSharp9UnitTests : SA1615CSharp8UnitTests
913
{
14+
[Fact]
15+
[WorkItem(3971, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3971")]
16+
public async Task TestPartialMethodDeclarationMissingReturnsDocumentationAsync()
17+
{
18+
var testCode = @"
19+
/// <summary>
20+
/// Tests a partial method.
21+
/// </summary>
22+
public partial class TestClass
23+
{
24+
/// <summary>Declaration.</summary>
25+
public partial {|#0:int|} TestMethod(int value);
26+
27+
public partial int TestMethod(int value) => value;
28+
}";
29+
30+
var expected = Diagnostic().WithLocation(0);
31+
32+
await VerifyCSharpDiagnosticAsync(testCode, new[] { expected }, CancellationToken.None).ConfigureAwait(false);
33+
}
1034
}
1135
}

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1615UnitTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,10 @@ internal class ClassName
340340
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
341341
}
342342

343-
private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken)
343+
protected static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken)
344344
=> VerifyCSharpFixAsync(source, new[] { expected }, fixedSource: null, cancellationToken);
345345

346-
private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken)
346+
protected static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken)
347347
=> VerifyCSharpFixAsync(source, expected, fixedSource: null, cancellationToken);
348348

349349
private static Task VerifyCSharpFixAsync(string source, DiagnosticResult expected, string fixedSource, CancellationToken cancellationToken)

0 commit comments

Comments
 (0)