Skip to content

Fallback navigate to#28294

Merged
dpoeschl merged 4 commits intodotnet:dev15.8.xfrom
sharwell:fallback-navigate-to
Jul 10, 2018
Merged

Fallback navigate to#28294
dpoeschl merged 4 commits intodotnet:dev15.8.xfrom
sharwell:fallback-navigate-to

Conversation

@sharwell
Copy link
Contributor

@sharwell sharwell commented Jul 5, 2018

Customer scenario

In the latest 15.8 Preview 4 internal builds, Navigate To does not work for TypeScript or F#.

Bugs this fixes

https://devdiv.visualstudio.com/DevDiv/_workitems/edit/644180

Workarounds, if any

None.

Risk

Medium risk. The safest option for release would be reverting the original change, but we would lose the substantial (clearly user visible) performance benefit it provided for Go To File.

Performance impact

This change enumerates the projects in a Solution to determine the supported Navigate To kinds each time the feature is used. However, this is not expected to result in substantial overhead compared to the underlying navigation operation.

Is this a regression from a previous update?

Yes

Root cause analysis

TypeScript and F# support Navigate To by implementing INavigateToSearchService (only available via IVTs and thus not under the protection of our public API surface change review process), but there is no test coverage for this feature in either language in either the dotnet/roslyn PR builds or the DDRITs used during the RI process.

How was the bug found?

Dogfooding

Test documentation updated?

No

@sharwell sharwell requested a review from a team as a code owner July 5, 2018 12:54
@CyrusNajmabadi
Copy link
Contributor

@sharwell What is this for?

@sharwell
Copy link
Contributor Author

sharwell commented Jul 6, 2018

@CyrusNajmabadi ask mode template updated to explain the change

@sharwell
Copy link
Contributor Author

sharwell commented Jul 6, 2018

@jasonmalinowski @minestarks @brettfo I have manually verified the repro state and the fix for both TypeScript and F#, so I am now confident this will work.

Copy link
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

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

Calling this an "approve with requested changes" -- mostly just a request for some comments and better text for the Obsolete, since the message isn't actually advice we want to give anyone.

}

#pragma warning disable CS0618 // Type or member is obsolete
var legacyNavigateToSearchService = project.LanguageServices.GetService<INavigateToSearchService>();
Copy link
Member

Choose a reason for hiding this comment

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

Any reason this method isn't just using your other helper that already does the "return an interface"? I recognize it'll allocate a shim which will then cause this loop to bail, but it's a single allocation per search, which seems pretty cheap compared to the duplicate logic here.

Copy link
Member

Choose a reason for hiding this comment

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

(bonus points for a "get all services" helper that just does the loop and is consumed in both properties)

var navigateToSearchService = project.LanguageServices.GetService<INavigateToSearchService_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdate>();
if (navigateToSearchService != null)
{
result = result.Union(navigateToSearchService.KindsProvided);
Copy link
Member

Choose a reason for hiding this comment

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

Use a builder?

Copy link
Contributor Author

@sharwell sharwell Jul 6, 2018

Choose a reason for hiding this comment

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

This is supposed to be a NOP on each loop. It's not clear whether ImmutableHashSet<T> implements the necessary edge cases as fast paths.

  1. When result is empty, the right hand side is returned
  2. When the right hand side is empty, result is returned unaltered
  3. In all other cases where the solution does not contain both C#/VB and F#/TypeScript projects, result and the right hand side reference the same object

Even if the edge cases aren't dedicated fast paths, the fact that most iterations do not alter result means a builder would not provide noticeable benefits.

if (navigateToSearchService != null)
{
result = result.Union(navigateToSearchService.KindsProvided);
continue;
Copy link
Member

Choose a reason for hiding this comment

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

continue doesn't need to be here.


namespace Microsoft.CodeAnalysis.NavigateTo
{
[Obsolete("Use " + nameof(INavigateToSearchService_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdate) + " instead.")]
Copy link
Member

Choose a reason for hiding this comment

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

So I'm not sure that's really the right message here: we sure don't want people moving to this new interface either...at least not with that name!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This order allows the new interface to be implemented independently (the hard/slow part), then we can coordinate with all the repositories on an interface rename (the easy part).

Copy link
Member

@jasonmalinowski jasonmalinowski Jul 6, 2018

Choose a reason for hiding this comment

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

I guess I assumed that our path forward would be to directly work forward having people consume the existing name with new surface area, rather than moving to the new name and then moving back.

In any case "above" is a pretty meaningless name then for an external consumer to consume.

Task<ImmutableArray<INavigateToSearchResult>> SearchDocumentAsync(Document document, string searchPattern, CancellationToken cancellationToken);
}

internal interface INavigateToSearchService_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdate : ILanguageService
Copy link
Member

Choose a reason for hiding this comment

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

Please link to the tracking bug tracking the cleanup, and a quick discussion of how this type came into being. The PR description nor commit description really make this clear unless you're willing to chase through the original PR and figure out the context there.

sharwell added 2 commits July 6, 2018 18:03
* Use TryGetNavigateToSearchService instead of duplicating logic
* Simplify code flow
* Link to dotnet#28343 tracking interface rename
@jinujoseph
Copy link
Contributor

Approved to merge for 15.8.Preview5

@jinujoseph
Copy link
Contributor

@dotnet-bot test

@jinujoseph
Copy link
Contributor

@dotnet-bot retest this please

@mmitche
Copy link
Member

mmitche commented Jul 9, 2018

@dotnet-bot test this please

@jasonmalinowski jasonmalinowski changed the base branch from dev15.8-preview4 to master July 9, 2018 17:35
@jasonmalinowski jasonmalinowski changed the base branch from master to dev15.8-preview4 July 9, 2018 17:35
@jinujoseph jinujoseph changed the base branch from dev15.8-preview4 to dev15.8.x July 10, 2018 17:25
@jasonmalinowski jasonmalinowski changed the base branch from dev15.8.x to master July 10, 2018 21:38
@jasonmalinowski jasonmalinowski changed the base branch from master to dev15.8.x July 10, 2018 21:39
@sharwell sharwell changed the base branch from dev15.8.x to dev15.8-preview4 July 10, 2018 22:36
@sharwell sharwell changed the base branch from dev15.8-preview4 to dev15.8.x July 10, 2018 22:36
Copy link
Contributor

@dpoeschl dpoeschl left a comment

Choose a reason for hiding this comment

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

Something strange is happening with the tests. Temporarily blocking while we sort it out.

@dpoeschl dpoeschl merged commit be711c3 into dotnet:dev15.8.x Jul 10, 2018
@jinujoseph
Copy link
Contributor

Merged for 15.8.Preview5

@sharwell sharwell deleted the fallback-navigate-to branch July 23, 2018 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants