Skip to content

Commit 87291ce

Browse files
committed
Add tests for additional edge cases
1 parent 214167f commit 87291ce

File tree

2 files changed

+36
-11
lines changed

2 files changed

+36
-11
lines changed

DocumentationAnalyzers/DocumentationAnalyzers.Test/PortabilityRules/DOC207UnitTests.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,40 @@ public async Task TestEmptyAndFullElementsValidatedAsync()
8383
class TestClass
8484
{
8585
}
86+
";
87+
88+
await Verify.VerifyAnalyzerAsync(testCode);
89+
}
90+
91+
[Fact]
92+
public async Task TestOtherAttributesIgnoredAsync()
93+
{
94+
var testCode = @"
95+
/// <summary>
96+
/// <see Langword=""not a keyword""/>
97+
/// <see x:langword=""not a keyword""/>
98+
/// <see name=""not a keyword""/>
99+
/// <see cref=""System.String""/>
100+
/// </summary>
101+
class TestClass
102+
{
103+
}
104+
";
105+
106+
await Verify.VerifyAnalyzerAsync(testCode);
107+
}
108+
109+
[Fact]
110+
public async Task TestOtherElementsIgnoredAsync()
111+
{
112+
var testCode = @"
113+
/// <summary>
114+
/// <p:see langword=""not a keyword""/>
115+
/// </summary>
116+
///
117+
class TestClass
118+
{
119+
}
86120
";
87121

88122
await Verify.VerifyAnalyzerAsync(testCode);

DocumentationAnalyzers/DocumentationAnalyzers/PortabilityRules/DOC207UseSeeLangwordCorrectly.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,9 @@ private static void HandleXmlNodeSyntax(SyntaxNodeAnalysisContext context)
5959
{
6060
attributes = xmlEmptyElement.Attributes;
6161
}
62-
else if (xmlNodeSyntax is XmlElementSyntax xmlElement)
63-
{
64-
attributes = xmlElement.StartTag.Attributes;
65-
}
6662
else
6763
{
68-
return;
64+
attributes = ((XmlElementSyntax)xmlNodeSyntax).StartTag.Attributes;
6965
}
7066

7167
foreach (var attribute in attributes)
@@ -80,12 +76,7 @@ private static void HandleXmlNodeSyntax(SyntaxNodeAnalysisContext context)
8076
continue;
8177
}
8278

83-
if (!(attribute is XmlTextAttributeSyntax xmlTextAttribute))
84-
{
85-
continue;
86-
}
87-
88-
var text = xmlTextAttribute.TextTokens;
79+
var text = ((XmlTextAttributeSyntax)attribute).TextTokens;
8980
string valueText;
9081
if (text.Count == 1)
9182
{

0 commit comments

Comments
 (0)