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); }
public RecoverableTextAndVersion( ValueSource <TextAndVersion> initialTextAndVersion, ITemporaryStorageService storageService) { _initialSource = initialTextAndVersion; _storageService = storageService; }
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; }
protected AbstractReferenceSerializationService( ITemporaryStorageService storageService, IDocumentationProviderService documentationService) { _storageService = storageService; _documentationService = documentationService; }
public RecoverableTextAndVersion( ValueSource <TextAndVersion> initialTextAndVersion, ITemporaryStorageService storageService) : base(initialTextAndVersion) { this.storageService = storageService; }
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>(); }
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>(); }
internal MonoDevelopMetadataReferenceManager(ITemporaryStorageService temporaryStorageService) { _metadataCache = new MetadataCache(); _metadataReferenceCache = new MetadataReferenceCache(); _temporaryStorageService = temporaryStorageService; Debug.Assert(temporaryStorageService != null); }
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>(); }
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>(); }
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); }
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(); }
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(); }
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()); }
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: ""); }
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(); }
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); }
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(); }
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); }
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; }
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); }
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); }
protected AbstractReferenceSerializationService(ITemporaryStorageService storageService) { _storageService = storageService; }
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); }
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)); }
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); }
public Service(ITemporaryStorageService service) : base(service) { }
public Service(ITemporaryStorageService service, IDocumentationProviderService documentationService) : base(service, documentationService) { }