Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a new implementation of IPersistenceService that sits on top of the new platform 'cloud cache' system. #50762

Merged
141 commits merged into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
bf62038
Throw if we can't successfully make a db
CyrusNajmabadi Jan 25, 2021
b7711fd
Print storage location
CyrusNajmabadi Jan 25, 2021
6e8f1aa
Add package reference
CyrusNajmabadi Jan 25, 2021
5a1bd0b
Working test
CyrusNajmabadi Jan 25, 2021
0ca6473
Update references
CyrusNajmabadi Jan 26, 2021
cc69cba
Merge branch 'asyncStorage' into cloudCache
CyrusNajmabadi Jan 26, 2021
ae267e7
Start fleshing out vs side
CyrusNajmabadi Jan 26, 2021
d6ba7b1
Merge branch 'asyncStorage' into cloudCache
CyrusNajmabadi Jan 26, 2021
fb3a0a3
Merge branch 'noChecksum' into cloudCache
CyrusNajmabadi Jan 26, 2021
8bc7b8e
Continued work
CyrusNajmabadi Jan 26, 2021
7ce39e0
Merge branch 'asyncStorage' into cloudCache
CyrusNajmabadi Jan 26, 2021
91527af
Everything compiles
CyrusNajmabadi Jan 26, 2021
4169f79
Rejigger
CyrusNajmabadi Jan 26, 2021
60c788c
Move code down
CyrusNajmabadi Jan 27, 2021
66cca33
VS side
CyrusNajmabadi Jan 27, 2021
33b4ed7
Update benchmark
CyrusNajmabadi Jan 27, 2021
92d018a
Perf work
CyrusNajmabadi Jan 27, 2021
7c734c0
Working
CyrusNajmabadi Jan 27, 2021
e75cc28
Merge remote-tracking branch 'upstream/master' into cloudCache
CyrusNajmabadi Jan 27, 2021
e99f17e
testing
CyrusNajmabadi Jan 27, 2021
e4b906b
Merge branch 'cloudCache' of https://github.com/CyrusNajmabadi/roslyn…
CyrusNajmabadi Jan 27, 2021
8799e80
Merge branch 'newSqlite' into cloudCache
CyrusNajmabadi Jan 27, 2021
100f085
Switch to sqlite
CyrusNajmabadi Jan 27, 2021
080d73c
Use same comparer as VSdoes
CyrusNajmabadi Jan 27, 2021
eae6643
Use reader
CyrusNajmabadi Jan 28, 2021
417eeaa
Add tests
CyrusNajmabadi Jan 28, 2021
c2d57b6
Fix dimensions
CyrusNajmabadi Jan 28, 2021
6d506fb
Fix test harness
CyrusNajmabadi Jan 28, 2021
2f3e7de
Merge branch 'storageChecksum' into cloudCache
CyrusNajmabadi Jan 28, 2021
ab0ac45
New key system
CyrusNajmabadi Jan 28, 2021
024654d
Merge branch 'storageChecksum' into cloudCache
CyrusNajmabadi Jan 28, 2021
e759fc5
Fallout
CyrusNajmabadi Jan 28, 2021
d482e6a
Merge remote-tracking branch 'upstream/master' into cloudCache
CyrusNajmabadi Jan 29, 2021
2da3576
Upgrade to latest
CyrusNajmabadi Jan 29, 2021
661d36c
Add message
CyrusNajmabadi Feb 1, 2021
70583a7
Buffer reads
CyrusNajmabadi Feb 1, 2021
237e39f
latest andrew
CyrusNajmabadi Feb 2, 2021
f8ed75b
update benchmarks
CyrusNajmabadi Feb 3, 2021
5c89b8e
Get building
CyrusNajmabadi Feb 8, 2021
66c89de
Merge remote-tracking branch 'upstream/master' into cloudCache
CyrusNajmabadi Feb 9, 2021
781f95d
Bmarks
CyrusNajmabadi Feb 9, 2021
393344d
Merge branch 'master' into cloudCache
CyrusNajmabadi Feb 12, 2021
d94d1de
import properly
CyrusNajmabadi Feb 12, 2021
845d817
Use latest version
CyrusNajmabadi Feb 12, 2021
249c654
Remove benchmarks
CyrusNajmabadi Feb 12, 2021
5c3e873
Update NuGet.config
CyrusNajmabadi Feb 12, 2021
b601fe3
Update eng/Versions.props
CyrusNajmabadi Feb 12, 2021
063d2e0
Add docs
CyrusNajmabadi Feb 13, 2021
e0aab47
Add docs
CyrusNajmabadi Feb 13, 2021
53e8cba
Remove unused code.
CyrusNajmabadi Feb 13, 2021
33c91ce
Set default back to sqlite
CyrusNajmabadi Feb 13, 2021
c3c1cd8
Add comment
CyrusNajmabadi Feb 13, 2021
af5d8e0
Update test
CyrusNajmabadi Feb 13, 2021
a5797a3
Merge remote-tracking branch 'upstream/master' into cloudCache
CyrusNajmabadi Feb 18, 2021
6c46b36
rejigger test
CyrusNajmabadi Feb 18, 2021
2fd3b81
rejigger test
CyrusNajmabadi Feb 18, 2021
fd0edcf
Merge remote-tracking branch 'upstream/master-vs-deps' into cloudCache
CyrusNajmabadi Feb 18, 2021
6cd3866
Merge branch 'cloudCache' of https://github.com/CyrusNajmabadi/roslyn…
CyrusNajmabadi Feb 18, 2021
cd7c7f6
Update version
CyrusNajmabadi Feb 18, 2021
81478ad
Merge branch 'cloudCache' of https://github.com/CyrusNajmabadi/roslyn…
CyrusNajmabadi Feb 18, 2021
8ae0851
Merge branch 'removeInternalDep' into cloudCache
CyrusNajmabadi Feb 18, 2021
40fc9b6
Remove
CyrusNajmabadi Feb 18, 2021
19741c2
Fixup
CyrusNajmabadi Feb 18, 2021
87aaab5
Async dispose
CyrusNajmabadi Feb 19, 2021
2eba470
Merge branch 'asyncDisposeStorage' into cloudCache
CyrusNajmabadi Feb 19, 2021
7f58d01
Tweak
CyrusNajmabadi Feb 19, 2021
e43b37d
Update version
CyrusNajmabadi Feb 23, 2021
228347b
Remove unused usings
CyrusNajmabadi Feb 23, 2021
c45e4b6
Merge remote-tracking branch 'upstream/master-vs-deps' into cloudCache
CyrusNajmabadi Feb 23, 2021
1d922ec
Merge remote-tracking branch 'origin/asyncDisposeStorage' into cloudC…
CyrusNajmabadi Feb 23, 2021
4cd5fda
merge conflict
CyrusNajmabadi Feb 23, 2021
d30bae7
Merge remote-tracking branch 'upstream/master' into cloudCache
CyrusNajmabadi Feb 23, 2021
3cc4fcf
Merge remote-tracking branch 'upstream/master-vs-deps' into cloudCache
CyrusNajmabadi Feb 23, 2021
bf3b5e2
Share code
CyrusNajmabadi Feb 23, 2021
8c47c1f
Share code
CyrusNajmabadi Feb 23, 2021
960d9fb
Share code
CyrusNajmabadi Feb 23, 2021
1056738
Update src/Tools/IdeCoreBenchmarks/Program.cs
CyrusNajmabadi Feb 23, 2021
0e8b2f5
Move
CyrusNajmabadi Feb 23, 2021
f6ca210
Merge branch 'cloudCache' of https://github.com/CyrusNajmabadi/roslyn…
CyrusNajmabadi Feb 23, 2021
3e28280
Share more test code
CyrusNajmabadi Feb 23, 2021
1d8543c
Add comment
CyrusNajmabadi Feb 23, 2021
289ff28
Add comments
CyrusNajmabadi Feb 23, 2021
6eff869
Update comment
CyrusNajmabadi Feb 23, 2021
cefb2c6
Remove option
CyrusNajmabadi Feb 23, 2021
f8a130d
Remove unnecessary call
CyrusNajmabadi Feb 23, 2021
50a817b
Use helper
CyrusNajmabadi Feb 23, 2021
826c5ec
Use proper comparer
CyrusNajmabadi Feb 23, 2021
2cab685
Add comment
CyrusNajmabadi Feb 23, 2021
917ceba
Narrow scope of field
CyrusNajmabadi Feb 23, 2021
9175866
Share code
CyrusNajmabadi Feb 23, 2021
27204a3
Add comment
CyrusNajmabadi Feb 23, 2021
c133ba7
Update version
CyrusNajmabadi Feb 23, 2021
711990e
Update mock
CyrusNajmabadi Feb 23, 2021
8bb9f24
Merge remote-tracking branch 'upstream/master' into cloudCache
CyrusNajmabadi Feb 24, 2021
f312c96
Build
CyrusNajmabadi Feb 24, 2021
b987f2e
Merge remote-tracking branch 'upstream/master-vs-deps' into cloudCache
CyrusNajmabadi Feb 24, 2021
2d92fad
Merge remote-tracking branch 'upstream/master-vs-deps' into cloudCache
CyrusNajmabadi Feb 25, 2021
e16117b
Merge remote-tracking branch 'upstream/master-vs-deps' into cloudCache
CyrusNajmabadi Mar 2, 2021
ff05577
Rename
CyrusNajmabadi Mar 2, 2021
2cc1213
Update comment
CyrusNajmabadi Mar 2, 2021
3b3068b
Update src/Workspaces/Core/Portable/Storage/CloudCache/ProjectCacheCo…
CyrusNajmabadi Mar 3, 2021
e1c6767
Update src/Workspaces/Core/Portable/Storage/CloudCache/CloudCachePers…
CyrusNajmabadi Mar 3, 2021
f19459a
Update src/Workspaces/Core/Portable/Storage/CloudCache/ProjectCacheCo…
CyrusNajmabadi Mar 3, 2021
d10adeb
Update src/VisualStudio/CSharp/Test/PersistentStorage/AbstractPersist…
CyrusNajmabadi Mar 3, 2021
ad72675
Update src/VisualStudio/Core/Def/Storage/VisualStudioCloudCacheServic…
CyrusNajmabadi Mar 3, 2021
23dfcd6
Merge remote-tracking branch 'upstream/master-vs-deps' into cloudCache
CyrusNajmabadi Mar 3, 2021
5e19d30
Renames
CyrusNajmabadi Mar 3, 2021
b73b763
Update comments
CyrusNajmabadi Mar 3, 2021
3f4101d
Renames
CyrusNajmabadi Mar 3, 2021
bc59fe2
Change enum value
CyrusNajmabadi Mar 3, 2021
a258e12
Add docs
CyrusNajmabadi Mar 3, 2021
c870298
remove check
CyrusNajmabadi Mar 3, 2021
ff1f9c9
remove check
CyrusNajmabadi Mar 3, 2021
efb818a
Renames
CyrusNajmabadi Mar 3, 2021
35e671a
Add comment
CyrusNajmabadi Mar 3, 2021
daf7418
Add docs
CyrusNajmabadi Mar 3, 2021
4a7544a
Spelling
CyrusNajmabadi Mar 3, 2021
bd08648
Add helper
CyrusNajmabadi Mar 3, 2021
ea2c17b
Share code
CyrusNajmabadi Mar 3, 2021
99a961e
Update
CyrusNajmabadi Mar 3, 2021
8591250
Add comment
CyrusNajmabadi Mar 3, 2021
fdf7348
Rename
CyrusNajmabadi Mar 3, 2021
5b4a533
Merge remote-tracking branch 'upstream/main-vs-deps' into cloudCache
CyrusNajmabadi Mar 4, 2021
de49957
Remove state objects.
CyrusNajmabadi Mar 4, 2021
25b1b25
mef work
CyrusNajmabadi Mar 4, 2021
f359dca
Proper mef
CyrusNajmabadi Mar 4, 2021
f85e575
Go back to sqlite
CyrusNajmabadi Mar 4, 2021
96054a5
Merge branch 'cloudCache' of https://github.com/CyrusNajmabadi/roslyn…
CyrusNajmabadi Mar 4, 2021
8f3bf8b
Merge remote-tracking branch 'upstream/main-vs-deps' into cloudCache
CyrusNajmabadi Mar 5, 2021
ebf3245
Rename
CyrusNajmabadi Mar 5, 2021
d0c7474
Clarity
CyrusNajmabadi Mar 5, 2021
ea2576b
Share code
CyrusNajmabadi Mar 5, 2021
3afb7ce
move all logic up to VS layer
CyrusNajmabadi Mar 5, 2021
5487582
Delete
CyrusNajmabadi Mar 5, 2021
09735a0
remote side
CyrusNajmabadi Mar 6, 2021
8163b52
Tweak
CyrusNajmabadi Mar 6, 2021
ec1bfdf
Share more code
CyrusNajmabadi Mar 6, 2021
1ff6721
perf code
CyrusNajmabadi Mar 6, 2021
1491a76
Merge remote-tracking branch 'upstream/main-vs-deps' into cloudCache
CyrusNajmabadi Mar 8, 2021
acbaa47
Fix
CyrusNajmabadi Mar 8, 2021
89e1b51
Fix
CyrusNajmabadi Mar 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
``` ini

BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19042
Intel Core i7-1065G7 CPU 1.30GHz, 1 CPU, 8 logical and 4 physical cores
[Host] : .NET Framework 4.8 (4.8.4250.0), X64 RyuJIT


```
| Method | Mean | Error |
|------------------ |-----:|------:|
| RunFindReferences | NA | NA |

Benchmarks with issues:
FindReferencesBenchmarks.RunFindReferences: DefaultJob
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxAbsoluteError,MaxRelativeError,MinInvokeCount,MinIterationTime,OutlierMode,Affinity,EnvironmentVariables,Jit,Platform,PowerPlanMode,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,HeapAffinitizeMask,HeapCount,NoAffinitize,RetainVm,Server,Arguments,BuildConfiguration,Clock,EngineFactory,NuGetReferences,Toolchain,IsMutator,InvocationCount,IterationCount,IterationTime,LaunchCount,MaxIterationCount,MaxWarmupIterationCount,MinIterationCount,MinWarmupIterationCount,RunStrategy,UnrollFactor,WarmupCount,Mean,Error
RunFindReferences,DefaultJob,False,Default,Default,Default,Default,Default,Default,11111111,Empty,RyuJit,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 4.7.2,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,1,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,NA,NA
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>IdeCoreBenchmarks.FindReferencesBenchmarks-20210127-150331</title>

<style type="text/css">
table { border-collapse: collapse; display: block; width: 100%; overflow: auto; }
td, th { padding: 6px 13px; border: 1px solid #ddd; text-align: right; }
tr { background-color: #fff; border-top: 1px solid #ccc; }
tr:nth-child(even) { background: #f8f8f8; }
</style>
</head>
<body>
<pre><code>
BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19042
Intel Core i7-1065G7 CPU 1.30GHz, 1 CPU, 8 logical and 4 physical cores
[Host] : .NET Framework 4.8 (4.8.4250.0), X64 RyuJIT
</code></pre>
<pre><code></code></pre>

<table>
<thead><tr><th> Method</th><th>Mean</th><th>Error</th>
</tr>
</thead><tbody><tr><td>RunFindReferences</td><td>NA</td><td>NA</td>
</tr></tbody></table>
</body>
</html>
9 changes: 5 additions & 4 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<MicrosoftBuildTasksCoreVersion>15.3.409</MicrosoftBuildTasksCoreVersion>
<NuGetVisualStudioContractsVersion>5.7.0</NuGetVisualStudioContractsVersion>
<!-- This is working around Microsoft.VisualStudio.Shell.15.0 having an unstated conflicting reference on this with NuGet.VisualStudio.Contracts -->
<MicrosoftVisualStudioRpcContractsVersion>16.7.50</MicrosoftVisualStudioRpcContractsVersion>
<MicrosoftVisualStudioRpcContractsVersion>16.9.65</MicrosoftVisualStudioRpcContractsVersion>
<!--
Since the Microsoft.CodeAnalysis.Analyzers package is a public dependency of our NuGet
packages we will keep it untied to the RoslynDiagnosticsNugetPackageVersion we use for
Expand Down Expand Up @@ -113,8 +113,9 @@
<MicrosoftNuGetBuildTasksVersion>0.1.0</MicrosoftNuGetBuildTasksVersion>
<MicrosoftPortableTargetsVersion>0.1.2-dev</MicrosoftPortableTargetsVersion>
<MicrosoftServiceHubClientVersion>2.7.89</MicrosoftServiceHubClientVersion>
<MicrosoftServiceHubFrameworkVersion>2.7.89</MicrosoftServiceHubFrameworkVersion>
<MicrosoftServiceHubFrameworkVersion>2.7.339</MicrosoftServiceHubFrameworkVersion>
<MicrosoftVisualBasicVersion>10.1.0</MicrosoftVisualBasicVersion>
<MicrosoftVisualStudioCacheVersion>16.9.26-beta</MicrosoftVisualStudioCacheVersion>
<MicrosoftVisualStudioCallHierarchyPackageDefinitionsVersion>15.8.27812-alpha</MicrosoftVisualStudioCallHierarchyPackageDefinitionsVersion>
<MicrosoftVisualStudioCodeAnalysisSdkUIVersion>15.8.27812-alpha</MicrosoftVisualStudioCodeAnalysisSdkUIVersion>
<MicrosoftVisualStudioComponentModelHostVersion>16.0.467</MicrosoftVisualStudioComponentModelHostVersion>
Expand Down Expand Up @@ -211,7 +212,7 @@
<SystemIOFileSystemVersion>4.3.0</SystemIOFileSystemVersion>
<SystemIOFileSystemPrimitivesVersion>4.3.0</SystemIOFileSystemPrimitivesVersion>
<SystemIOPipesAccessControlVersion>4.5.1</SystemIOPipesAccessControlVersion>
<SystemIOPipelinesVersion>5.0.0</SystemIOPipelinesVersion>
<SystemIOPipelinesVersion>5.0.1</SystemIOPipelinesVersion>
<SystemManagementVersion>5.0.0-preview.8.20407.11</SystemManagementVersion>
<SystemMemoryVersion>4.5.4</SystemMemoryVersion>
<SystemResourcesExtensionsVersion>4.7.1</SystemResourcesExtensionsVersion>
Expand Down Expand Up @@ -254,7 +255,7 @@
create a test insertion in Visual Studio to validate.
-->
<NewtonsoftJsonVersion>12.0.2</NewtonsoftJsonVersion>
<StreamJsonRpcVersion>2.7.66-alpha</StreamJsonRpcVersion>
<StreamJsonRpcVersion>2.7.67</StreamJsonRpcVersion>
<MicrosoftBclAsyncInterfacesVersion>1.1.1</MicrosoftBclAsyncInterfacesVersion>
CyrusNajmabadi marked this conversation as resolved.
Show resolved Hide resolved
<!--
When updating the S.C.I or S.R.M version please let the MSBuild team know in advance so they
Expand Down
33 changes: 33 additions & 0 deletions src/Tools/IdeCoreBenchmarks/CloudCache/AuthorizationServiceMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.ServiceHub.Framework.Services;

#pragma warning disable CS0067 // events that are never used

namespace CloudCache
{
internal class AuthorizationServiceMock : IAuthorizationService
Copy link
Member Author

Choose a reason for hiding this comment

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

mocks for testing/perf related purposes.

CyrusNajmabadi marked this conversation as resolved.
Show resolved Hide resolved
{
public event EventHandler? CredentialsChanged;

public event EventHandler? AuthorizationChanged;

internal bool Allow { get; set; } = true;

public ValueTask<bool> CheckAuthorizationAsync(ProtectedOperation operation, CancellationToken cancellationToken = default)
{
return new ValueTask<bool>(this.Allow);
}

public ValueTask<IReadOnlyDictionary<string, string>> GetCredentialsAsync(CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}
}
}
80 changes: 80 additions & 0 deletions src/Tools/IdeCoreBenchmarks/CloudCache/FileSystemServiceMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// 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.Collections.Generic;
using System.IO;
using System.IO.Pipelines;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.ServiceHub.Framework;
using Microsoft.VisualStudio.RpcContracts.FileSystem;

namespace CloudCache
{
internal class FileSystemServiceMock : IFileSystem
{
public event EventHandler<DirectoryEntryChangedEventArgs>? DirectoryEntryChanged;

public event EventHandler<RootEntriesChangedEventArgs>? RootEntriesChanged;

public Task<Uri> ConvertLocalFileNameToRemoteUriAsync(string fileName, CancellationToken cancellationToken) => throw new NotImplementedException();

public Task<Uri> ConvertLocalFileNameToRemoteUriAsync(string fileName, string remoteScheme, CancellationToken cancellationToken) => throw new NotImplementedException();

public Task<Uri> ConvertLocalUriToRemoteUriAsync(Uri localUri, CancellationToken cancellationToken) => throw new NotImplementedException();

public Task<Uri> ConvertLocalUriToRemoteUriAsync(Uri localUri, string remoteScheme, CancellationToken cancellationToken) => throw new NotImplementedException();

public Task<Uri> ConvertRemoteUriToLocalUriAsync(Uri remoteUri, CancellationToken cancellationToken) => Task.FromResult(remoteUri);

public Task CopyAsync(Uri sourceUri, Uri destinationUri, bool overwrite, IProgress<OperationProgressData>? progress, CancellationToken cancellationToken) => throw new NotImplementedException();

public Task CreateDirectoryAsync(Uri uri, CancellationToken cancellationToken) => throw new NotImplementedException();

public Task DeleteAsync(Uri uri, bool recursive, IProgress<OperationProgressData>? progress, CancellationToken cancellationToken) => throw new NotImplementedException();

public Task<Uri> DownloadFileAsync(Uri remoteUri, IProgress<OperationProgressData>? progress, CancellationToken cancellationToken) => throw new NotImplementedException();

public IAsyncEnumerable<Microsoft.VisualStudio.RpcContracts.FileSystem.DirectoryInfo> EnumerateDirectoriesAsync(Uri uri, string searchPattern, SearchOption searchOption, CancellationToken cancellationToken) => throw new NotImplementedException();

public IAsyncEnumerable<DirectoryEntryInfo> EnumerateDirectoryEntriesAsync(Uri uri, string searchPattern, SearchOption searchOption, CancellationToken cancellationToken) => throw new NotImplementedException();

public IAsyncEnumerable<Microsoft.VisualStudio.RpcContracts.FileSystem.FileInfo> EnumerateFilesAsync(Uri uri, string searchPattern, SearchOption searchOption, CancellationToken cancellationToken) => throw new NotImplementedException();

public Task<string> GetDefaultRemoteUriSchemeAsync(CancellationToken cancellationToken) => throw new NotImplementedException();

public Task<UriDisplayInfo> GetDisplayInfoAsync(Uri uri, CancellationToken cancellationToken) => throw new NotImplementedException();

public Task<UriDisplayInfo> GetDisplayInfoAsync(string fileName, CancellationToken cancellationToken) => throw new NotImplementedException();

public Task<DirectoryEntryInfo?> GetInfoAsync(Uri uri, CancellationToken cancellationToken) => throw new NotImplementedException();

public Task<ServiceMoniker> GetMonikerForFileSystemProviderAsync(string scheme, CancellationToken cancellationToken) => throw new NotImplementedException();

public Task<ServiceMoniker> GetMonikerForRemoteFileSystemProviderAsync(string scheme, CancellationToken cancellationToken) => throw new NotImplementedException();

public Task<IReadOnlyList<Uri>> GetRootEntriesAsync(string scheme, CancellationToken cancellationToken) => throw new NotImplementedException();

public Task<IReadOnlyList<Uri>> GetRootEntriesAsync(CancellationToken cancellationToken) => throw new NotImplementedException();

public Task<IReadOnlyList<string>> GetSupportedSchemesAsync(CancellationToken cancellationToken) => throw new NotImplementedException();

public Task MoveAsync(Uri oldUri, Uri newUri, bool overwrite, IProgress<OperationProgressData>? progress, CancellationToken cancellationToken) => throw new NotImplementedException();

public Task ReadFileAsync(Uri uri, PipeWriter writer, CancellationToken cancellationToken) => throw new NotImplementedException();

public ValueTask UnwatchAsync(WatchResult watchResult, CancellationToken cancellationToken) => throw new NotImplementedException();

public ValueTask<WatchResult> WatchDirectoryAsync(Uri uri, bool recursive, CancellationToken cancellationToken) => throw new NotImplementedException();

public ValueTask<WatchResult> WatchFileAsync(Uri uri, CancellationToken cancellationToken) => throw new NotImplementedException();

public Task WriteFileAsync(Uri uri, PipeReader reader, bool overwrite, CancellationToken cancellationToken) => throw new NotImplementedException();

protected virtual void OnDirectoryEntryChanged(DirectoryEntryChangedEventArgs args) => this.DirectoryEntryChanged?.Invoke(this, args);

protected virtual void OnRootEntriesChanged(RootEntriesChangedEventArgs args) => this.RootEntriesChanged?.Invoke(this, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// 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.Composition;
using System.IO.Pipelines;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Storage;
using Microsoft.ServiceHub.Framework;
using Microsoft.ServiceHub.Framework.Services;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Cache;
using Microsoft.VisualStudio.RpcContracts.Caching;

namespace CloudCache
{
[ExportWorkspaceService(typeof(ICloudCacheServiceProvider), ServiceLayer.Host), Shared]
internal class IdeCoreBenchmarksCloudCacheServiceProvider : ICloudCacheServiceProvider
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public IdeCoreBenchmarksCloudCacheServiceProvider()
{
Console.WriteLine($"Instantiated {nameof(IdeCoreBenchmarksCloudCacheServiceProvider)}");
}

public ValueTask<ICloudCacheService> CreateCacheAsync(CancellationToken cancellationToken)
{
var authorizationServiceClient = new AuthorizationServiceClient(new AuthorizationServiceMock());
var solutionService = new SolutionServiceMock();
var fileSystem = new FileSystemServiceMock();
var serviceBroker = new ServiceBrokerMock()
{
BrokeredServices =
{
{ VisualStudioServices.VS2019_9.SolutionService.Moniker, solutionService },
{ VisualStudioServices.VS2019_9.FileSystem.Moniker, fileSystem },
{ FrameworkServices.Authorization.Moniker, new AuthorizationServiceMock() },
},
};

var someContext = new CacheContext { RelativePathBase = @"C:\github\roslyn" };
CyrusNajmabadi marked this conversation as resolved.
Show resolved Hide resolved
var cacheService = new CacheService(someContext, serviceBroker, authorizationServiceClient);
return new(new IdeCoreBenchmarksCloudCacheService(cacheService));
}

private class IdeCoreBenchmarksCloudCacheService : ICloudCacheService
CyrusNajmabadi marked this conversation as resolved.
Show resolved Hide resolved
{
private readonly ICacheService _cacheService;

public IdeCoreBenchmarksCloudCacheService(ICacheService cacheService)
{
_cacheService = cacheService;
}

private static CacheItemKey Convert(CloudCacheItemKey key)
=> new(Convert(key.ContainerKey), key.ItemName) { Version = key.Version };

private static CacheContainerKey Convert(CloudCacheContainerKey containerKey)
=> new(containerKey.Component, containerKey.Dimensions);

public void Dispose()
=> (_cacheService as IDisposable)?.Dispose();

public Task<bool> CheckExistsAsync(CloudCacheItemKey key, CancellationToken cancellationToken)
=> _cacheService.CheckExistsAsync(Convert(key), cancellationToken);

public ValueTask<string> GetRelativePathBaseAsync(CancellationToken cancellationToken)
=> _cacheService.GetRelativePathBaseAsync(cancellationToken);

public Task SetItemAsync(CloudCacheItemKey key, PipeReader reader, bool shareable, CancellationToken cancellationToken)
=> _cacheService.SetItemAsync(Convert(key), reader, shareable, cancellationToken);

public Task<bool> TryGetItemAsync(CloudCacheItemKey key, PipeWriter writer, CancellationToken cancellationToken)
=> _cacheService.TryGetItemAsync(Convert(key), writer, cancellationToken);
}
}
}
38 changes: 38 additions & 0 deletions src/Tools/IdeCoreBenchmarks/CloudCache/ServiceBrokerMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// 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.Collections.Generic;
using System.IO.Pipelines;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.ServiceHub.Framework;

namespace CloudCache
{
internal class ServiceBrokerMock : IServiceBroker
{
public event EventHandler<BrokeredServicesChangedEventArgs>? AvailabilityChanged;

internal Dictionary<ServiceMoniker, object> BrokeredServices { get; } = new();

public ValueTask<IDuplexPipe?> GetPipeAsync(ServiceMoniker serviceMoniker, ServiceActivationOptions options = default, CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}

public ValueTask<T?> GetProxyAsync<T>(ServiceRpcDescriptor serviceDescriptor, ServiceActivationOptions options = default, CancellationToken cancellationToken = default)
where T : class
{
if (this.BrokeredServices.TryGetValue(serviceDescriptor.Moniker, out object? service))
{
return new((T?)service);
}

return default;
}

internal void OnAvailabilityChanged(BrokeredServicesChangedEventArgs args) => this.AvailabilityChanged?.Invoke(this, args);
}
}
Loading