dotnet/roslyn

GetSymbolInfo for a get property returns an overriden property without a get

Open

#5 659 ouverte le 2 oct. 2015

Voir sur GitHub
 (0 commentaires) (0 réactions) (0 assignés)C# (4 257 forks)batch import
Area-CompilersBugConcept-APIhelp wanted

Métriques du dépôt

Stars
 (20 414 stars)
Métriques de merge PR
 (Merge moyen 6j 17h) (256 PRs mergées en 30 j)

Description

public class A: B{
    public override int Q{ set{ base.Q = value; } }

    public void foo(int x){
    }

    public void test(){
        foo(Q);
    }

    public static void Main(string[] args){
    }
}

public class B{
    public virtual int Q{ get; set; }
}

Calling model.GetSymbolInfo on the argument 'Q' in the call to 'foo' returns an IPropertySymbol defined by class A, which does not have a GetMethod. To get the GetMethod used, I have to look at the OverridenProperty attribute of the returned symbol to find B.get_Q.

It seems like Roslyn should bind the 'Q' expression directly to the B.Q property. Presumably this does not occur because Roslyn does not take the context of the property into account, meaning that it doesn't look at if the property is used in a get/set context, and rather that simply the name is resolved to the 'closest' definition of the property.

Roslyn 1.0.0

Guide contributeur