Repository navigation
Commit ec22810
Fixes #97.
## The bug
`CommentsHelper.ConvertDocComment` split Javadoc content on
`Environment.NewLine`:
```csharp
comment.getContent().Split([Environment.NewLine], StringSplitOptions.None)
```
JavaParser's `getContent()` preserves the line endings of the **parsed
file**, which are independent of the **host OS**. I confirmed this with
a throwaway probe: CRLF source yields content with 3 CRs, LF-only source
yields 0.
So when the two disagree — most commonly a Unix-line-ending file
converted on Windows, which is exactly what the reporter narrowed it
down to — the content stays one unsplit line, the per-line regex never
matches, and the Javadoc is dropped from the output entirely.
Single-line `/** ... */` comments were unaffected because they contain
no newline to split on. That's why the bug appeared specific to
multi-line Javadoc.
## Verification
Rather than assume, I reproduced it: on unmodified `master`, patching
the split to `"\r\n"` (simulating a Windows host) makes the new tests
fail with the Javadoc **completely absent** — no `<summary>`, no
`<param>`. With the fix, all cases pass.
## The change
- Added `SplitLines()`, which normalizes line endings before splitting,
and applied it to the three places that split text originating from the
Java source. `FormatAsBlockComment` already did this correctly by hand
and now shares the helper.
- Added `NormalizeLineEndings()` on the raw comment-trivia paths so
comment content adopts the generated file's line endings instead of
leaking the Java file's, consistent with the existing
`Whitespace.NewLine` convention.
- The remaining `Environment.NewLine` uses are all on the **output**
side — including `AdjustBlockCommentIndentation`, which splits trivia we
generate ourselves — and are correct as-is. Only the input-side splits
were platform-sensitive.
## Tests
Two new theories in `CommentTests.cs`, each run against both `\n` and
`\r\n` input.
Worth flagging: there was previously **no test anywhere** asserting
Javadoc → `<summary>`/`<param>`/`<returns>`/`<exception>` output — every
other suite sets `IncludeComments = false`, so that path was entirely
uncovered. These tests close that gap as well.
Full suite: 382/382 passing, 0 build warnings.
## Out of scope
Two pre-existing issues I noticed and left alone, each confirmed to
reproduce on `master` independently of this change:
- Generated output has mixed line endings because Roslyn's
`NormalizeWhitespace()` emits `\r\n` regardless of platform — this
happens even for a file containing no comments.
- The CLI's `file` mode ignored the package declaration and dropped the
type for one of my test inputs.
Happy to look into either separately.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 539f413 commit ec22810
2 files changed
Lines changed: 100 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
244 | 326 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
142 | 155 | | |
143 | 156 | | |
144 | | - | |
145 | | - | |
| 157 | + | |
146 | 158 | | |
147 | 159 | | |
148 | 160 | | |
| |||
293 | 305 | | |
294 | 306 | | |
295 | 307 | | |
296 | | - | |
| 308 | + | |
297 | 309 | | |
298 | 310 | | |
299 | 311 | | |
| |||
318 | 330 | | |
319 | 331 | | |
320 | 332 | | |
321 | | - | |
| 333 | + | |
322 | 334 | | |
323 | 335 | | |
324 | 336 | | |
| |||
0 commit comments