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

Fix cref's IntelliSense ordering for generic types (#8623) #9356

Closed
wants to merge 3 commits into from

Conversation

dimalypai
Copy link

Comparing on symbol text resulted in the opposite order, because of the ordering between > or } and , (comma). More discussion was happening in the issue #8623.

Comparing on symbol text resulted in the opposite order,
because of the ordering between > or } and , (comma).
@dnfclas
Copy link

dnfclas commented Mar 1, 2016

Hi @dmytrolypai, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla2.dotnetfoundation.org.

TTYL, DNFBOT;

@davkean davkean added Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. labels Mar 1, 2016
@davkean
Copy link
Member

davkean commented Mar 1, 2016

tag @dotnet/roslyn-ide
@dotnet-bot test eta please

@davkean
Copy link
Member

davkean commented Mar 1, 2016

tag @rchande

@dnfclas
Copy link

dnfclas commented Mar 1, 2016

@dmytrolypai, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, DNFBOT;

@davkean
Copy link
Member

davkean commented Mar 8, 2016

@dotnet/roslyn-ide Can we please take a look at this?

@@ -1009,6 +1009,23 @@ class TestException : Exception { }
End Function

<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Copy link
Member

Choose a reason for hiding this comment

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

Add <WorkItem(8623, "https://github.com/dotnet/roslyn/issues/8623")> attribute so we know what issue this tests.

Copy link
Author

Choose a reason for hiding this comment

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

Ah, sorry. For some reason I thought it was only for internal issues. Fixed now.

@tamlin-mike
Copy link

If the goal is for versions with more template arg's to come later, couldn't it simply be solved by letting sortText be symbol (base) name + " " + count_of_commas_plus_1 (or simply template args count, since that probably must be available somewhere as an O(1) operation) in a 2-digit form with leading zero?
(if the language supports more than 99 template arguments, make it three digits :-) ).

@dimalypai
Copy link
Author

@tamlin-mike I think this sounds similar to one of the ideas in the issue discussion (#8623), please correct me if I am wrong. See comments by @rchande and @davkean regarding the usage of metadata type names.

@davkean
Copy link
Member

davkean commented Mar 16, 2016

@dotnet/roslyn-ide Can we take another look?

@tamlin-mike
Copy link

@dmytrolypai I don't see see it. davkean noted that "10" would come before "2" when sorted, and would therefore not work for template argument count. My idea was using "%02d", nTemplateArgs (C format syntax), which seems to solve that problem.

@dimalypai
Copy link
Author

@tamlin-mike Aha, right, now I understand. Yes, 10 vs 2 problem is gone. The only downside I see is what you pointed out earlier about the number of template arguments and picking the correct width for the number part (I don't know if there is a limit for the number of type parameters in C#). Will you implement this idea? The test part from this pull requests can be used, I guess. I don't how to do it the best way with git/github magic, though :)

@tamlin-mike
Copy link

@dmytrolypai Afraid not. This was more of a drive-by problem solving.

@dimalypai
Copy link
Author

@tamlin-mike I see)
I would like to hear an opinion from @dotnet/roslyn-ide about the solution idea described by @tamlin-mike. I found this also: http://stackoverflow.com/questions/2524293/limit-on-amount-of-generic-parameters-in-net (It looks like the spec does not restrict the number of type parameters, which becomes a bit of a problem here).

var sortText = builder
.Replace('{', ' ')
.Replace('}', ' ')
.ToString();
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder what the rest of @dotnet/roslyn-ide thinks of this issue I mentioned on the bug:

We also can't use "whitespace and identifier character strings with type parameter names" either:

genericType ztypeparameter would be sorted after generictype atypeparameter btypeparameter.

If we can't use the metadata name, can we take the type name and append the number of type parameters with some leading 0 padding?

Copy link
Member

Choose a reason for hiding this comment

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

💭 Seems like the sort text should use the metadata name (with arity, e.g. Dictionary`2) and just ignore all the type parameters. Not sure if that would break other scenarios though.

@Pilchie
Copy link
Member

Pilchie commented Mar 31, 2016

I'm actually okay with this the way it is.

It should order things by number of parameters if they all use the same type parameter names, and lexically if they don't, which seems right to me.

👍

@davkean
Copy link
Member

davkean commented Mar 31, 2016

@Pilchie Won't that order Func after Func<T1, T2, TResult>?

@Pilchie
Copy link
Member

Pilchie commented Apr 1, 2016

@davkean Can you try that again with some escaping?

@davkean
Copy link
Member

davkean commented Apr 1, 2016

I meant Func<TResult> after Func<T1, T2, TResult>?

@tamlin-mike
Copy link

Can't the sort order hold its own info, separate from the display strings?

I mean, if we have
struct/class { string GenericName; /* NOTE: Intentionally not TYPE name */
int nGenericArgs ];

it would be obvious how to sort them with a predicate.

I'm starting to think I'm either missing something obvious, or we're all just fumbling in the dark. :-)

@rchande
Copy link
Contributor

rchande commented Sep 8, 2017

@dmytrolypai This slipped off our radar and I'm very sorry about that. Are you still interested in getting this merged? If so, can you resolve the conflicts and push a new set of changes? Thanks!

@davkean
Copy link
Member

davkean commented Sep 8, 2017 via email

@dimalypai
Copy link
Author

@rchande No worries! Yeah, it's been a while, but I will try to get this back on track.

@sharwell
Copy link
Member

Think Dictionary`2 vs Dictionary`10.

That's easy enough to handle with a logical comparer for the sort, e.g. dotnet/corefx#395.

@CyrusNajmabadi
Copy link
Member

We do have LogicalStringComparer at the VS layer. It could be properly lower down for this purpose.

@jaredpar
Copy link
Member

We apologize, but we are closing this PR due to code drift. We regret letting this PR go so long without attention, but at this point the code base has changed too much for us to revisit older PRs. Going forward, we will manage PRs better under an SLA currently under draft in issue #26266 – we encourage you to add comments to that draft as you see fit. Although that SLA is still in draft form, we nevertheless want to move forward with the identification of older PRs to give contributors as much early notice as possible to review and update them.

If you are interested in pursuing this PR, please reset it against the head of master and we will reopen it. Thank you!

@jaredpar jaredpar closed this Apr 19, 2018
@sharwell sharwell added the Resolution-Expired The request is closed due to inactivity under our contribution review policy. label Apr 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. Resolution-Expired The request is closed due to inactivity under our contribution review policy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.