You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A class whose member has an invalid doc comment (a line break in a param/see-also name) is still written up to that member, then throws (#164 again, through DocComment) #188
ClassTemplate.Validate is meant to refuse a bad class before any of it is written (#169). It checks the kind, the members and the nested classes, but none of the doc comments:
The doc-comment checks (EnsureAttributesFitOnOneLine, Templates/DocComment.cs around lines 111 and 192-223) run only inside DocComment.WriteTo, so a bad doc comment fails partway through writing the class.
Reproduction
Inside one class. A class has members A and B, and B.Documentation.Params contains a name with a line break ("a\nb"). AddClass throws ArgumentException after the CodeBlocker already holds:
public class C
{
void A() { }
}
The output has a closing brace but has lost B and everything after it.
Across a source file.AddSourceFile with two classes, where the second class's Documentation.SeeAlso contains "A\nB". It throws after writing the namespace, the usings and all of class First. SourceFileTemplate validates every template up front (SourceFileTemplate.cs around line 62) precisely to avoid this kind of partial output.
This is distinct from #183 (an empty expression body) and #176 (a BodyFactory that throws).
Suggested fix / acceptance criteria
Move the doc-comment checks into a Validate that runs before writing. Call it from TemplateBase.Validate for the template's own Documentation, so ClassTemplate.Validate covers the class itself, every member and every nested class.
Add tests: both cases above throw ArgumentException and leave the CodeBlocker's output unchanged (empty, or exactly what it held before the call).
Category: Bug Priority: Medium. It produces partial output and then throws, which is exactly what #169's up-front validation and SourceFileTemplate's pre-check were meant to prevent. It needs malformed doc-comment input (a line break in a param or see-also name), so typical callers won't hit it.
Area / suggested assignment:Templates/DocComment.cs and TemplateBase.Validate, with ClassTemplate.Validate and SourceFileTemplate as callers. This is the "check before writing" series.
Next steps: Extract EnsureAttributesFitOnOneLine and the related checks into DocComment.Validate(). Call it from TemplateBase.Validate, so class, member and nested-class validation all cover it. Add the two "output unchanged" tests.
Activity
matt-edmondson commentedon Nov 5, 2026
Triage
Category: Bug
Priority: Medium. It produces partial output and then throws, which is exactly what #169's up-front validation and
SourceFileTemplate's pre-check were meant to prevent. It needs malformed doc-comment input (a line break in a param or see-also name), so typical callers won't hit it.Area / suggested assignment:
Templates/DocComment.csandTemplateBase.Validate, withClassTemplate.ValidateandSourceFileTemplateas callers. This is the "check before writing" series.Duplicates / in progress
public void M()}#176 (a throwingBodyFactory).int P => ;// TODO(CS1525): the #175 guard checks only for blank lines #184) moves expression-body checks into validation and probably edits the sameValidatechain. Land it first, then add the doc-comment pass on top.public void M()}#176 is also open and restructuresClassTemplate.WriteTo(it is waiting on PR Drop the blank lines around a braced member body [patch] #182). Keep this change confined toValidateso it doesn't collide with that work.Next steps: Extract
EnsureAttributesFitOnOneLineand the related checks intoDocComment.Validate(). Call it fromTemplateBase.Validate, so class, member and nested-class validation all cover it. Add the two "output unchanged" tests.Generated by Claude Code