Exemplo n.º 1
0
        public void UnregisterSnapshot(ChecksumScope snapshot)
        {
            // calling it multiple times for same snapshot is not allowed.
            RootTreeNode dummy;

            Contract.ThrowIfFalse(_rootTreeNodes.TryRemove(snapshot, out dummy));
        }
Exemplo n.º 2
0
            public async Task<ChecksumScope> CreateChecksumAsync(Solution solution, CancellationToken cancellationToken)
            {
                // TODO: add logging mechanism
                var cache = _caches.CreateRootTreeNodeCache(solution);

                var builder = new SnapshotBuilder(cache);
                var snapshot = new ChecksumScope(_caches, cache, await builder.BuildAsync(solution, cancellationToken).ConfigureAwait(false));

                return snapshot;
            }
Exemplo n.º 3
0
            public async Task <ChecksumScope> CreateChecksumAsync(Solution solution, CancellationToken cancellationToken)
            {
                // TODO: add logging mechanism
                var cache = _caches.CreateRootTreeNodeCache(solution);

                var builder  = new SnapshotBuilder(cache);
                var snapshot = new ChecksumScope(_caches, cache, await builder.BuildAsync(solution, cancellationToken).ConfigureAwait(false));

                return(snapshot);
            }
        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);
        }
Exemplo n.º 5
0
            public async Task<ChecksumScope> CreateChecksumAsync(Solution solution, CancellationToken cancellationToken)
            {
                using (Logger.LogBlock(FunctionId.SolutionChecksumServiceFactory_CreateChecksumAsync, cancellationToken))
                {
                    var cache = _caches.CreateRootTreeNodeCache(solution);

                    var builder = new SnapshotBuilder(cache);
                    var snapshot = new ChecksumScope(_caches, cache, await builder.BuildAsync(solution, cancellationToken).ConfigureAwait(false));

                    return snapshot;
                }
            }
Exemplo n.º 6
0
            public async Task<ChecksumScope> CreateChecksumAsync(Solution solution, CancellationToken cancellationToken)
            {
                using (Logger.LogBlock(FunctionId.SolutionChecksumServiceFactory_CreateChecksumAsync, cancellationToken))
                {
                    var rootTreeNode = _treeCollection.CreateRootTreeNode(solution.State);

                    var builder = new ChecksumTreeBuilder(rootTreeNode);
                    var snapshot = new ChecksumScope(_treeCollection, rootTreeNode, await builder.BuildAsync(solution.State, cancellationToken).ConfigureAwait(false));

                    return snapshot;
                }
            }
Exemplo n.º 7
0
            public async Task <ChecksumScope> CreateChecksumAsync(Solution solution, CancellationToken cancellationToken)
            {
                using (Logger.LogBlock(FunctionId.SolutionChecksumServiceFactory_CreateChecksumAsync, cancellationToken))
                {
                    var cache = _caches.CreateRootTreeNodeCache(solution);

                    var builder  = new SnapshotBuilder(cache);
                    var snapshot = new ChecksumScope(_caches, cache, await builder.BuildAsync(solution, cancellationToken).ConfigureAwait(false));

                    return(snapshot);
                }
            }
Exemplo n.º 8
0
        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));
        }
Exemplo n.º 9
0
 public void RegisterSnapshot(ChecksumScope snapshot, IRootChecksumTreeNode cache)
 {
     // duplicates are not allowed, there can be multiple snapshots to same solution, so no ref counting.
     Contract.ThrowIfFalse(_rootTreeNodes.TryAdd(snapshot, (RootTreeNode)cache));
 }
            private async Task UpdateSolutionChecksumAsync(CancellationToken cancellationToken)
            {
                using (await _gate.DisposableWaitAsync(cancellationToken).ConfigureAwait(false))
                {
                    // hold onto previous snapshot
                    var previousSnapshot = _lastSnapshot;

                    // create a new one (incrementally update the snapshot)
                    _lastSnapshot = await _checksumService.CreateChecksumAsync(_service.Workspace.CurrentSolution, cancellationToken).ConfigureAwait(false);

                    // let old one go.
                    previousSnapshot?.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;
                }
            }
Exemplo n.º 12
0
 public void UnregisterSnapshot(ChecksumScope snapshot)
 {
     // calling it multiple times for same snapshot is not allowed.
     RootTreeNode dummy;
     Contract.ThrowIfFalse(_rootTreeNodes.TryRemove(snapshot, out dummy));
 }
Exemplo n.º 13
0
 public void RegisterSnapshot(ChecksumScope snapshot, IRootChecksumTreeNode cache)
 {
     // duplicates are not allowed, there can be multiple snapshots to same solution, so no ref counting.
     Contract.ThrowIfFalse(_rootTreeNodes.TryAdd(snapshot, (RootTreeNode)cache));
 }
 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();
 }
            public override void Shutdown()
            {
                base.Shutdown();

                // stop listening workspace change event
                _workspace.WorkspaceChanged -= OnWorkspaceChanged;

                CancelAndDispose(_globalOperationCancellationSource);

                // release last snapshot
                _lastSnapshot?.Dispose();
                _lastSnapshot = null;
            }