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

Do not offer use-conditional when it would cause name collisions #76807

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

CyrusNajmabadi
Copy link
Member

Fixes #72464

Followup to #76798

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 18, 2025
// Ignore an anonymous type property or tuple field. It's ok if they have a name that
// matches the name of the local we're introducing.
return semanticModel.GetAllDeclaredSymbols(container, cancellationToken, descendInto)
.Where(s => !s.IsAnonymousTypeProperty() && !s.IsTupleField());
Copy link
Member Author

Choose a reason for hiding this comment

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

i moved this filtering into GetAllDeclaredSymbols as all callers want this behavior.

// matches the name of the local we're introducing.
return semanticModel.GetAllDeclaredSymbols(container, cancellationToken)
.Where(s => !s.IsAnonymousTypeProperty() && !s.IsTupleField());
return semanticModel.GetAllDeclaredSymbols(container, cancellationToken);
Copy link
Member Author

Choose a reason for hiding this comment

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

these checks moved into GetAllDeclaredSymbols .

@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review January 18, 2025 03:31
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner January 18, 2025 03:31
@CyrusNajmabadi
Copy link
Member Author

@JoeRobich @ToddGrun This is ready for review, and is the last open bug in the 'use conditional expr' area.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code cleanup "Apply conditional expression preferences" - in latest VS version
1 participant