Example #1
0
            private IList <(Checksum, object)> ReadAssets(
                Stream stream, int scopeId, ISet <Checksum> checksums, CancellationToken cancellationToken)
            {
                var results = new List <(Checksum, object)>();

                using (var reader = ObjectReader.TryGetReader(stream, cancellationToken))
                {
                    Debug.Assert(reader != null,
                                 @"We only ge a reader for data transmitted between live processes.
This data should always be correct as we're never persisting the data between sessions.");

                    var responseScopeId = reader.ReadInt32();
                    Contract.ThrowIfFalse(scopeId == responseScopeId);

                    var count = reader.ReadInt32();
                    Contract.ThrowIfFalse(count == checksums.Count);

                    for (var i = 0; i < count; i++)
                    {
                        var responseChecksum = Checksum.ReadFrom(reader);
                        Contract.ThrowIfFalse(checksums.Contains(responseChecksum));

                        var kind = (WellKnownSynchronizationKind)reader.ReadInt32();

                        // in service hub, cancellation means simply closed stream
                        var @object = AssetService.Deserialize <object>(kind, reader, cancellationToken);

                        results.Add((responseChecksum, @object));
                    }

                    return(results);
                }
            }
Example #2
0
        public SolutionCreator(AssetService assetService, Solution baseSolution, CancellationToken cancellationToken)
        {
            Contract.ThrowIfNull(baseSolution);

            _assetService      = assetService;
            _baseSolution      = baseSolution;
            _cancellationToken = cancellationToken;
        }
Example #3
0
        public RoslynServices(int scopeId, AssetStorage storage, HostServices hostServices)
        {
            _scopeId = scopeId;

            AssetService       = new AssetService(_scopeId, storage, SolutionService.PrimaryWorkspace);
            SolutionService    = new SolutionService(AssetService);
            CompilationService = new CompilationService(SolutionService);
        }
Example #4
0
        public RoslynServices(int scopeId, AssetStorage storage)
        {
            _scopeId = scopeId;

            AssetService       = new AssetService(_scopeId, storage);
            SolutionService    = new SolutionService(AssetService);
            CompilationService = new CompilationService(SolutionService);
        }
Example #5
0
        public RoslynServices(int scopeId, AssetStorage storage, HostServices hostServices)
        {
            _scopeId = scopeId;

            var mefHostExportProvider = (IMefHostExportProvider)hostServices;
            var primaryWorkspace      = mefHostExportProvider.GetExports <PrimaryWorkspace>().Single().Value;
            var workspace             = (RemoteWorkspace)primaryWorkspace.Workspace ?? new RemoteWorkspace();

            AssetService       = new AssetService(_scopeId, storage, workspace);
            SolutionService    = new SolutionService(AssetService);
            CompilationService = new CompilationService(SolutionService);
        }
Example #6
0
 public SolutionService(AssetService assetService)
 {
     _assetService = assetService;
 }
Example #7
0
 public ChecksumSynchronizer(AssetService assetService)
 {
     _assetService = assetService;
 }
Example #8
0
        private async Task <Dictionary <ProjectId, ProjectStateChecksums> > GetProjectMapAsync(AssetService assetService, HashSet <Checksum> projects)
        {
            var map = new Dictionary <ProjectId, ProjectStateChecksums>();

            var projectChecksums = await assetService.GetAssetsAsync <ProjectStateChecksums>(projects, _cancellationToken).ConfigureAwait(false);

            var infos = await assetService.GetAssetsAsync <ProjectInfo.ProjectAttributes>(projectChecksums.Select(p => p.Item2.Info), _cancellationToken).ConfigureAwait(false);

            foreach (var kv in projectChecksums)
            {
                var info = await assetService.GetAssetAsync <ProjectInfo.ProjectAttributes>(kv.Item2.Info, _cancellationToken).ConfigureAwait(false);

                map.Add(info.Id, kv.Item2);
            }

            return(map);
        }
Example #9
0
        private async Task <Dictionary <DocumentId, DocumentStateChecksums> > GetDocumentMapAsync(AssetService assetService, HashSet <Checksum> documents)
        {
            var map = new Dictionary <DocumentId, DocumentStateChecksums>();

            var documentChecksums = await assetService.GetAssetsAsync <DocumentStateChecksums>(documents, _cancellationToken).ConfigureAwait(false);

            foreach (var kv in documentChecksums)
            {
                var info = await assetService.GetAssetAsync <DocumentInfo.DocumentAttributes>(kv.Item2.Info, _cancellationToken).ConfigureAwait(false);

                map.Add(info.Id, kv.Item2);
            }

            return(map);
        }
Example #10
0
 public SolutionCreator(AssetService assetService, Solution baseSolution, CancellationToken cancellationToken)
 {
     _assetService      = assetService;
     _baseSolution      = baseSolution;
     _cancellationToken = cancellationToken;
 }