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

XAML QuickInfo update #51846

Merged
4 commits merged into from
Mar 24, 2021
Merged

XAML QuickInfo update #51846

4 commits merged into from
Mar 24, 2021

Conversation

mgoertz-msft
Copy link
Contributor

@mgoertz-msft mgoertz-msft commented Mar 12, 2021

Updated XAML QuickInfo to show more info like C# by using ISymbolDisplayService and adding more documentation parts.

Before:
QuickInfo-Before

After:
QuickInfo-After

@mgoertz-msft mgoertz-msft requested a review from a team as a code owner March 12, 2021 20:02
@sharwell
Copy link
Member

Can you add before/after screenshots?

@mgoertz-msft
Copy link
Contributor Author

@sharwell Done. See updated description.

@sharwell
Copy link
Member

Nice! Does the hyperlinking work as well?

@mgoertz-msft
Copy link
Contributor Author

No, it does not. This is for the LSP Hover handler, which I don't think supports that.

@@ -53,16 +52,51 @@ public static async Task<IEnumerable<TaggedText>> GetDescriptionAsync(this ISymb
return Enumerable.Empty<TaggedText>();
}

var textContentBuilder = new List<TaggedText>();
textContentBuilder.AddRange(symbol.ToDisplayParts(s_descriptionStyle).ToTaggedText());
var description = await symbolDisplayService.ToDescriptionPartsAsync(codeProject.Solution.Workspace, semanticModel, 0, ImmutableArray.Create(symbol), SymbolDescriptionGroups.MainDescription, cancellationToken).ConfigureAwait(false);
Copy link
Member

Choose a reason for hiding this comment

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

named parameter for 0.


var documentation = symbol.GetDocumentationParts(semanticModel, offset, formatter, cancellationToken);
var documentation = symbol.GetDocumentationParts(semanticModel, 0, formatter, cancellationToken);
Copy link
Member

Choose a reason for hiding this comment

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

named parameter for 0.

builder.AddRange(documentation);
}

var remarksDocumentation = symbol.GetRemarksDocumentationParts(semanticModel, 0, formatter, cancellationToken);
Copy link
Member

Choose a reason for hiding this comment

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

i'm surprpised you need to write this yourself. if you use ToDescriptionGroupsAsync, you should have a documentation group already setup for you that you can use. does that not work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope. I would have expected ToDescriptionPartsAsync with SymbolDescriptionGroups.All to give me everything but it does not, so I limited it to MainDescription and called the rest myself.

@CyrusNajmabadi
Copy link
Member

Overall, this looks great. Just a general question about if we can make it even simpler by leveraging more of what ISYmbolDisplayService gives you :)

@mgoertz-msft
Copy link
Contributor Author

Thanks @CyrusNajmabadi. I agree ISymbolDisplayService should have been able to do all this for me. Right now, it does not make a difference if I pass in All groups or just MainDescription to ToDescriptionPartsAsync, both just give me the full symbol name.

@mgoertz-msft
Copy link
Contributor Author

Thanks @CyrusNajmabadi. I agree ISymbolDisplayService should have been able to do all this for me. Right now, it does not make a difference if I pass in All groups or just MainDescription to , both just give me the full symbol name.

@mgoertz-msft
Copy link
Contributor Author

@sharwell, @CyrusNajmabadi, anything else you need before signing off?

@CyrusNajmabadi
Copy link
Member

Sorry. I need to look into this. I have to understand why we can't currently share more.

@mgoertz-msft
Copy link
Contributor Author

@CyrusNajmabadi How about we go with this for now and I open an issue?

@CyrusNajmabadi
Copy link
Member

looking now.

@CyrusNajmabadi
Copy link
Member

CyrusNajmabadi commented Mar 18, 2021

I've opened #51961 to help out here. You'll be able to just grab the groups and build the total docs.

@mgoertz-msft
Copy link
Contributor Author

Thanks @CyrusNajmabadi! I'll wait for it. Looks like #51961 has some (unrelated?) test failures though.

@CyrusNajmabadi
Copy link
Member

@mgoertz-msft my pr went in. So you should be able to use that and just combine the groups without having to rebuild the internal structure. Thanks!

@mgoertz-msft
Copy link
Contributor Author

@CyrusNajmabadi Shouldn't I be able to call ToDescriptionPartsAsync with DescriptionGroups.All to get everything? That still doesn't work because the builder only puts the MainDescription into the _groupsMap and the rest into the _documentationMap.

@CyrusNajmabadi
Copy link
Member

Call ToDescriptionGroupsAsync instead. That gives you the merged result. You shouldn't need SymbolDisplayParts (i hope) for what you're doing. TaggedText is the better, and richer, medium for doing things like QuickInfo.

@mgoertz-msft
Copy link
Contributor Author

I would have just called ToTaggedText() on the result. With ToDescriptionGroupsAsync I have to iterate over all the groups and merge the results myself. Isn't it still a bug that ToDescriptionPartsAsync takes a group flag as an argument but only ever supports the MainDescription?

@CyrusNajmabadi
Copy link
Member

I would have just called ToTaggedText() on the result. With ToDescriptionGroupsAsync I have to iterate over all the groups and merge the results myself.

We can make an extension that does that for you if htat would help :)

Isn't it still a bug that ToDescriptionPartsAsync takes a group flag as an argument but only ever supports the MainDescription?

In this case no. Because we can't actually make SymbolDisplayParts for these other sections. Specifically, these other sections use features of TaggedText that are not representable in the SYmbolDisplayPart world. SymbolDisplayParts are a subset of TaggedText.

This is very much because this is an api using both compiler and IDE primitives, and it has evolved a lot over the years. it likely could be cleaned up, but it was internal and we never had the need.

@CyrusNajmabadi
Copy link
Member

i think you'll want to extract the code in CommonSemanticQuickInfoProvider.CreateContentAsync where we grab all this data and merge it together and then use that common code for your new provider.

@CyrusNajmabadi
Copy link
Member

actually, let me try to provide the helper. i'll make a pr for thsi.

@mgoertz-msft
Copy link
Contributor Author

@CyrusNajmabadi New QuickInfoUtilities helper works great, thanks, but I had to insert line breaks between the sections.

…sions/SymbolExtensions.cs

Co-authored-by: CyrusNajmabadi <cyrus.najmabadi@gmail.com>
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Auto-approval

@ghost ghost merged commit 1360d6f into dotnet:main Mar 24, 2021
@ghost ghost added this to the Next milestone Mar 24, 2021
@allisonchou allisonchou modified the milestones: Next, 16.10.P2 Mar 29, 2021
This pull request was closed.
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.

4 participants