-
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 branch 'tempStorage' of https://github.com/CyrusNajmabadi/roslyn …
…into tempStorage
- Loading branch information
Showing
10 changed files
with
203 additions
and
57 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
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
src/Workspaces/Core/Portable/Workspace/Solution/VersionSource/ITreeAndVersionSource.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,20 @@ | ||
// 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.Diagnostics.CodeAnalysis; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.CodeAnalysis; | ||
|
||
/// <summary> | ||
/// Similar to <see cref="ITextAndVersionSource"/>, but for trees. Allows hiding (or introspecting) the details of how | ||
/// a tree is created for a particular document. | ||
/// </summary> | ||
internal interface ITreeAndVersionSource | ||
{ | ||
Task<TreeAndVersion> GetValueAsync(CancellationToken cancellationToken); | ||
TreeAndVersion GetValue(CancellationToken cancellationToken); | ||
bool TryGetValue([NotNullWhen(true)] out TreeAndVersion? value); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
44 changes: 44 additions & 0 deletions
44
src/Workspaces/Core/Portable/Workspace/Solution/VersionSource/SimpleTreeAndVersionSource.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.Diagnostics.CodeAnalysis; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Roslyn.Utilities; | ||
|
||
namespace Microsoft.CodeAnalysis; | ||
|
||
/// <summary> | ||
/// Simple implementation of <see cref="ITreeAndVersionSource"/> backed by an opaque <see | ||
/// cref="AsyncLazy{TreeAndVersion}"/>."/> | ||
/// </summary> | ||
internal sealed class SimpleTreeAndVersionSource : ITreeAndVersionSource | ||
{ | ||
private readonly AsyncLazy<TreeAndVersion> _source; | ||
|
||
private SimpleTreeAndVersionSource(AsyncLazy<TreeAndVersion> source) | ||
{ | ||
_source = source; | ||
} | ||
|
||
public Task<TreeAndVersion> GetValueAsync(CancellationToken cancellationToken) | ||
=> _source.GetValueAsync(cancellationToken); | ||
|
||
public TreeAndVersion GetValue(CancellationToken cancellationToken) | ||
=> _source.GetValue(cancellationToken); | ||
|
||
public bool TryGetValue([NotNullWhen(true)] out TreeAndVersion? value) | ||
=> _source.TryGetValue(out value); | ||
|
||
public static SimpleTreeAndVersionSource Create<TArg>( | ||
Func<TArg, CancellationToken, Task<TreeAndVersion>> asynchronousComputeFunction, | ||
Func<TArg, CancellationToken, TreeAndVersion>? synchronousComputeFunction, TArg arg) | ||
{ | ||
return new(AsyncLazy<TreeAndVersion>.Create(asynchronousComputeFunction, synchronousComputeFunction, arg)); | ||
} | ||
|
||
public static SimpleTreeAndVersionSource Create(TreeAndVersion source) | ||
=> new(AsyncLazy.Create(source)); | ||
} |
Oops, something went wrong.