Skip to content

Commit deb537b

Browse files
peterisharwell
authored andcommitted
De-"Foo"ied test code, changed name from emptyElement to element, changed to use casts instead of as statements, wrapped parameter for string format in single quotes.
1 parent 059f4c4 commit deb537b

2 files changed

Lines changed: 33 additions & 33 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1627UnitTests.cs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,50 +38,50 @@ public async Task TestMemberWithBlankElementAsync(string element)
3838
{
3939
var testCode = @"
4040
/// <summary>
41-
/// Foo
41+
/// Class name.
4242
/// </summary>
4343
public class ClassName
4444
{
4545
/// <summary>
46-
/// Foo
46+
/// Join together two strings.
4747
/// </summary>
48-
///<param name=""foo"">Test</param>
49-
///<param name=""bar"">Test</param>
48+
///<param name=""first"">First string.</param>
49+
///<param name=""second"">Second string.</param>
5050
/// <$$> </$$>
51-
public ClassName Method(string foo, string bar) { return null; }
51+
public string JoinStrings(string first, string second) { return first + second; }
5252
}";
5353
var expectedDiagnostic = this.CSharpDiagnostic().WithLocation(12, 9).WithArguments(element);
5454
await this.VerifyCSharpDiagnosticAsync(testCode.Replace("$$", element), expectedDiagnostic, CancellationToken.None).ConfigureAwait(false);
5555
}
5656

5757
/// <summary>
58-
/// Checks an element with a blank value gives an error.
58+
/// Checks an element with a multiple blank values give multiple errors.
5959
/// </summary>
6060
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
6161
[Fact]
6262
public async Task TestMemberWithMultipleBlankElementsAsync()
6363
{
6464
var testCode = @"
6565
/// <summary>
66-
/// Foo
66+
/// Class name.
6767
/// </summary>
6868
public class ClassName
6969
{
7070
/// <summary>
71-
/// Foo
71+
/// Join together two strings.
7272
/// </summary>
73-
///<param name=""foo"">Test</param>
74-
///<param name=""bar"">Test</param>
75-
/// <remarks>Foo bar</remarks>
73+
///<param name=""first"">First string.</param>
74+
///<param name=""second"">Second string.</param>
75+
/// <remarks>Single line remark.</remarks>
7676
/// <example></example>
7777
/// <exception>
7878
///
7979
/// </exception>
8080
/// <permission>
81-
/// Multi line notes
82-
/// Multi line notes
81+
/// Multi line notes.
82+
/// Multi line notes.
8383
/// </permission>
84-
public ClassName Method(string foo, string bar) { return null; }
84+
public string JoinStrings(string first, string second) { return first + second; }
8585
}";
8686
var expectedDiagnostics = new[]
8787
{
@@ -102,17 +102,17 @@ public async Task TestMemberWithEmptyElementAsync(string element)
102102
{
103103
var testCode = @"
104104
/// <summary>
105-
/// Foo
105+
/// Class name.
106106
/// </summary>
107107
public class ClassName
108108
{
109109
/// <summary>
110-
/// Foo
110+
/// Join together two strings.
111111
/// </summary>
112-
///<param name=""foo"">Test</param>
113-
///<param name=""bar"">Test</param>
112+
///<param name=""first"">First string.</param>
113+
///<param name=""second"">Second string.</param>
114114
/// <$$ />
115-
public ClassName Method(string foo, string bar) { return null; }
115+
public string JoinStrings(string first, string second) { return first + second; }
116116
}";
117117
var expectedDiagnostic = this.CSharpDiagnostic().WithLocation(12, 9).WithArguments(element);
118118
await this.VerifyCSharpDiagnosticAsync(testCode.Replace("$$", element), expectedDiagnostic, CancellationToken.None).ConfigureAwait(false);
@@ -129,17 +129,17 @@ public async Task TestMemberWithValidElementAsync(string element)
129129
{
130130
var testCode = @"
131131
/// <summary>
132-
/// Foo
132+
/// Class name.
133133
/// </summary>
134134
public class ClassName
135135
{
136136
/// <summary>
137-
/// Foo
137+
/// Join together two strings.
138138
/// </summary>
139-
///<param name=""foo"">Test</param>
140-
///<param name=""bar"">Test</param>
141-
/// <$$>FooBar</$$>
142-
public ClassName Method(string foo, string bar) { return null; }
139+
///<param name=""first"">First string.</param>
140+
///<param name=""second"">Second string.</param>
141+
/// <$$>Not blank element.</$$>
142+
public string JoinStrings(string first, string second) { return first + second; }
143143
}";
144144
await this.VerifyCSharpDiagnosticAsync(testCode.Replace("$$", element), EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
145145
}

StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1627DocumentationTextMustNotBeEmpty.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ internal class SA1627DocumentationTextMustNotBeEmpty : DiagnosticAnalyzer
4747
/// </summary>
4848
public const string DiagnosticId = "SA1627";
4949
private const string Title = "Documentation text must not be empty";
50-
private const string MessageFormat = "The documentation text within the {0} tag must not be empty.";
50+
private const string MessageFormat = "The documentation text within the \'{0}\' tag must not be empty.";
5151
private const string Description = "The XML header documentation for a C# code element contains an empty tag.";
5252
private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1627.md";
5353

@@ -80,23 +80,23 @@ private static void HandleCompilationStart(CompilationStartAnalysisContext conte
8080

8181
private static void HandleXmlElement(SyntaxNodeAnalysisContext context)
8282
{
83-
XmlElementSyntax emptyElement = context.Node as XmlElementSyntax;
83+
var element = (XmlElementSyntax)context.Node;
8484

85-
var name = emptyElement?.StartTag?.Name;
85+
var name = element.StartTag?.Name;
8686

87-
if (elementsToCheck.Contains(name.ToString()) && XmlCommentHelper.IsConsideredEmpty(emptyElement))
87+
if (elementsToCheck.Contains(name.ToString()) && XmlCommentHelper.IsConsideredEmpty(element))
8888
{
89-
context.ReportDiagnostic(Diagnostic.Create(Descriptor, emptyElement.GetLocation(), name.ToString()));
89+
context.ReportDiagnostic(Diagnostic.Create(Descriptor, element.GetLocation(), name.ToString()));
9090
}
9191
}
9292

9393
private static void HandleXmlEmptyElement(SyntaxNodeAnalysisContext context)
9494
{
95-
XmlEmptyElementSyntax emptyElement = context.Node as XmlEmptyElementSyntax;
95+
var element = (XmlEmptyElementSyntax)context.Node;
9696

97-
if (elementsToCheck.Contains(emptyElement?.Name.ToString()))
97+
if (elementsToCheck.Contains(element.Name.ToString()))
9898
{
99-
context.ReportDiagnostic(Diagnostic.Create(Descriptor, emptyElement.GetLocation(), emptyElement?.Name.ToString()));
99+
context.ReportDiagnostic(Diagnostic.Create(Descriptor, element.GetLocation(), element.Name.ToString()));
100100
}
101101
}
102102
}

0 commit comments

Comments
 (0)