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

Changes for empty reponse for GoToDefinition on PropertyAccessorSymbol #1086

Merged
merged 6 commits into from
Jan 29, 2018
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -50,6 +50,10 @@ public async Task<GotoDefinitionResponse> Handle(GotoDefinitionRequest request)
// for partial methods, pick the one with body
if (symbol is IMethodSymbol method)
{
// Return an empty response for property accessor symbols like get and set
if (method.AssociatedSymbol is IPropertySymbol)
return response;

symbol = method.PartialImplementationPart ?? symbol;
}

Expand Down
104 changes: 104 additions & 0 deletions tests/OmniSharp.Roslyn.CSharp.Tests/GoToDefinitionFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,110 @@ class {|def:Foo|} {
await TestGoToSourceAsync(testFile);
}

[Fact]
public async Task DoesNotReturnOnPropertAccessorGet()
{
var testFile = new TestFile("foo.cs", @"
class Test {
public string Foo{ g$$et; set; }
}");

await TestGoToSourceAsync(testFile);
}

[Fact]
public async Task DoesNotReturnOnPropertAccessorSet()
{
var testFile = new TestFile("foo.cs", @"
class Test {
public int Foo{ get; s$$et; }
}");

await TestGoToSourceAsync(testFile);
}

[Fact]
public async Task DoesNotReturnOnPropertyAccessorPropertyDef()
{
var testFile = new TestFile("foo.cs", @"
class Test {
public int |def:Foo| Fo$$o{ get; set; }
}");

await TestGoToSourceAsync(testFile);
}

[Fact]
public async Task ReturnsOnPropertyAccessorPropertySetting()
{
var testFile = new TestFile("foo.cs", @"
class Test {
public int |def:Foo|{ get; set; }

public static void main()
{
F$$oo = 3;
}
}");

await TestGoToSourceAsync(testFile);
}

[Fact]
public async Task ReturnsOnPropertyAccessorField1()
{
var testFile = new TestFile("foo.cs", @"
class Test {

public int |def:foo|;

public int Foo
{
get => f$$oo;
set => foo = value;
}
}");

await TestGoToSourceAsync(testFile);
}

[Fact]
public async Task ReturnsOnPropertyAccessorField2()
{
var testFile = new TestFile("foo.cs", @"
class Test {

public int |def:foo|;

public int Foo
{
get => foo;
set => f$$oo = value;
}
}");

await TestGoToSourceAsync(testFile);
}

[Fact]
public async Task ReturnsOnPropertyAccessorPropertyGetting()
{
var testFile = new TestFile("foo.cs", @"
class Test {
public int |def:Foo|{ get; set; }

public static void main()
{
Foo = 3;
Console.WriteLine(F$$oo);
}
}");

await TestGoToSourceAsync(testFile);
}



[Theory]
[InlineData("bar.cs")]
[InlineData("bar.csx")]
Expand Down