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

Signature Help: Prefer non-obsolete overloads #49961

Merged
merged 7 commits into from
Dec 17, 2020

Conversation

MaStr11
Copy link
Contributor

@MaStr11 MaStr11 commented Dec 14, 2020

Fixes #49609

@MaStr11 MaStr11 requested a review from a team as a code owner December 14, 2020 15:29
return CreateDescriptionAsync(workspace, semanticModel, position, symbol, overloadCount: symbols.Count - 1, supportedPlatforms, cancellationToken);

static bool IsObsolete(ISymbol symbol)
=> symbol.GetAttributes().Any(x => x.AttributeClass.MetadataName == "ObsoleteAttribute");
Copy link
Contributor Author

@MaStr11 MaStr11 Dec 14, 2020

Choose a reason for hiding this comment

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

This line is copy/paste from

private async Task AddDescriptionPartAsync(ISymbol symbol)
{
if (symbol.GetAttributes().Any(x => x.AttributeClass.MetadataName == "ObsoleteAttribute"))

That logic should be extracted (e.g. static bool IsObsolete(this ISymbol symbol) somewhere). I haven't done this, because the logic seems to be implemented way better already:

internal static bool IsTargetEarlyAttribute(INamedTypeSymbolInternal attributeType, int attributeArgCount, AttributeDescription description)

and
internal static readonly AttributeDescription ObsoleteAttribute = new AttributeDescription("System", "ObsoleteAttribute", s_signaturesOfObsoleteAttribute);

But this logic is not accessible in this layer. Many Symbol implementations also have an ObsoleteAttributeData ObsoleteAttributeData property, but that is also internal, not part of any interface, and not accessible from here.

So I don't know what's the best way forward to avoid code duplication in this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm, my initial inclination is that creating an IsObsolete extension method in somewhere like ISymbolExtensions would be the best path forward. Like you mentioned, I don't think we're able to access the other logic since it's in the compiler layer.

Maybe @CyrusNajmabadi has some thoughts on this?

Copy link
Member

Choose a reason for hiding this comment

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

yes. we should just have a single extension for this in the IDE that all these locations use.

Copy link
Contributor Author

@MaStr11 MaStr11 Dec 17, 2020

Choose a reason for hiding this comment

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

I have found one more occurrence of that pattern and replaced it with the new extension method in 7128e78.

@jinujoseph jinujoseph added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Dec 14, 2020
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

tiny recommended changes.

@CyrusNajmabadi CyrusNajmabadi merged commit 0ff4743 into dotnet:master Dec 17, 2020
@ghost ghost added this to the Next milestone Dec 17, 2020
@CyrusNajmabadi
Copy link
Member

Thanks!!

@MaStr11 MaStr11 deleted the SigHelpDeprecatedOverload branch December 17, 2020 18:58
@dibarbet dibarbet modified the milestones: Next, 16.9.P3 Dec 19, 2020
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Signature help when browsing IntelliSense list should not prefer obsolete overloads
6 participants