-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59798 from CyrusNajmabadi/asyncNavigation2
Change navigation helpers to operate in two steps.
- Loading branch information
Showing
14 changed files
with
302 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/Features/Core/Portable/Navigation/INavigableDocumentLocation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Roslyn.Utilities; | ||
|
||
namespace Microsoft.CodeAnalysis.Navigation | ||
{ | ||
internal interface INavigableLocation | ||
{ | ||
/// <summary> | ||
/// Navigates to a location opening or presenting it in a UI if necessary. This work must happen quickly. Any | ||
/// expensive async work must be done by whatever component creates this value. This method is async only to | ||
/// allow final clients to call this from a non-UI thread while allowing the navigation to jump to the UI | ||
/// thread. | ||
/// </summary> | ||
Task<bool> NavigateToAsync(CancellationToken cancelletionToken); | ||
} | ||
|
||
internal class NavigableLocation : INavigableLocation | ||
{ | ||
private readonly Func<CancellationToken, Task<bool>> _callback; | ||
|
||
public NavigableLocation(Func<CancellationToken, Task<bool>> callback) | ||
=> _callback = callback; | ||
|
||
public Task<bool> NavigateToAsync(CancellationToken cancellationToken) | ||
=> _callback(cancellationToken); | ||
|
||
public static class TestAccessor | ||
{ | ||
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods | ||
public static Task<INavigableLocation?> Create(bool value) | ||
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods | ||
{ | ||
return Task.FromResult<INavigableLocation?>( | ||
new NavigableLocation(c => value ? SpecializedTasks.True : SpecializedTasks.False)); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.