-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Address a few locations also need to care about partial properties #73792
Merged
Cosifne
merged 4 commits into
dotnet:features/partial-properties
from
Cosifne:dev/shech/HandlePartialProperires
May 31, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,18 +73,27 @@ private static ImmutableArray<RoslynNavigationBarItem> GetMembersInTypes( | |
continue; | ||
} | ||
|
||
var method = member as IMethodSymbol; | ||
if (method != null && method.PartialImplementationPart != null) | ||
if (member is IMethodSymbol { PartialImplementationPart: { } } methodSymbol) | ||
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. |
||
{ | ||
memberItems.AddIfNotNull(CreateItemForMember(solution, method, tree, cancellationToken)); | ||
memberItems.AddIfNotNull(CreateItemForMember(solution, method.PartialImplementationPart, tree, cancellationToken)); | ||
memberItems.AddIfNotNull(CreateItemForMember(solution, methodSymbol, tree, cancellationToken)); | ||
memberItems.AddIfNotNull(CreateItemForMember(solution, methodSymbol.PartialImplementationPart, tree, cancellationToken)); | ||
} | ||
else | ||
else if (member is IPropertySymbol { PartialImplementationPart: { } } propertySymbol) | ||
{ | ||
memberItems.AddIfNotNull(CreateItemForMember(solution, propertySymbol, tree, cancellationToken)); | ||
memberItems.AddIfNotNull(CreateItemForMember(solution, propertySymbol.PartialImplementationPart, tree, cancellationToken)); | ||
} | ||
else if (member is IMethodSymbol or IPropertySymbol) | ||
{ | ||
Debug.Assert(method == null || method.PartialDefinitionPart == null, "NavBar expected GetMembers to return partial method definition parts but the implementation part was returned."); | ||
Debug.Assert(member is IMethodSymbol { PartialDefinitionPart: null } or IPropertySymbol { PartialDefinitionPart: null }, | ||
$"NavBar expected GetMembers to return partial method/property definition parts but the implementation part was returned."); | ||
|
||
memberItems.AddIfNotNull(CreateItemForMember(solution, member, tree, cancellationToken)); | ||
} | ||
else | ||
{ | ||
memberItems.AddIfNotNull(CreateItemForMember(solution, member, tree, cancellationToken)); | ||
} | ||
} | ||
|
||
memberItems.Sort((x, y) => | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,7 +211,7 @@ private IEnumerable<ISymbol> FindMembers(IEnumerable<INamespaceOrTypeSymbol> con | |
private IEnumerable<ISymbol> FindMembers(IEnumerable<INamedTypeSymbol> types, NameAndArity nameAndArity) | ||
{ | ||
// Get the matching members from all types (including constructors and explicit interface | ||
// implementations). If there is a partial method, prefer returning the implementation over | ||
// implementations). If there is a partial method/property, prefer returning the implementation over | ||
// the definition (since the definition will not be a candidate for setting a breakpoint). | ||
var members = types.SelectMany(t => GetMembers(t, nameAndArity.Name)) | ||
.Select(s => GetPartialImplementationPartOrNull(s) ?? s); | ||
|
@@ -227,8 +227,12 @@ private async Task<IEnumerable<INamedTypeSymbol>> GetAllTypesAsync(CancellationT | |
return namespaces.GetAllTypes(cancellationToken); | ||
} | ||
|
||
private static IMethodSymbol GetPartialImplementationPartOrNull(ISymbol symbol) | ||
=> (symbol.Kind == SymbolKind.Method) ? ((IMethodSymbol)symbol).PartialImplementationPart : null; | ||
private static ISymbol GetPartialImplementationPartOrNull(ISymbol symbol) => symbol.Kind switch | ||
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. cc @tmat to take a look. Not familiar with debugger, but I feel this change brings no harm. |
||
{ | ||
SymbolKind.Method => ((IMethodSymbol)symbol).PartialImplementationPart, | ||
SymbolKind.Property => ((IPropertySymbol)symbol).PartialImplementationPart, | ||
_ => null | ||
}; | ||
|
||
/// <summary> | ||
/// Is this method or property a valid place to set a breakpoint and does it match the expected parameter count? | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is just a test verified the same behavior as partial methods above.