What's wrong
DocComment.WriteElement (CodeBlocker/Templates/DocComment.cs ~186-189) returns without writing anything when the element text is null or empty. That is fine for summary/returns/value/remarks, but it also applies to the named tags param, typeparam and exception. Meanwhile:
Validate(parameterNames, typeParameterNames) (~161-180) only compares names. A DocTag { Name = "b", Text = "" } counts as documenting b, so validation passes.
IsEmpty (~80-90) counts Params.Count/TypeParams.Count, so a comment holding only an empty-text param reports IsEmpty == false but writes nothing.
Repro (reproduced with MSTest)
var doc = new DocComment { Summary = "S" };
doc.Params.Add(new DocTag { Name = "a", Text = "A" });
doc.Params.Add(new DocTag { Name = "b", Text = "" });
doc.Validate(["a", "b"], []); // 0 issues
doc.WriteTo(codeBlocker);
Output:
/// <summary>S</summary>
/// <param name="a">A</param>
b has no <param> tag. When compiled, the generated method void M(int a, int b) gets CS1573 ("Parameter 'b' has no matching param tag in the XML comment"). Under TreatWarningsAsErrors, which the ktsu SDK enables, that is a build break. The generator author was told by Validate that the comment was complete.
Suggested fix / acceptance criteria
- Always write tags that carry a
name/cref attribute (param, typeparam, exception), even with empty text, e.g. /// <param name="b"></param>. Keep the empty-skip only for summary, returns, value and remarks.
- Make
IsEmpty agree with what WriteTo actually emits.
- Alternatively, if empty tags should stay suppressed,
Validate must report The parameter 'b' has no <param> entry. for an empty-text entry.
- Add a regression test for the case above.
What's wrong
DocComment.WriteElement(CodeBlocker/Templates/DocComment.cs~186-189) returns without writing anything when the element text is null or empty. That is fine forsummary/returns/value/remarks, but it also applies to the named tagsparam,typeparamandexception. Meanwhile:Validate(parameterNames, typeParameterNames)(~161-180) only compares names. ADocTag { Name = "b", Text = "" }counts as documentingb, so validation passes.IsEmpty(~80-90) countsParams.Count/TypeParams.Count, so a comment holding only an empty-text param reportsIsEmpty == falsebut writes nothing.Repro (reproduced with MSTest)
Output:
bhas no<param>tag. When compiled, the generated methodvoid M(int a, int b)gets CS1573 ("Parameter 'b' has no matching param tag in the XML comment"). UnderTreatWarningsAsErrors, which the ktsu SDK enables, that is a build break. The generator author was told byValidatethat the comment was complete.Suggested fix / acceptance criteria
name/crefattribute (param,typeparam,exception), even with empty text, e.g./// <param name="b"></param>. Keep the empty-skip only forsummary,returns,valueandremarks.IsEmptyagree with whatWriteToactually emits.Validatemust reportThe parameter 'b' has no <param> entry.for an empty-text entry.