-
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
Use record param docs as property summary docs #58960
Conversation
c78fed4
to
77dca02
Compare
77dca02
to
6b37199
Compare
...ompilers/CSharp/Portable/Compiler/DocumentationCommentCompiler.DocumentationCommentWalker.cs
Outdated
Show resolved
Hide resolved
...ompilers/CSharp/Portable/Compiler/DocumentationCommentCompiler.DocumentationCommentWalker.cs
Outdated
Show resolved
Hide resolved
{ | ||
if (attribute is XmlNameAttributeSyntax nameAttribute | ||
&& nameAttribute.GetElementKind() == XmlNameAttributeElementKind.Parameter | ||
&& string.Equals(nameAttribute.Identifier.Identifier.ValueText, recordPropertySymbol.Name, StringComparison.Ordinal)) |
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.
We could consider actually binding the attribute value and comparing the resulting symbol with the record property symbol, but it doesn't seem necessary.
@"<member name=""P:C.I1""> | ||
<summary>Description for I1</summary> | ||
</member> | ||
", property.GetDocumentationCommentXml()); |
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.
Could you update the test below (XmlDoc_Cref
) to check the doc on generated property too?
More cases of references (cref/seealso/...) would be good to cover, if we don't have it already: one parameter/property referencing another parameter/property.
@@ -706,7 +777,6 @@ private string FormatComment(string substitutedText) | |||
Debug.Assert(numLines > 0); | |||
} | |||
|
|||
Debug.Assert(TrimmedStringStartsWith(lines[0], "/**")); |
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.
nit: Consider adding a comment to replace the assertion (we may have /**
or a positional property case)
{ | ||
_cancellationToken.ThrowIfCancellationRequested(); | ||
|
||
if (getMatchingParamTags() is not { } paramTags) |
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.
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.
Done with review pass (iteration 2)
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.
LGTM Thanks (iteration 3)
Closes #52663
This solution works by modifying the processing stage where crefs are replaced with doc comment IDs.
It requires some changes to the subsequent 'FormatComment' step which removes
///
,/**
and similar exterior trivia, and adjusts the indenting of the comments to match the output XML file. Specifically, make a change to make this layer more tolerant of "fragments" of/** */
multi-line comments.In the medium or long term, I'd actually like to eliminate or vastly simplify the 'FormatComment' stage by modifying the initial parsing stage of XML comments. Ideally, we would have an invariant where:
Then I think we could write the XML to the documentation stream in one pass, simply replacing cref nodes with doc comment IDs as we go and inserting the appropriate amount of indentation immediately following each XmlNewLineToken.