Skip to content

Commit

Permalink
Merge pull request #1086 from akshita31/gotodef
Browse files Browse the repository at this point in the history
Changes for empty reponse for GoToDefinition on PropertyAccessorSymbol
  • Loading branch information
filipw authored Jan 29, 2018
2 parents dca4795 + 6a199f4 commit 345f066
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
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

0 comments on commit 345f066

Please sign in to comment.