Skip to content

Commit

Permalink
Merge pull request #342 from waf/fix-navigate-to-source-for-generic-t…
Browse files Browse the repository at this point in the history
…ypes

Fix navigate to source for generic types
  • Loading branch information
waf authored Mar 23, 2024
2 parents 6844d65 + 47d024a commit 3ca5ff5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CSharpRepl.Services/SymbolExploration/SymbolExplorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public async Task<SymbolResult> LookupSymbolAtPosition(string text, int position
.Select(t => assemblyReader.GetTypeDefinition(t))
.FirstOrDefault(t =>
assemblyReader.GetString(t.Namespace) == symbolAtPosition.ContainingNamespace.ToDisplayString()
&& assemblyReader.GetString(t.Name) == (symbolAtPosition.ContainingType?.Name ?? symbolAtPosition.Name)
&& assemblyReader.GetString(t.Name) == (symbolAtPosition.ContainingType?.Name ?? symbolAtPosition.MetadataName)
);

using var debugSymbolLoader = new DebugSymbolLoader(assemblyFilePath);
Expand Down
10 changes: 10 additions & 0 deletions CSharpRepl.Tests/SymbolExplorerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ public async Task GetSymbolAtIndex_ClassInSourceLinkedAssembly_ReturnsSourceLink
Assert.EndsWith("Console.cs", symbol.Url);
}

[Fact]
public async Task GetSymbolAtIndex_GenericTypeInSourceLinkedAssembly_ReturnsSourceLinkUrl()
{
// should return a string like https://www.github.com/dotnet/runtime/blob/1381d5ebd2ab1f292848d5b19b80cf71ac332508/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/List.cs
var symbol = await services.GetSymbolAtIndexAsync(@"List<string>", "Li".Length);

Assert.StartsWith("https://www.github.com/dotnet/runtime/", symbol.Url);
Assert.EndsWith("List.cs", symbol.Url);
}

[Fact]
public async Task GetSymbolAtIndex_MethodInSourceLinkedAssembly_ReturnsSourceLinkUrl()
{
Expand Down

0 comments on commit 3ca5ff5

Please sign in to comment.