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

Handle nameof expressions in UnboundIdentifiersDiagnosticAnalyzerBase #24071

Merged
merged 2 commits into from
Jan 18, 2019

Conversation

mavasani
Copy link
Contributor

@mavasani mavasani commented Jan 6, 2018

Addresses #23667

Ask Mode template

Customer scenario

nameof is incorrectly squiggled in a lambda with diagnostics with the following error:
Error IDE1007 The name 'nameof' does not exist in the current context.. Note that the code compiles without errors and the IDE experience is very confusing.

Bugs this fixes

#23667

Workarounds, if any

Ignore the incorrect IDE1007 errors

Risk

Low risk, we are special casing nameof expressions in the unbound identifiers analyzer

Performance impact

Low

Is this a regression from a previous update?

No

Root cause analysis

Analyzer was assuming each identifier name should bind to a symbol for successful bind. This is not true for nameof, which is represented as an IdentifierNameSyntax node in C#, but GetSymbolInfo returns no symbols for it.

How was the bug found?

Customer reported

Test documentation updated?

N/A

@mavasani mavasani added the PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. label Jan 6, 2018
@mavasani mavasani requested a review from a team as a code owner January 6, 2018 00:16
@jasonmalinowski
Copy link
Member

@mavasani Looking at the terribly long conversation in that bug, why didn't we conclude that the compiler should just report this directly and we get rid of the UnboundIdentifiersDiagnosticAnalyzerBase? I have yet to meet somebody who doesn't want that thing to go away. 😄

@mavasani
Copy link
Contributor Author

mavasani commented Jan 8, 2018

@jasonmalinowski The analyzer handles nodes within broken lambdas and incomplete members - I presume the compiler doesn't want to bind them for perf reasons, but I will ask the compiler team for their views on handling these cases.

@mavasani
Copy link
Contributor Author

mavasani commented Jul 2, 2018

Closing this PR as per #23667 (comment) cc @jcouv

@mavasani mavasani closed this Jul 2, 2018
@mavasani mavasani reopened this Dec 5, 2018
@mavasani mavasani closed this Dec 7, 2018
@mavasani mavasani reopened this Dec 7, 2018
@mavasani mavasani removed the PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. label Dec 7, 2018
@mavasani
Copy link
Contributor Author

mavasani commented Dec 7, 2018

@jasonmalinowski @jcouv can you please re-review this PR as per #23667 (comment)?

@CyrusNajmabadi
Copy link
Member

Is there a reason we aren't just fixing this at the compiler layer?

@mavasani
Copy link
Contributor Author

mavasani commented Dec 7, 2018

Is there a reason we aren't just fixing this at the compiler layer?

The compiler feature request has been stalled for quite a while now, and the underlying bug has been reported by multiple customers now. I see no reason to block the user experience on our implementation details, especially given this IDE analyzer already exists.

@CyrusNajmabadi
Copy link
Member

I guess my take is this: given that customers are hitting this, that indicates we should un-stall the root problem. If we fix on the IDE side, that's just going to remove the motivation to ever really fix this at the root level, and we'll continue being in teh state where the IDE is simulating (poorly) that it is the compiler.

Note: we've gotten a wide range of bugs over the years with the lack of compiler support here being the root cause. Rather than fix each one in a piecemeal fashion, i'd rather the compiler just analyze these guys normally.

@jinujoseph jinujoseph added the Need Design Review The end user experience design needs to be reviewed and approved. label Jan 3, 2019
@jinujoseph jinujoseph added this to the 16.0 milestone Jan 3, 2019
@mavasani mavasani removed the Need Design Review The end user experience design needs to be reviewed and approved. label Jan 18, 2019
@mavasani
Copy link
Contributor Author

mavasani commented Jan 18, 2019

We discussed this at the last design meeting and it was decided that we take the fix to the analyzer for 16.0, and keep the underlying issue open to track compiler support for correctly reporting errors within a lambda.

Tagging @jcouv @jasonmalinowski @dotnet/roslyn-ide for review - this PR itself is very trivial

@mavasani
Copy link
Contributor Author

Thanks @jasonmalinowski. @jcouv can you take a quick look please?

@jinujoseph @vatsalyaagrawal for approval

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks

@mavasani
Copy link
Contributor Author

@jaredpar @dotnet/roslyn-infrastructure Linux_Test coreclr seems to have gotten abandoned, and multiple retry attempts lead to it getting immediately abandoned again. Known issue?

image

@jinujoseph jinujoseph modified the milestones: 16.0, 16.0.P3 Jan 18, 2019
@mavasani mavasani merged commit 6b7e1fc into dotnet:master Jan 18, 2019
@mavasani mavasani deleted the NameOfFix branch January 18, 2019 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants