-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Put record parameters in scope of xml docs #49134
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
Changes from all commits
5022bc2
de5e638
ffe4fda
1c7f178
14e6b96
2af5a82
38a249c
32b0bc3
7e373fe
76d7c1a
6ecb064
ecc1f93
61ab83b
1872663
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1132,14 +1132,26 @@ public override Binder VisitXmlNameAttribute(XmlNameAttributeSyntax parent) | |
/// </summary> | ||
private Binder GetParameterNameAttributeValueBinder(MemberDeclarationSyntax memberSyntax, Binder nextBinder) | ||
{ | ||
BaseMethodDeclarationSyntax baseMethodDeclSyntax = memberSyntax as BaseMethodDeclarationSyntax; | ||
if ((object)baseMethodDeclSyntax != null && baseMethodDeclSyntax.ParameterList.ParameterCount > 0) | ||
if (memberSyntax is BaseMethodDeclarationSyntax { ParameterList: { ParameterCount: > 0 } } baseMethodDeclSyntax) | ||
{ | ||
Binder outerBinder = VisitCore(memberSyntax.Parent); | ||
MethodSymbol method = GetMethodSymbol(baseMethodDeclSyntax, outerBinder); | ||
return new WithParametersBinder(method.Parameters, nextBinder); | ||
} | ||
|
||
if (memberSyntax is RecordDeclarationSyntax { ParameterList: { ParameterCount: > 0 } } recordDeclSyntax) | ||
{ | ||
Binder outerBinder = VisitCore(memberSyntax); | ||
SourceNamedTypeSymbol recordType = ((NamespaceOrTypeSymbol)outerBinder.ContainingMemberOrLambda).GetSourceTypeMember(recordDeclSyntax); | ||
var primaryConstructor = recordType.GetMembersUnordered().OfType<SynthesizedRecordConstructor>().SingleOrDefault(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Why will this be necessarily only one constructor? Doesn't the copy constructor count as a SynthesizedRecordConstructor? Consider leaving a comment. #ByDesign There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Records have exactly one SynthesizedRecordConstructor (it's the primary ctor). The copy constructor is either a source symbol or SynthesizedRecordCopyCtor. In reply to: 549877846 [](ancestors = 549877846) |
||
|
||
if (primaryConstructor.SyntaxRef.SyntaxTree == recordDeclSyntax.SyntaxTree && | ||
primaryConstructor.GetSyntax() == recordDeclSyntax) | ||
{ | ||
return new WithParametersBinder(primaryConstructor.Parameters, nextBinder); | ||
} | ||
} | ||
|
||
// As in Dev11, we do not allow <param name="value"> on events. | ||
SyntaxKind memberKind = memberSyntax.Kind(); | ||
if (memberKind == SyntaxKind.PropertyDeclaration || memberKind == SyntaxKind.IndexerDeclaration) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -377,7 +377,11 @@ public override void DefaultVisit(Symbol symbol) | |
|
||
private static bool ShouldSkip(Symbol symbol) | ||
{ | ||
return symbol.IsImplicitlyDeclared || symbol.IsAccessor() || symbol is SynthesizedSimpleProgramEntryPointSymbol || symbol is SimpleProgramNamedTypeSymbol; | ||
return symbol.IsImplicitlyDeclared || | ||
symbol.IsAccessor() || | ||
symbol is SynthesizedSimpleProgramEntryPointSymbol || | ||
symbol is SimpleProgramNamedTypeSymbol || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could (was suggested by Olivier earlier) but I think it reads better as-is. In reply to: 549878424 [](ancestors = 549878424) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean, I don't agree, but it's your call I guess. In reply to: 549984705 [](ancestors = 549984705,549878424) |
||
symbol is SynthesizedRecordPropertySymbol; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The line is getting very long, consider splitting it. #Closed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be reduced to
? |
||
|
||
/// <summary> | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
I think this method might not correspond to the parameters in this partial declaration. #Closed
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.
Added tests for partials.
We're basically taking the xml doc from the declaration that has the parameter list. That seems sensible. But we could also try to also find the xml doc on declaration without parameter list. What do you think?
In reply to: 517014473 [](ancestors = 517014473)
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.
I think that we should match doc-comment to the primary constructor only if both are on the same partial declaration
In reply to: 518320962 [](ancestors = 518320962,517014473)
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.
Note that only one partial declaration declares a primary constructor, parameter lists on other declarations are ignored and not analyzed, can have all kind of differences by comparison to each other.
In reply to: 518379208 [](ancestors = 518379208,518320962,517014473)
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.
Apparently my comment wasn't clear. Let me rephrase it. I think that here we should find primary constructor symbol only if it corresponds to memberSyntax. We shouldn't be using a symbol that is declared by a different partial declaration.
In reply to: 518380246 [](ancestors = 518380246,518379208,518320962,517014473)