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

GetSymbolInfo behaves differently in msbuild from the IDE #5362

Closed
pdelvo opened this issue Sep 21, 2015 · 7 comments
Closed

GetSymbolInfo behaves differently in msbuild from the IDE #5362

pdelvo opened this issue Sep 21, 2015 · 7 comments
Assignees
Labels
Area-Compilers Bug Concept-API This issue involves adding, removing, clarification, or modification of an API. Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented

Comments

@pdelvo
Copy link
Contributor

pdelvo commented Sep 21, 2015

Over at StyleCopAnalyzers we got this bug report. When investigating I discovered that the problem only was showing up when the analyzer ran on the command line (or our testing application) but not in the IDE. The problem was that GetSymbolInfo was returning two different answers when resolving this symbol:

    public enum Lifetime
    {
        Persistent,
        Transient,
        Scoped
    }
   public class Example
    {
        public Lifetime Lifetime => Lifetime.Persistent;
        //                          ^^^^^^^^
    }

In the IDE it returned the symbol of the enum (which is correct). On the command line however the symbol of the Lifetime property was returned. It looks like the bug only shows up when the symbol is on an ArrowExpressionClause. The bug also shows up if the property has a different name and there is different Property with the name Lifetime:

    public enum Lifetime
    {
        Persistent,
        Transient,
        Scoped
    }
   public class Example
    {
        public Lifetime Lifetime2 => Lifetime.Persistent;
        //                           ^^^^^^^^
        public Lifetime Lifetime
        {
            get
            {
                return Lifetime.Persistent;
            }
        }
    }
@Pilchie Pilchie added Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API. labels Sep 21, 2015
@gafter gafter modified the milestones: 1.1, 1.2 Sep 21, 2015
@jaredpar jaredpar added the Need More Info The issue needs more information to proceed. label Nov 30, 2015
@jaredpar
Copy link
Member

Sorry we're just getting around to this.

There are only two items I can think of that MSBuild would influence here which could explain this:

  1. Picks a different version of the Roslyn APIs hence you're just seeing different code execute.
  2. The compilation is built in a subtly different way that causes the difference you're seeing.

It's hard to determine which is the case based on the bug info. My instinct is to lean towards 1. Are you able to test locally and see which is the case?

@jaredpar jaredpar modified the milestones: 2.0, 1.2 Nov 30, 2015
@jaredpar
Copy link
Member

I'm unable to reproduce this locally hence closing. Please comment back if you have additional information that could help me repro this issue.

@jaredpar jaredpar added the Resolution-Not Reproducible The described behavior could not be reproduced by developers label Jan 18, 2016
@pdelvo
Copy link
Contributor Author

pdelvo commented Jan 18, 2016

I tried it and it still happens. maybe it is easier to repro it like this:

  • Clone stylecopanalyzers
  • Revert this commit.
  • Add the analyzer to a project that has the code from above in it.
  • Compile it.
    A violation of SA1101 is raised if the command line compiler is used, but not in the live analysis of visual studio.

@pdelvo
Copy link
Contributor Author

pdelvo commented Jan 25, 2016

After some research I think I have some more information. I think the problem is, that this statement is not true in this case. The BindIdentifier method does not handle the "Color Color" case but it should. I dont have time to look into this further, but I think it might have to call BindLeftOfPotentialColorColorMemberAccess at some point or the caller of BindIdentifier has to do that.

@pdelvo
Copy link
Contributor Author

pdelvo commented Jan 25, 2016

I think I found the commit that is causing this problem: 92b896ba This would explain why I saw different results before, probably because of different version of roslyn with and without this change

@jaredpar jaredpar removed the Resolution-Not Reproducible The described behavior could not be reproduced by developers label Jan 25, 2016
@jaredpar
Copy link
Member

Thanks for the additional information @pdelvo.

@AlekseyTs AlekseyTs reopened this Feb 1, 2016
@jaredpar jaredpar added Bug and removed Need More Info The issue needs more information to proceed. labels Feb 1, 2016
gafter pushed a commit that referenced this issue Apr 18, 2016
…yntax

An ArrowExpressionClauseSyntax is special because it has an expression as its direct child. Because of that the binder was not correctly caching all nodes of the bound tree and instead was falling back to binding decendand nodes by themself when asked for them. This fails if in the decendant nodes there is a color color case.

With this change the binder does cache all of the ArrowExpressionClauseSyntax's children including the correctly resolved symbols for a color color situation.
Fixes #5362
Closes #8167
@gafter gafter added the Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented label Apr 18, 2016
@gafter
Copy link
Member

gafter commented Apr 18, 2016

Integrated into future in 7d02e6c .

@gafter gafter closed this as completed Apr 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Bug Concept-API This issue involves adding, removing, clarification, or modification of an API. Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants