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
don't include implicit/explicit keywords when completing explicit interface operator #53938
don't include implicit/explicit keywords when completing explicit interface operator #53938
Conversation
src/EditorFeatures/TestUtilities/Completion/AbstractCompletionProviderTests.cs
Show resolved
Hide resolved
/// ]]></code> | ||
/// instead of: | ||
/// <code><![CDATA[ | ||
/// static implicit I2<Test2>.implicit operator int(Test2 x) |
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 don't see why we would ever format this text. That just feels like a bug.
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 am a little confused how symboldisplay plays into this scenario. i would not expect completion to be using symboldisplay here. that feels like a core bug on its own to me.
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.
That too.
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.
Line 101 in bcd1dab
var memberString = member.ToMinimalDisplayString(semanticModel, namePosition, s_signatureDisplayFormat); |
:(
@CyrusNajmabadi @333fred Any suggestion on how to best approach this?
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.
- kill me
- replace that code with code that just builds the right syntax for what we're generating. it seems not that hard right? it's just member name, type parameters, parameters, constraints.
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.
replace that code with code that just builds the right syntax for what we're generating
I did that. The code isn't large as I was initially expecting. The only risk I see with this approach is regressing some edge cases, but I'll add more tests.
55dfaf7
to
cd11a40
Compare
cd11a40
to
0b92d20
Compare
.../CSharp/Portable/Completion/CompletionProviders/ExplicitInterfaceMemberCompletionProvider.cs
Outdated
Show resolved
Hide resolved
...ion/CompletionProviders/ExplicitInterfaceMemberCompletionProvider.CompletionSymbolDisplay.cs
Outdated
Show resolved
Hide resolved
...ion/CompletionProviders/ExplicitInterfaceMemberCompletionProvider.CompletionSymbolDisplay.cs
Outdated
Show resolved
Hide resolved
} | ||
|
||
first = false; | ||
AddType(parameter.Type, builder); |
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.
any concern about ref-kind?
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.
@CyrusNajmabadi Yes. This was a bug. Fixed and added a test.
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.
any need to add params?
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.
any need to add constraints? i know it's an explicit interface, so normally no. but is there that funky case where we need to know if T?
is unconstrained or not?
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.
any need to add params?
Yes it definitely should be added. It was a working scenario. Fixed in latest commit.
any need to add constraints? i know it's an explicit interface, so normally no. but is there that funky case where we need to know if
T?
is unconstrained or not?
This is a scenario that doesn't work well on latest preview already.
The existing behavior is: no ?
is added, and no "default" constraint is added.
I'll probably just add the ?
for this PR and leave any potential improvements to address separately.
...ion/CompletionProviders/ExplicitInterfaceMemberCompletionProvider.CompletionSymbolDisplay.cs
Outdated
Show resolved
Hide resolved
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.
Request changes
Submit feedback that must be addressed before merging.
Co-authored-by: CyrusNajmabadi <cyrus.najmabadi@gmail.com>
@CyrusNajmabadi Can you review please? Thanks! |
Ping @CyrusNajmabadi |
|
||
first = false; | ||
builder.Append(typeArgument.Name); | ||
} |
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 would be 100% ok with a stringbuilder extension that takes a TEnumerable and a separator and does this logic :)
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.
@CyrusNajmabadi A private extension just for this class, or somewhere else for wider usage?
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.
somewhere else :)
I have a few suggestions. If you do not want to take them, just LMK. |
@CyrusNajmabadi Thanks. I fixed those you pointed to in addition to other few bugs. |
@CyrusNajmabadi This is ready for another look |
...ion/CompletionProviders/ExplicitInterfaceMemberCompletionProvider.CompletionSymbolDisplay.cs
Outdated
Show resolved
Hide resolved
Thanks! |
Head branch was pushed to by a user without write access
…plicitInterfaceMemberCompletionProvider.CompletionSymbolDisplay.cs Co-authored-by: CyrusNajmabadi <cyrus.najmabadi@gmail.com>
@CyrusNajmabadi Auto-merge was disabled as I pushed commits. Can you re-enable? Thanks! |
Thanks! |
Fixes #53924
This adds a public API :(Another solution would be to handle this case entirely in the completion provider, i.e, dodisplayText.Replace("implicit operator", "").Replace("explicit operator", "");
, but it looks a bit ugly. I'm certainly open to any other ideas.Test plan: #52221