-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue with disappearing newlines after multiline documentation comment #77521
base: main
Are you sure you want to change the base?
Fix issue with disappearing newlines after multiline documentation comment #77521
Conversation
@dotnet-policy-service agree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small comment, otherwise LGTM.
@dgounaris can you update your comment to specifically say "fixes |
@333fred Thanks for the review, addressed the comments, feel free to have a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dotnet/roslyn-compiler for a second review
This PR fixes #76856, where multi-line doc comments ending in a newline would have the newline disappearing afterwards.
Based on my investigation, the situation can be described as follows:
RewriteTrivia
skips newline tokens.NeedsLineBreakAfter
call can't be the target for this fix, because not every comment needs a new line after it. Wider context is needed.EndsInLineBreak
can be true for the doc token in cases where in reality the documentation end token is the ending token, due to the 0 width of theEndOfDocumentationCommentToken
type.The proposed fix adds a linebreak if the leading SyntaxToken is a multiline documentation ending in linebreak, and forces it to be retained during rewriting by slightly modifying
EndsInLineBreak
too.As this is my first time contributing, let me know if I have not grasped the codebase correctly and there is a cleaner way to apply this.