Repository navigation
Refuse a line break in a doc comment cref or name before writing [patch] - #160
Open
matt-edmondson wants to merge 1 commit into
Open
matt-edmondson wants to merge 1 commit into
matt-edmondson wants to merge 1 commit into
Conversation
A line terminator in InheritDocCref, a SeeAlso entry, or the Name of a param, typeparam or exception DocTag ended the /// comment mid-attribute and left the rest compiled as code. DocComment.WriteTo now checks every attribute value first and throws ArgumentException, so nothing is written. Fixes #159 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW3C2EQ5hMiLw63t4Aa
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #159
What changed
DocComment.WriteTochecks every attribute value before it writes the first///line. The values checked areInheritDocCref(whenInheritDocis set), eachSeeAlsoentry, and theNameof eachTypeParams,ParamsandExceptionsentry. If any value contains a line terminator fromLineTerminators(LF, CR, NEL, U+2028, U+2029), it throwsArgumentExceptionand writes nothing. That is the same ruleRegionScopeapplies to a multi-line region name.Rejecting was the option the issue suggested. A cref or a parameter name that contains a line break is never valid, so encoding it as
would only move the error from the generated file to the compiler's cref resolution.DocComment.WriteTois the first thingTemplateBase.WriteTowrites. So a template whose documentation is rejected leaves no half-written declaration behind.Tests
ALineBreakInAnAttributeValueIsRejectedBeforeWritingruns once per terminator (LF, CRLF, CR, NEL, U+2028, U+2029). For each one it coversSeeAlso,InheritDocCref, aparam, atypeparamand anexceptionDocTag.Name, and asserts that the output stays empty.AnUnusedInheritDocCrefIsNotCheckedcovers a cref that is set whileInheritDocis off. It is ignored, as the property documents, so it is not rejected.Generated by Claude Code