Exemple #1
0
        public RoslynServices(int sessionId, AssetStorage storage)
        {
            _sessionId = sessionId;

            AssetService = new AssetService(_sessionId, storage);
            SolutionService = new SolutionService(AssetService);
            CompilationService = new CompilationService(SolutionService);
        }
Exemple #2
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);
        }
Exemple #3
0
        public RoslynServices(int scopeId, AssetStorage storage)
        {
            _scopeId = scopeId;

            AssetService       = new AssetService(_scopeId, storage);
            SolutionService    = new SolutionService(AssetService);
            CompilationService = new CompilationService(SolutionService);
        }
        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);
        }
Exemple #5
0
        public Task SynchronizeGlobalAssetsAsync(PinnedSolutionInfo solutionInfo, Checksum[] checksums, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (RoslynLogger.LogBlock(FunctionId.RemoteHostService_SynchronizeGlobalAssetsAsync, Checksum.GetChecksumsLogInfo, checksums, cancellationToken))
                {
                    var assetProvider = SolutionService.CreateAssetProvider(solutionInfo, AssetStorage);
                    var assets = await assetProvider.GetAssetsAsync <object>(checksums, cancellationToken).ConfigureAwait(false);

                    foreach (var(checksum, value) in assets)
                    {
                        AssetStorage.TryAddGlobalAsset(checksum, value);
                    }
                }
            }, cancellationToken));
        }
        public async Task TestCreation()
        {
            var code = @"class Test { void Method() { } }";

            using (var workspace = await TestWorkspace.CreateCSharpAsync(code))
            {
                var solution = workspace.CurrentSolution;
                var solutionChecksum = await solution.State.GetChecksumAsync(CancellationToken.None);

                var map = solution.GetAssetMap();

                var sessionId = 0;
                var storage = new AssetStorage(enableCleanup: false);
                var source = new MyAssetSource(storage, sessionId, map);
                var service = new SolutionService(new AssetService(sessionId, storage));

                var synched = await service.GetSolutionAsync(solutionChecksum, CancellationToken.None);

                Assert.Equal(solutionChecksum, await synched.State.GetChecksumAsync(CancellationToken.None));
            }
        }
Exemple #7
0
 public CompilationService(SolutionService solutionService)
 {
     _solutionService = solutionService;
 }
Exemple #8
0
 protected SolutionService CreateSolutionService(PinnedSolutionInfo solutionInfo)
 => new SolutionService(SolutionService.CreateAssetProvider(solutionInfo, AssetStorage));
 public CompilationService(SolutionService solutionService)
 {
     _solutionService = solutionService;
 }
        private static async Task<SolutionService> GetSolutionServiceAsync(Solution solution, Dictionary<Checksum, object> map = null)
        {
            // make sure checksum is calculated
            await solution.State.GetChecksumAsync(CancellationToken.None);

            map = map ?? new Dictionary<Checksum, object>();
            solution.AppendAssetMap(map);

            var sessionId = 0;
            var storage = new AssetStorage();
            var source = new TestAssetSource(storage, sessionId, map);
            var service = new SolutionService(new AssetService(sessionId, storage));

            return service;
        }