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 method body made only of a /* block comment */ is written as no body: void M() /* nothing to do */ (CS1002), unlike the // form fixed in #157 #185
newMethodTemplate{Type="void",Name="M",BodyFactory= b =>b.WriteLine("/* nothing to do */")}
This renders as:
voidM()/* nothing to do */
That fails with CS1002 (; expected). The same body written as // nothing to do has rendered correctly since #157/#161:
voidM(){// nothing to do}
Reproduced against main @ aa7ca53. Constructor and operator bodies take the same path.
Why
HasCode / IsCode (CodeBlocker/Templates/TemplateRendering.cs:454-483) treat as "not code" only // comments (found by VerbatimStringScanner.FindLineComments) and # directives. A block comment counts as code, so a one-line fragment takes the single-line branch at :311-316 and is placed on the declaration line as if it were an expression body.
Suggested fix
Have the scanner also report /* … */ spans, honouring strings and verbatim strings the way it does for //. Then treat a line that is only a block comment as not code in HasCode. That also closes the /* … */ variant of the comment-only expression-body issue.
Acceptance criteria
A BodyFactory that writes only /* … */, on one line or several, renders a braced body that compiles.
A body that writes /* note */ return 1; still counts as code and renders as it does today.
/* inside a string literal is not read as a comment.
Activity
matt-edmondson commentedon Nov 5, 2026
Triage
//form. The fix also closes the/* */variant of An expression body that writes only a comment or directives still rendersint P => ;// TODO(CS1525): the #175 guard checks only for blank lines #184.VerbatimStringScanner(it needs to report block-comment spans) andTemplateRendering.HasCode/IsCodeint P => ;// TODO(CS1525): the #175 guard checks only for blank lines #184. No open PR covers it. Open PR Drop the blank lines around a braced member body [patch] #182 changesWriteBody's comment-only path, so rebase onto it once it merges.Generated by Claude Code