コード例 #1
0
ファイル: MetadataOnlyImage.cs プロジェクト: sperling/cskarp
        public static MetadataOnlyImage Create(ITemporaryStorageService service, Compilation compilation, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            using (Logger.LogBlock(FunctionId.Workspace_SkeletonAssembly_EmitMetadataOnlyImage, cancellationToken))
            {
                // TODO: make it to use SerializableBytes.WritableStream rather than MemoryStream so that
                //       we don't allocate anything for skeleton assembly.
                using (var stream = SerializableBytes.CreateWritableStream())
                {
                    // note: cloning compilation so we don't retain all the generated symbols after its emitted.
                    // * REVIEW * is cloning clone p2p reference compilation as well?
                    var emitResult = compilation.Clone().EmitMetadataOnly(stream, cancellationToken: cancellationToken);

                    if (emitResult.Success)
                    {
                        var storage = service.CreateTemporaryStorage(cancellationToken);

                        stream.Position = 0;
                        storage.WriteStream(stream, cancellationToken);

                        return(new MetadataOnlyImage(storage, compilation.AssemblyName));
                    }
                }
            }

            return(Empty);
        }
コード例 #2
0
 public RecoverableTextAndVersion(
     ValueSource <TextAndVersion> initialTextAndVersion,
     ITemporaryStorageService storageService)
 {
     _initialSource  = initialTextAndVersion;
     _storageService = storageService;
 }
コード例 #3
0
        public static MetadataOnlyImage Create(ITemporaryStorageService service, Compilation compilation, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            using (Logger.LogBlock(FunctionId.Workspace_SkeletonAssembly_EmitMetadataOnlyImage, cancellationToken))
            {
                // TODO: make it to use SerializableBytes.WritableStream rather than MemoryStream so that
                //       we don't allocate anything for skeleton assembly.
                using (var stream = SerializableBytes.CreateWritableStream())
                {
                    // note: cloning compilation so we don't retain all the generated symbols after its emitted.
                    // * REVIEW * is cloning clone p2p reference compilation as well?
                    var emitResult = compilation.Clone().Emit(stream, options: s_emitOptions, cancellationToken: cancellationToken);

                    if (emitResult.Success)
                    {
                        var storage = service.CreateTemporaryStreamStorage(cancellationToken);

                        stream.Position = 0;
                        storage.WriteStream(stream, cancellationToken);

                        return new MetadataOnlyImage(storage, compilation.AssemblyName);
                    }
                }
            }

            return Empty;
        }
コード例 #4
0
 protected AbstractReferenceSerializationService(
     ITemporaryStorageService storageService,
     IDocumentationProviderService documentationService)
 {
     _storageService       = storageService;
     _documentationService = documentationService;
 }
コード例 #5
0
 public RecoverableTextAndVersion(
     ValueSource <TextAndVersion> initialTextAndVersion,
     ITemporaryStorageService storageService)
     : base(initialTextAndVersion)
 {
     this.storageService = storageService;
 }
コード例 #6
0
ファイル: SolutionServices.cs プロジェクト: Rickinio/roslyn
 public SolutionServices(Workspace workspace)
 {
     this.Workspace = workspace;
     this.TemporaryStorage = workspace.Services.GetService<ITemporaryStorageService>();
     this.MetadataService = workspace.Services.GetService<IMetadataService>();
     this.CacheService = workspace.Services.GetService<IProjectCacheHostService>();
 }
コード例 #7
0
 public SolutionServices(Workspace workspace)
 {
     this.Workspace        = workspace;
     this.TemporaryStorage = workspace.Services.GetService <ITemporaryStorageService>();
     this.MetadataService  = workspace.Services.GetService <IMetadataService>();
     this.CacheService     = workspace.Services.GetService <IProjectCacheHostService>();
 }
コード例 #8
0
        internal MonoDevelopMetadataReferenceManager(ITemporaryStorageService temporaryStorageService)
        {
            _metadataCache          = new MetadataCache();
            _metadataReferenceCache = new MetadataReferenceCache();

            _temporaryStorageService = temporaryStorageService;
            Debug.Assert(temporaryStorageService != null);
        }
コード例 #9
0
ファイル: SolutionServices.cs プロジェクト: EkardNT/Roslyn
 public SolutionServices(Workspace workspace)
 {
     this.Workspace = workspace;
     this.TemporaryStorage = workspace.Services.GetService<ITemporaryStorageService>();
     this.TextFactory = workspace.Services.GetService<ITextFactoryService>();
     this.TextCache = workspace.Services.GetService<ITextCacheService>();
     this.CompilationCacheService = workspace.Services.GetService<ICompilationCacheService>();
     this.MetadataReferenceProviderService = workspace.Services.GetService<IMetadataReferenceProviderService>();
 }
コード例 #10
0
 public SolutionServices(Workspace workspace)
 {
     this.Workspace                        = workspace;
     this.TemporaryStorage                 = workspace.Services.GetService <ITemporaryStorageService>();
     this.TextFactory                      = workspace.Services.GetService <ITextFactoryService>();
     this.TextCache                        = workspace.Services.GetService <ITextCacheService>();
     this.CompilationCacheService          = workspace.Services.GetService <ICompilationCacheService>();
     this.MetadataReferenceProviderService = workspace.Services.GetService <IMetadataReferenceProviderService>();
 }
コード例 #11
0
ファイル: MetadataOnlyImage.cs プロジェクト: stark-lang/stark
        public static MetadataOnlyImage Create(Workspace workspace, ITemporaryStorageService service, Compilation compilation, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            try
            {
                workspace.LogTestMessage($"Beginning to create a skeleton assembly for {compilation.AssemblyName}...");

                using (Logger.LogBlock(FunctionId.Workspace_SkeletonAssembly_EmitMetadataOnlyImage, cancellationToken))
                {
                    // TODO: make it to use SerializableBytes.WritableStream rather than MemoryStream so that
                    //       we don't allocate anything for skeleton assembly.
                    using (var stream = SerializableBytes.CreateWritableStream())
                    {
                        // note: cloning compilation so we don't retain all the generated symbols after its emitted.
                        // * REVIEW * is cloning clone p2p reference compilation as well?
                        var emitResult = compilation.Clone().Emit(stream, options: s_emitOptions, cancellationToken: cancellationToken);

                        if (emitResult.Success)
                        {
                            workspace.LogTestMessage($"Successfully emitted a skeleton assembly for {compilation.AssemblyName}");
                            var storage = service.CreateTemporaryStreamStorage(cancellationToken);

                            stream.Position = 0;
                            storage.WriteStream(stream, cancellationToken);

                            return(new MetadataOnlyImage(storage, compilation.AssemblyName));
                        }
                        else
                        {
                            workspace.LogTestMessage($"Failed to create a skeleton assembly for {compilation.AssemblyName}:");

                            foreach (var diagnostic in emitResult.Diagnostics)
                            {
                                workspace.LogTestMessage("  " + diagnostic.GetMessage());
                            }

                            // log emit failures so that we can improve most common cases
                            Logger.Log(FunctionId.MetadataOnlyImage_EmitFailure, KeyValueLogMessage.Create(m =>
                            {
                                // log errors in the format of
                                // CS0001:1;CS002:10;...
                                var groups  = emitResult.Diagnostics.GroupBy(d => d.Id).Select(g => $"{g.Key}:{g.Count()}");
                                m["Errors"] = string.Join(";", groups);
                            }));
                        }
                    }
                }
            }
            finally
            {
                workspace.LogTestMessage($"Done trying to create a skeleton assembly for {compilation.AssemblyName}");
            }

            return(Empty);
        }
コード例 #12
0
 public SolutionServices(Workspace workspace, IWorkspaceServiceProvider workspaceServices)
 {
     this.Workspace                 = workspace;
     this.WorkspaceServices         = workspaceServices;
     this.LanguageServicesFactory   = WorkspaceServices.GetService <ILanguageServiceProviderFactory>();
     this.TemporaryStorage          = WorkspaceServices.GetService <ITemporaryStorageService>();
     this.TextFactory               = WorkspaceServices.GetService <ITextFactoryService>();
     this.TextCache                 = WorkspaceServices.GetService <ITextCacheService>();
     this.CompilationCacheService   = WorkspaceServices.GetService <ICompilationCacheService>();
     this.MetadataReferenceProvider = WorkspaceServices.GetService <IMetadataReferenceProviderService>().GetProvider();
 }
コード例 #13
0
ファイル: SolutionServices.cs プロジェクト: riversky/roslyn
 public SolutionServices(Workspace workspace, IWorkspaceServiceProvider workspaceServices)
 {
     this.Workspace = workspace;
     this.WorkspaceServices = workspaceServices;
     this.LanguageServicesFactory = WorkspaceServices.GetService<ILanguageServiceProviderFactory>();
     this.TemporaryStorage = WorkspaceServices.GetService<ITemporaryStorageService>();
     this.TextFactory = WorkspaceServices.GetService<ITextFactoryService>();
     this.TextCache = WorkspaceServices.GetService<ITextCacheService>();
     this.CompilationCacheService = WorkspaceServices.GetService<ICompilationCacheService>();
     this.MetadataReferenceProvider = WorkspaceServices.GetService<IMetadataReferenceProviderService>().GetProvider();
 }
コード例 #14
0
        private protected SerializerService(HostWorkspaceServices workspaceServices)
        {
            _workspaceServices = workspaceServices;

            _storageService         = workspaceServices.GetRequiredService <ITemporaryStorageService>();
            _textService            = workspaceServices.GetRequiredService <ITextFactoryService>();
            _analyzerLoaderProvider = workspaceServices.GetRequiredService <IAnalyzerAssemblyLoaderProvider>();
            _documentationService   = workspaceServices.GetService <IDocumentationProviderService>();

            _lazyLanguageSerializationService = new ConcurrentDictionary <string, IOptionsSerializationService>(concurrencyLevel: 2, capacity: _workspaceServices.SupportedLanguages.Count());
        }
コード例 #15
0
        public VisualStudioProjectOptionsProcessor(
            VisualStudioProject project,
            HostWorkspaceServices workspaceServices)
        {
            _project                  = project ?? throw new ArgumentNullException(nameof(project));
            _workspaceServices        = workspaceServices;
            _commandLineParserService = workspaceServices.GetLanguageServices(project.Language).GetRequiredService <ICommandLineParserService>();
            _temporaryStorageService  = workspaceServices.GetRequiredService <ITemporaryStorageService>();

            // Set up _commandLineArgumentsForCommandLine to a default. No lock taken since we're in
            // the constructor so nothing can race.

            // Silence NRT warning.  This will be initialized by the call below to ReparseCommandLineIfChanged_NoLock.
            _commandLineArgumentsForCommandLine = null !;
            ReparseCommandLineIfChanged_NoLock(commandLine: "");
        }
コード例 #16
0
        private void TestTemporaryStorage(ITemporaryStorageService temporaryStorageService, SourceText text)
        {
            // create a temporary storage location
            var temporaryStorage = temporaryStorageService.CreateTemporaryTextStorage(System.Threading.CancellationToken.None);

            // write text into it
            temporaryStorage.WriteTextAsync(text).Wait();

            // read text back from it
            var text2 = temporaryStorage.ReadTextAsync().Result;

            Assert.NotSame(text, text2);
            Assert.Equal(text.ToString(), text2.ToString());

            temporaryStorage.Dispose();
        }
コード例 #17
0
        internal VisualStudioMetadataReferenceManager(IServiceProvider serviceProvider, ITemporaryStorageService temporaryStorageService)
        {
            _metadataCache      = new MetadataCache();
            _runtimeDirectories = GetRuntimeDirectories();

            XmlMemberIndexService    = (IVsXMLMemberIndexService)serviceProvider.GetService(typeof(SVsXMLMemberIndexService));
            SmartOpenScopeServiceOpt = (IVsSmartOpenScope)serviceProvider.GetService(typeof(SVsSmartOpenScope));

            FileChangeService        = (IVsFileChangeEx)serviceProvider.GetService(typeof(SVsFileChangeEx));
            _temporaryStorageService = temporaryStorageService;

            Debug.Assert(XmlMemberIndexService != null);
            Debug.Assert(SmartOpenScopeServiceOpt != null);
            Debug.Assert(FileChangeService != null);
            Debug.Assert(temporaryStorageService != null);
        }
コード例 #18
0
        private void TestTemporaryStorage(ITemporaryStorageService temporaryStorageService, SourceText text)
        {
            // create a temporary storage location
            var temporaryStorage = temporaryStorageService.CreateTemporaryStorage(System.Threading.CancellationToken.None);

            // write text into it
            temporaryStorage.WriteTextAsync(text).Wait();

            // read text back from it
            var text2 = temporaryStorage.ReadTextAsync().Result;

            Assert.NotSame(text, text2);
            Assert.Equal(text.ToString(), text2.ToString());

            temporaryStorage.Dispose();
        }
コード例 #19
0
        internal VisualStudioMetadataReferenceManager(IServiceProvider serviceProvider, ITemporaryStorageService temporaryStorageService)
        {
            _metadataCache = new MetadataCache();
            _runtimeDirectories = GetRuntimeDirectories();

            _xmlMemberIndexService = (IVsXMLMemberIndexService)serviceProvider.GetService(typeof(SVsXMLMemberIndexService));
            _smartOpenScopeService = (IVsSmartOpenScope)serviceProvider.GetService(typeof(SVsSmartOpenScope));

            _fileChangeService = (IVsFileChangeEx)serviceProvider.GetService(typeof(SVsFileChangeEx));
            _temporaryStorageService = temporaryStorageService;

            Debug.Assert(_xmlMemberIndexService != null);
            Debug.Assert(_smartOpenScopeService != null);
            Debug.Assert(_fileChangeService != null);
            Debug.Assert(temporaryStorageService != null);
        }
コード例 #20
0
        public static MetadataOnlyImage Create(Workspace workspace, ITemporaryStorageService service, Compilation compilation, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            try
            {
                workspace.LogTestMessage($"Beginning to create a skeleton assembly for {compilation.AssemblyName}...");

                using (Logger.LogBlock(FunctionId.Workspace_SkeletonAssembly_EmitMetadataOnlyImage, cancellationToken))
                {
                    // TODO: make it to use SerializableBytes.WritableStream rather than MemoryStream so that
                    //       we don't allocate anything for skeleton assembly.
                    using (var stream = SerializableBytes.CreateWritableStream())
                    {
                        // note: cloning compilation so we don't retain all the generated symbols after its emitted.
                        // * REVIEW * is cloning clone p2p reference compilation as well?
                        var emitResult = compilation.Clone().Emit(stream, options: s_emitOptions, cancellationToken: cancellationToken);

                        if (emitResult.Success)
                        {
                            workspace.LogTestMessage($"Successfully emitted a skeleton assembly for {compilation.AssemblyName}");
                            var storage = service.CreateTemporaryStreamStorage(cancellationToken);

                            stream.Position = 0;
                            storage.WriteStream(stream, cancellationToken);

                            return new MetadataOnlyImage(storage, compilation.AssemblyName);
                        }
                        else
                        {
                            workspace.LogTestMessage($"Failed to create a skeleton assembly for {compilation.AssemblyName}:");

                            foreach (var diagnostic in emitResult.Diagnostics)
                            {
                                workspace.LogTestMessage("  " + diagnostic.GetMessage());
                            }
                        }
                    }
                }
            }
            finally
            {
                workspace.LogTestMessage($"Done trying to create a skeleton assembly for {compilation.AssemblyName}");
            }

            return Empty;
        }
コード例 #21
0
        public static MetadataOnlyImage Create(Workspace workspace, ITemporaryStorageService service, Compilation compilation, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            try
            {
                workspace.LogTestMessage($"Beginning to create a skeleton assembly for {compilation.AssemblyName}...");

                using (Logger.LogBlock(FunctionId.Workspace_SkeletonAssembly_EmitMetadataOnlyImage, cancellationToken))
                {
                    // TODO: make it to use SerializableBytes.WritableStream rather than MemoryStream so that
                    //       we don't allocate anything for skeleton assembly.
                    using (var stream = SerializableBytes.CreateWritableStream())
                    {
                        // note: cloning compilation so we don't retain all the generated symbols after its emitted.
                        // * REVIEW * is cloning clone p2p reference compilation as well?
                        var emitResult = compilation.Clone().Emit(stream, options: s_emitOptions, cancellationToken: cancellationToken);

                        if (emitResult.Success)
                        {
                            workspace.LogTestMessage($"Successfully emitted a skeleton assembly for {compilation.AssemblyName}");
                            var storage = service.CreateTemporaryStreamStorage(cancellationToken);

                            stream.Position = 0;
                            storage.WriteStream(stream, cancellationToken);

                            return(new MetadataOnlyImage(storage, compilation.AssemblyName));
                        }
                        else
                        {
                            workspace.LogTestMessage($"Failed to create a skeleton assembly for {compilation.AssemblyName}:");

                            foreach (var diagnostic in emitResult.Diagnostics)
                            {
                                workspace.LogTestMessage("  " + diagnostic.GetMessage());
                            }
                        }
                    }
                }
            }
            finally
            {
                workspace.LogTestMessage($"Done trying to create a skeleton assembly for {compilation.AssemblyName}");
            }

            return(Empty);
        }
コード例 #22
0
        public void Store(SyntaxTree tree, SyntaxNode root, ITemporaryStorageService service, CancellationToken cancellationToken)
        {
            ITemporaryStorage storage;
            if (map.TryGetValue(tree, out storage))
            {
                // we already have it serialized to temporary storage
                return;
            }

            // tree will be always held alive in memory, but nodes come and go. serialize nodes to storage
            using (var stream = SerializableBytes.CreateWritableStream())
            {
                root.SerializeTo(stream, cancellationToken);
                stream.Position = 0;

                storage = service.CreateTemporaryStorage(cancellationToken);
                storage.WriteStream(stream, cancellationToken);
            }

            SaveTreeToMap(tree, storage);
        }
コード例 #23
0
        public void Store(SyntaxTree tree, SyntaxNode root, ITemporaryStorageService service, CancellationToken cancellationToken)
        {
            ITemporaryStorage storage;

            if (map.TryGetValue(tree, out storage))
            {
                // we already have it serialized to temporary storage
                return;
            }

            // tree will be always held alive in memory, but nodes come and go. serialize nodes to storage
            using (var stream = SerializableBytes.CreateWritableStream())
            {
                root.SerializeTo(stream, cancellationToken);
                stream.Position = 0;

                storage = service.CreateTemporaryStorage(cancellationToken);
                storage.WriteStream(stream, cancellationToken);
            }

            SaveTreeToMap(tree, storage);
        }
コード例 #24
0
 protected AbstractReferenceSerializationService(ITemporaryStorageService storageService)
 {
     _storageService = storageService;
 }
コード例 #25
0
 public void EnqueueStore(SyntaxTree tree, SyntaxNode root, ITemporaryStorageService service, CancellationToken cancellationToken)
 {
     // this can be used more like in fire and forget fashion
     EnqueueStoreAsync(tree, root, service, cancellationToken);
 }
コード例 #26
0
 public Task EnqueueStoreAsync(SyntaxTree tree, SyntaxNode root, ITemporaryStorageService service, CancellationToken cancellationToken)
 {
     // returned task can be used to monitor when actual store happened.
     return(queue.ScheduleTask(() => Store(tree, root, service, cancellationToken), cancellationToken));
 }
コード例 #27
0
 public void EnqueueStore(SyntaxTree tree, SyntaxNode root, ITemporaryStorageService service, CancellationToken cancellationToken)
 {
     // this can be used more like in fire and forget fashion
     EnqueueStoreAsync(tree, root, service, cancellationToken);
 }
コード例 #28
0
 public Task EnqueueStoreAsync(SyntaxTree tree, SyntaxNode root, ITemporaryStorageService service, CancellationToken cancellationToken)
 {
     // returned task can be used to monitor when actual store happened.
     return queue.ScheduleTask(() => Store(tree, root, service, cancellationToken), cancellationToken);
 }
コード例 #29
0
 protected AbstractReferenceSerializationService(ITemporaryStorageService storageService)
 {
     _storageService = storageService;
 }
コード例 #30
0
 public Service(ITemporaryStorageService service) : base(service)
 {
 }
コード例 #31
0
 public Service(ITemporaryStorageService service) : base(service)
 {
 }
 public Service(ITemporaryStorageService service, IDocumentationProviderService documentationService) :
     base(service, documentationService)
 {
 }