Skip to content

Skip blank doc crefs and refuse null doc tags before writing [patch] - #211

Open
matt-edmondson wants to merge 1 commit into
mainfrom
fix/208-blank-crefs
Open

matt-edmondson wants to merge 1 commit into
mainfrom
fix/208-blank-crefs

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

DocComment wrote a whitespace InheritDocCref, a blank SeeAlso entry and a blank Exceptions[i].Name as cref="" or cref=" ". The compiler reports each of these as CS1584/CS1658. A null SeeAlso entry or DocTag threw a NullReferenceException partway through writing, which left the class without that member.

Changes

  • A whitespace InheritDocCref writes a bare <inheritdoc/>, the same as an empty one.
  • Null, empty or whitespace SeeAlso entries are skipped (through TemplateRendering.NonBlank), and so are Exceptions entries whose Name is null, empty or whitespace. IsEmpty counts only the entries that get written.
  • ValidateAttributes refuses a null DocTag in TypeParams, Params or Exceptions, and a param or typeparam with a null Name, by throwing ArgumentException before anything is written. This matches Refuse a null parameter, member or nested type before writing [patch] #199. A container's Validate already calls it, so the class is never left half written.

Tests

  • Blank crefs: no cref="" lines, and the non-blank entries are kept.
  • A comment that holds only blank crefs is IsEmpty and writes nothing.
  • A null SeeAlso entry inside a class renders the whole class.
  • Null tags and null param/typeparam names throw before any output, both from WriteTo and through AddClass.
  • All five tests fail on main and pass with the fix. Full suite: 382 passed, 0 failed.

Fixes #208


Generated by Claude Code

A whitespace InheritDocCref, a blank SeeAlso entry and a blank Exceptions name were
written as cref="" (CS1584). They are now skipped, and a whitespace InheritDocCref
writes a bare <inheritdoc/>. A null SeeAlso entry or exception name is skipped the
same way. A null DocTag, or a param/typeparam with a null name, is refused by
ValidateAttributes before anything is written, rather than throwing
NullReferenceException with the class half written.

Fixes #208

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW2P5xiJJTm9Z4wJwcH
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants