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

Intellisense not showing methods from the Base class in Signature Help #1030

Merged
merged 17 commits into from
Dec 8, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,15 @@ private IEnumerable<IMethodSymbol> GetMethodOverloads(SemanticModel semanticMode
return new IMethodSymbol[] { };
}

return symbol.ContainingType.GetMembers(symbol.Name).OfType<IMethodSymbol>();
var MethodOverloads = symbol.ContainingType.GetMembers(symbol.Name).OfType<IMethodSymbol>();
Copy link
Member

Choose a reason for hiding this comment

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

local variables should start with lowercase

var BaseType = symbol.ContainingType.BaseType;
while(BaseType!=null && BaseType.ContainingNamespace.Name!= "System")
Copy link
Member

Choose a reason for hiding this comment

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

spacing is off here.
Also, perhaps it would be better to check for baseTypeSymbol.SpecialType != SpecialType.System_Object and terminate there instead rather than on "System" namespace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The above mentioned change is failing for the case of attribute constructor as the System.Attribute class doesn't have the SpecialType as System_Object, hence for that case we will also get an Attribute.Attribute method which is not required.This is the reason the System Namespace has been used.

{
MethodOverloads = MethodOverloads.Concat(BaseType.GetMembers(symbol.Name).OfType<IMethodSymbol>());
BaseType = BaseType.BaseType;
}

return MethodOverloads;
}

private int InvocationScore(IMethodSymbol symbol, IEnumerable<TypeInfo> types)
Expand Down
29 changes: 28 additions & 1 deletion tests/OmniSharp.Roslyn.CSharp.Tests/SignatureHelpFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,40 @@ public Program(Program p, int n)
{
}
}";

var actual = await GetSignatureHelp(source);
Assert.Equal(3, actual.Signatures.Count());
Assert.Equal(1, actual.ActiveParameter);
Assert.Contains("ctor2", actual.Signatures.ElementAt(actual.ActiveSignature).Documentation);
}

[Fact]
public async Task SignatureHelpForOverloadedMethodsInheritance()
Copy link

Choose a reason for hiding this comment

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

Can you add a case for methods with the same name that shouldn't be accessible? Eg:

    class Program
    {
        static void Main(string[] args)
        {
        }

        private void Foo() { }
    }

    class G : Program
    {
        protected void Foo() { }
    }

{
const string source =
@"public class MyBase
{
public void MyMethod(int a) { }
public void MyMethod(int a, int b) { }
}
public class Class1 : MyBase
{
public void MyMethod(int a, int b, int c) { }
public void MyMethod(int a, int b, int c, int d) { }
}
public class Class2
{
public void foo()
{
Class1 c1 = new Class1();
c1.MyMethod($$);
}
}";
var actual = await GetSignatureHelp(source);
Assert.Equal(4, actual.Signatures.Count());
}
[Fact]
public async Task SkipReceiverOfExtensionMethods()
{
Expand Down