Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions CodeBlocker.Test/DocCommentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,37 @@ public void ValidationReportsADuplicateTag()
Assert.Contains("more than once", issues[0]);
}

[TestMethod]
public void ValidationReportsADuplicateUndeclaredTagOnce()
{
DocComment documentation = new();
documentation.Params.Add(new DocTag { Name = "y", Text = "First." });
documentation.Params.Add(new DocTag { Name = "y", Text = "Again." });
documentation.Params.Add(new DocTag { Name = "y", Text = "Third." });

IReadOnlyList<string> issues = documentation.Validate(["x"], []);

Assert.HasCount(4, issues);
Assert.AreEqual("<param name=\"y\"> does not match any declared parameter.", issues[0]);
Assert.AreEqual("<param name=\"y\"> is documented more than once.", issues[1]);
Assert.AreEqual("<param name=\"y\"> is documented more than once.", issues[2]);
Assert.AreEqual("The parameter 'x' has no <param> entry.", issues[3]);
}

[TestMethod]
public void ValidationReportsADuplicateUndeclaredTypeParameterTagOnce()
{
DocComment documentation = new();
documentation.TypeParams.Add(new DocTag { Name = "U", Text = "First." });
documentation.TypeParams.Add(new DocTag { Name = "U", Text = "Again." });

IReadOnlyList<string> issues = documentation.Validate([], []);

Assert.HasCount(2, issues);
Assert.AreEqual("<typeparam name=\"U\"> does not match any declared type parameter.", issues[0]);
Assert.AreEqual("<typeparam name=\"U\"> is documented more than once.", issues[1]);
}

[TestMethod]
public void ANamedTagWithEmptyTextIsStillWritten()
{
Expand Down
3 changes: 1 addition & 2 deletions CodeBlocker/Templates/DocComment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ void Check(Collection<DocTag> tags, HashSet<string> declared, string tagName, st
{
issues.Add($"<{tagName} name=\"{name}\"> is documented more than once.");
}

if (!declared.Contains(name))
else if (!declared.Contains(name))
{
issues.Add($"<{tagName} name=\"{name}\"> does not match any declared {what}.");
}
Expand Down
Loading