提交 33f3458d 编写于 作者: C CyrusNajmabadi

You should be able to navigate to items that are in generated code.

上级 39233d4c
......@@ -840,8 +840,9 @@ public async Task DottedPattern7()
}
[WorkItem(1174255, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1174255")]
[WorkItem(8009, "https://github.com/dotnet/roslyn/issues/8009")]
[Fact, Trait(Traits.Feature, Traits.Features.NavigateTo)]
public async Task NoNavigationToGeneratedFiles()
public async Task NavigateToGeneratedFiles()
{
using (var workspace = await TestWorkspace.CreateAsync(@"
<Workspace>
......@@ -860,7 +861,7 @@ namespace N
{
public partial class C
{
public void VisibleMethod_Not() { }
public void VisibleMethod_Generated() { }
}
}
</Document>
......@@ -876,7 +877,8 @@ public partial class C
var items = _aggregator.GetItems("VisibleMethod");
var expectedItems = new List<NavigateToItem>()
{
new NavigateToItem("VisibleMethod", NavigateToItemKind.Method, "csharp", null, null, MatchKind.Exact, true, null)
new NavigateToItem("VisibleMethod", NavigateToItemKind.Method, "csharp", null, null, MatchKind.Exact, true, null),
new NavigateToItem("VisibleMethod_Generated", NavigateToItemKind.Method, "csharp", null, null, MatchKind.Prefix, true, null)
};
// The pattern matcher should match 'VisibleMethod' to both 'VisibleMethod' and 'VisibleMethod_Not', except that
......
......@@ -29,7 +29,8 @@ public static IEnumerable<INavigableItem> GetItemsFromPreferredSourceLocations(S
return locations.Select(loc => GetItemFromSymbolLocation(solution, symbol, loc, displayString));
}
public static IEnumerable<Location> GetPreferredSourceLocations(Solution solution, ISymbol symbol)
public static IEnumerable<Location> GetPreferredSourceLocations(
Solution solution, ISymbol symbol)
{
// Prefer non-generated source locations over generated ones.
......
......@@ -16,11 +16,10 @@ internal static class NavigateToSymbolFinder
{
internal static async Task<IEnumerable<ValueTuple<DeclaredSymbolInfo, Document, IEnumerable<PatternMatch>>>> FindNavigableDeclaredSymbolInfos(Project project, string pattern, CancellationToken cancellationToken)
{
var generatedCodeRecognitionService = project.LanguageServices.WorkspaceServices.GetService<IGeneratedCodeRecognitionService>();
var patternMatcher = new PatternMatcher(pattern);
var result = new List<ValueTuple<DeclaredSymbolInfo, Document, IEnumerable<PatternMatch>>>();
foreach (var document in project.Documents.Where(d => !generatedCodeRecognitionService?.IsGeneratedCode(d) ?? true))
foreach (var document in project.Documents)
{
cancellationToken.ThrowIfCancellationRequested();
var declaredSymbolInfos = await document.GetDeclaredSymbolInfosAsync(cancellationToken).ConfigureAwait(false);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册