protected Session(ChecksumScope scope, CancellationToken cancellationToken) { _disposed = false; ChecksumScope = scope; CancellationToken = cancellationToken; }
private async Task UpdateLastSolutionSnapshotAsync(ISolutionChecksumService snapshotService, Solution solution) { // TODO: actual incremental build of solution snapshot should be its own service // this is needed to make sure we incrementally update solution checksums. otherwise, we will always create from // scratch which can be quite expansive for big solution var lastSnapshot = _lastSnapshot; _lastSnapshot = await snapshotService.CreateChecksumAsync(solution, CancellationToken.None).ConfigureAwait(false); lastSnapshot?.Dispose(); }
private async Task UpdateSolutionChecksumAsync(CancellationToken cancellationToken) { // hold onto previous snapshot var previousSnapshot = _lastSnapshot; // create a new one (incrementally update the snapshot) _lastSnapshot = await _checksumService.CreateChecksumAsync(_workspace.CurrentSolution, cancellationToken).ConfigureAwait(false); // let old one go. previousSnapshot?.Dispose(); }
public override void Shutdown() { base.Shutdown(); // stop listening workspace change event _workspace.WorkspaceChanged -= OnWorkspaceChanged; CancelAndDispose(_globalOperationCancellationSource); // release last snapshot _lastSnapshot?.Dispose(); _lastSnapshot = null; }
public JsonRpcSession( ChecksumScope snapshot, Stream snapshotStream, object callbackTarget, Stream serviceStream, CancellationToken cancellationToken) : base(snapshot, cancellationToken) { _snapshotClient = new SnapshotJsonRpcClient(this, snapshotStream); _serviceClient = new ServiceJsonRpcClient(serviceStream, callbackTarget); // dispose session when cancellation has raised _cancellationRegistration = CancellationToken.Register(Dispose); }
public override void Shutdown() { base.Shutdown(); // stop listening workspace change event _service.Workspace.WorkspaceChanged -= OnWorkspaceChanged; CancelAndDispose(_globalOperationCancellationSource); using (_gate.DisposableWait(CancellationToken.None)) { // release last snapshot _lastSnapshot?.Dispose(); _lastSnapshot = null; } }
private async Task <Solution> GetSolutionAsync(ISolutionChecksumService service, ChecksumScope snapshot) { var workspace = new AdhocWorkspace(); var solutionInfo = await GetValueAsync <SolutionChecksumObjectInfo>(service, snapshot.SolutionChecksum.Info, WellKnownChecksumObjects.SolutionChecksumObjectInfo).ConfigureAwait(false); var projects = new List <ProjectInfo>(); foreach (var projectSnapshot in snapshot.SolutionChecksum.Projects.ToProjectObjects(service)) { var documents = new List <DocumentInfo>(); foreach (var documentSnapshot in projectSnapshot.Documents.ToDocumentObjects(service)) { var documentInfo = await GetValueAsync <DocumentChecksumObjectInfo>(service, documentSnapshot.Info, WellKnownChecksumObjects.DocumentChecksumObjectInfo).ConfigureAwait(false); var text = await GetValueAsync <SourceText>(service, documentSnapshot.Text, WellKnownChecksumObjects.SourceText).ConfigureAwait(false); // TODO: do we need version? documents.Add( DocumentInfo.Create( documentInfo.Id, documentInfo.Name, documentInfo.Folders, documentInfo.SourceCodeKind, TextLoader.From(TextAndVersion.Create(text, VersionStamp.Create())), documentInfo.FilePath, documentInfo.IsGenerated)); } var p2p = new List <ProjectReference>(); foreach (var checksum in projectSnapshot.ProjectReferences) { var reference = await GetValueAsync <ProjectReference>(service, checksum, WellKnownChecksumObjects.ProjectReference).ConfigureAwait(false); p2p.Add(reference); } var metadata = new List <MetadataReference>(); foreach (var checksum in projectSnapshot.MetadataReferences) { var reference = await GetValueAsync <MetadataReference>(service, checksum, WellKnownChecksumObjects.MetadataReference).ConfigureAwait(false); metadata.Add(reference); } var analyzers = new List <AnalyzerReference>(); foreach (var checksum in projectSnapshot.AnalyzerReferences) { var reference = await GetValueAsync <AnalyzerReference>(service, checksum, WellKnownChecksumObjects.AnalyzerReference).ConfigureAwait(false); analyzers.Add(reference); } var additionals = new List <DocumentInfo>(); foreach (var documentSnapshot in projectSnapshot.AdditionalDocuments.ToDocumentObjects(service)) { var documentInfo = await GetValueAsync <DocumentChecksumObjectInfo>(service, documentSnapshot.Info, WellKnownChecksumObjects.DocumentChecksumObjectInfo).ConfigureAwait(false); var text = await GetValueAsync <SourceText>(service, documentSnapshot.Text, WellKnownChecksumObjects.SourceText).ConfigureAwait(false); // TODO: do we need version? additionals.Add( DocumentInfo.Create( documentInfo.Id, documentInfo.Name, documentInfo.Folders, documentInfo.SourceCodeKind, TextLoader.From(TextAndVersion.Create(text, VersionStamp.Create())), documentInfo.FilePath, documentInfo.IsGenerated)); } var projectInfo = await GetValueAsync <ProjectChecksumObjectInfo>(service, projectSnapshot.Info, WellKnownChecksumObjects.ProjectChecksumObjectInfo).ConfigureAwait(false); var compilationOptions = await GetValueAsync <CompilationOptions>(service, projectSnapshot.CompilationOptions, WellKnownChecksumObjects.CompilationOptions).ConfigureAwait(false); var parseOptions = await GetValueAsync <ParseOptions>(service, projectSnapshot.ParseOptions, WellKnownChecksumObjects.ParseOptions).ConfigureAwait(false); projects.Add( ProjectInfo.Create( projectInfo.Id, projectInfo.Version, projectInfo.Name, projectInfo.AssemblyName, projectInfo.Language, projectInfo.FilePath, projectInfo.OutputFilePath, compilationOptions, parseOptions, documents, p2p, metadata, analyzers, additionals)); } return(workspace.AddSolution(SolutionInfo.Create(solutionInfo.Id, solutionInfo.Version, solutionInfo.FilePath, projects))); }
protected abstract Task <Session> CreateServiceSessionAsync(string serviceName, ChecksumScope snapshot, object callbackTarget, CancellationToken cancellationToken);
protected abstract Task <Session> CreateCodeAnalysisServiceSessionAsync(ChecksumScope snapshot, object callbackTarget, CancellationToken cancellationToken);
protected override async Task <Session> CreateServiceSessionAsync(string serviceName, ChecksumScope snapshot, object callbackTarget, CancellationToken cancellationToken) { // get stream from service hub to communicate snapshot/asset related information // this is the back channel the system uses to move data between VS and remote host var snapshotStream = await _hubClient.RequestServiceAsync(WellKnownServiceHubServices.SnapshotService, cancellationToken).ConfigureAwait(false); // get stream from service hub to communicate service specific information // this is what consumer actually use to communicate information var serviceStream = await _hubClient.RequestServiceAsync(serviceName, cancellationToken).ConfigureAwait(false); return(new JsonRpcSession(snapshot, snapshotStream, callbackTarget, serviceStream, cancellationToken)); }