-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Signature Help: Prefer non-obsolete overloads #49961
Conversation
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"); |
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 line is copy/paste from
Lines 248 to 250 in a30b09e
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.
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.
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?
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.
yes. we should just have a single extension for this in the IDE that all these locations use.
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 have found one more occurrence of that pattern and replaced it with the new extension method in 7128e78.
src/Features/Core/Portable/Completion/CommonCompletionUtilities.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ISymbolExtensions.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.
tiny recommended changes.
Thanks!! |
Fixes #49609