-
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
Partial properties: public API and IDE features #73603
Changes from all commits
b801092
7079e74
b148d3f
8bf8b4d
90e9e4c
f588b1d
cbbe293
ab00963
eddd6f9
2cb66a9
d400efa
1ddc59e
5f82d34
3222d83
bccb280
c0a3817
ea84944
d29b205
5fc7fc9
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 |
---|---|---|
|
@@ -1799,10 +1799,14 @@ private Symbol GetDeclaredMember(NamespaceOrTypeSymbol container, TextSpan decla | |
zeroWidthMatch = symbol; | ||
} | ||
|
||
// Handle the case of the implementation of a partial method. | ||
var partial = symbol.Kind == SymbolKind.Method | ||
? ((MethodSymbol)symbol).PartialImplementationPart | ||
: null; | ||
// Handle the case of the implementation of a partial member. | ||
Symbol partial = symbol switch | ||
{ | ||
MethodSymbol method => method.PartialImplementationPart, | ||
SourcePropertySymbol property => property.PartialImplementationPart, | ||
_ => null | ||
}; | ||
|
||
if ((object)partial != null) | ||
{ | ||
var loc = partial.GetFirstLocation(); | ||
|
@@ -2033,9 +2037,7 @@ private ParameterSymbol GetMethodParameterSymbol( | |
return null; | ||
} | ||
|
||
return | ||
GetParameterSymbol(method.Parameters, parameter, cancellationToken) ?? | ||
((object)method.PartialDefinitionPart == null ? null : GetParameterSymbol(method.PartialDefinitionPart.Parameters, parameter, cancellationToken)); | ||
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 believe this check of 'PartialDefinitionPart' did not make sense. The containing method We should expect that |
||
return GetParameterSymbol(method.Parameters, parameter, cancellationToken); | ||
} | ||
|
||
private ParameterSymbol GetIndexerParameterSymbol( | ||
|
@@ -2127,11 +2129,8 @@ private ParameterSymbol GetDelegateParameterSymbol( | |
} | ||
|
||
/// <summary> | ||
/// Given a type parameter declaration (field or method), get the corresponding symbol | ||
/// Given a type parameter declaration (on a type or method), get the corresponding symbol | ||
/// </summary> | ||
/// <param name="typeParameter"></param> | ||
/// <param name="cancellationToken">The cancellation token.</param> | ||
/// <returns></returns> | ||
public override ITypeParameterSymbol GetDeclaredSymbol(TypeParameterSyntax typeParameter, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
if (typeParameter == null) | ||
|
@@ -2165,10 +2164,7 @@ private ParameterSymbol GetDelegateParameterSymbol( | |
return this.GetTypeParameterSymbol(typeSymbol.TypeParameters, typeParameter).GetPublicSymbol(); | ||
|
||
case MethodSymbol methodSymbol: | ||
return (this.GetTypeParameterSymbol(methodSymbol.TypeParameters, typeParameter) ?? | ||
((object)methodSymbol.PartialDefinitionPart == null | ||
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 think this check didn't make sense for the same reason as #73603 (comment). |
||
? null | ||
: this.GetTypeParameterSymbol(methodSymbol.PartialDefinitionPart.TypeParameters, typeParameter))).GetPublicSymbol(); | ||
return this.GetTypeParameterSymbol(methodSymbol.TypeParameters, typeParameter).GetPublicSymbol(); | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,5 +110,22 @@ public interface IPropertySymbol : ISymbol | |
/// The list of custom modifiers, if any, associated with the type of the property. | ||
/// </summary> | ||
ImmutableArray<CustomModifier> TypeCustomModifiers { get; } | ||
|
||
/// <summary> | ||
/// If this is a partial property implementation part, returns the corresponding | ||
/// definition part. Otherwise null. | ||
/// </summary> | ||
IPropertySymbol? PartialDefinitionPart { get; } | ||
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. Looking at the usages of the existing public APIs for partial methods, I feel there are more IDE scenario and potentially EnC scenarios that will need to be adjusted for partial properties/indexers. Are those known/understood? 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. IDE scenarios outside of hte min-bar are entirely optional to change. |
||
|
||
/// <summary> | ||
/// If this is a partial property definition part, returns the corresponding | ||
/// implementation part. Otherwise null. | ||
/// </summary> | ||
IPropertySymbol? PartialImplementationPart { get; } | ||
|
||
/// <summary> | ||
/// Returns true if this is a partial definition part. Otherwise false. | ||
/// </summary> | ||
bool IsPartialDefinition { get; } | ||
} | ||
} |
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.
This PR includes some tests for
GetDeclaredSymbol
public API. Do we have tests forGetDeclaredSymbol
on the parameters of a partial indexer?It looks like there is additional logic in this file that looks at
PartialDefinitionPart
for partial methods for that scenario, which might need to be updated to account for partial properties. #ResolvedThere 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 have addressed the remaining usages of PartialDefinition/ImplementationPart in this file.
There is one other usage of PartialDefinitionPart which doesn't need to account for properties, because it is for a method type parameter scenario, and properties don't have type parameters.