Skip to content
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

Merged
merged 3 commits into from
Feb 2, 2022

Conversation

RikkiGibson
Copy link
Contributor

@RikkiGibson RikkiGibson commented Jan 20, 2022

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:

  • whitespaces which shouldn't be included in the output XML document are trivia on XML nodes.
  • whitespaces which should be included in the output XML document are contained in XML text nodes.

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.

@RikkiGibson RikkiGibson marked this pull request as ready for review January 27, 2022 00:12
@RikkiGibson RikkiGibson requested review from a team as code owners January 27, 2022 00:12
{
if (attribute is XmlNameAttributeSyntax nameAttribute
&& nameAttribute.GetElementKind() == XmlNameAttributeElementKind.Parameter
&& string.Equals(nameAttribute.Identifier.Identifier.ValueText, recordPropertySymbol.Name, StringComparison.Ordinal))
Copy link
Contributor Author

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());
Copy link
Member

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], "/**"));
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getMatchingParamTags()

nit: consider making getMatchingParamTags static and passing the relevant state explicitly (docCommentNodes and the property's name?)

Copy link
Member

@jcouv jcouv left a 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)

Copy link
Member

@jcouv jcouv left a 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)

@RikkiGibson RikkiGibson merged commit be7b1a3 into dotnet:main Feb 2, 2022
@ghost ghost added this to the Next milestone Feb 2, 2022
@RikkiGibson RikkiGibson deleted the record-xml branch February 2, 2022 21:38
@RikkiGibson RikkiGibson modified the milestones: Next, 17.2.P1 Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

XML Documents for Positional Records
4 participants