private static ExportProvider CreateExportProvider(string applicationDataFolder) { var stopwatch = Stopwatch.StartNew(); string defaultPluginsPath = Path.Combine(new FileInfo(Application.ExecutablePath).Directory.FullName, "Plugins"); string userPluginsPath = UserPluginsPath; var pluginFiles = PluginsPathScanner.GetFiles(defaultPluginsPath, userPluginsPath); #if !CI_BUILD pluginFiles = pluginFiles.Where(f => f.Name.StartsWith("GitExtensions.")); #endif var cacheFile = Path.Combine(applicationDataFolder ?? "ignored", "Plugins", "composition.cache"); IExportProviderFactory exportProviderFactory; if (applicationDataFolder != null && File.Exists(cacheFile)) { using (var cacheStream = File.OpenRead(cacheFile)) { exportProviderFactory = ThreadHelper.JoinableTaskFactory.Run(() => new CachedComposition().LoadExportProviderFactoryAsync(cacheStream, Resolver.DefaultInstance)); } } else { var assemblies = pluginFiles.Select(assemblyFile => TryLoadAssembly(assemblyFile)).Where(assembly => assembly != null).ToArray(); var discovery = PartDiscovery.Combine( new AttributedPartDiscoveryV1(Resolver.DefaultInstance), new AttributedPartDiscovery(Resolver.DefaultInstance, isNonPublicSupported: true)); var parts = ThreadHelper.JoinableTaskFactory.Run(() => discovery.CreatePartsAsync(assemblies)); var catalog = ComposableCatalog.Create(Resolver.DefaultInstance).AddParts(parts); var configuration = CompositionConfiguration.Create(catalog.WithCompositionService()); var runtimeComposition = RuntimeComposition.CreateRuntimeComposition(configuration); if (applicationDataFolder != null) { #if false // Composition caching currently disabled Directory.CreateDirectory(Path.Combine(applicationDataFolder, "Plugins")); using (var cacheStream = File.OpenWrite(cacheFile)) { ThreadHelper.JoinableTaskFactory.Run(() => new CachedComposition().SaveAsync(runtimeComposition, cacheStream)); } #endif } exportProviderFactory = runtimeComposition.CreateExportProviderFactory(); } return(exportProviderFactory.CreateExportProvider()); }
private static ExportProvider CreateExportProvider(string?applicationDataFolder) { Stopwatch stopwatch = Stopwatch.StartNew(); string defaultPluginsPath = Path.Combine(new FileInfo(Application.ExecutablePath).Directory.FullName, "Plugins"); string?userPluginsPath = UserPluginsPath; IEnumerable <FileInfo> pluginFiles = PluginsPathScanner.GetFiles(defaultPluginsPath, userPluginsPath); string cacheFile = Path.Combine(applicationDataFolder ?? "ignored", "Plugins", "composition.cache"); IExportProviderFactory exportProviderFactory; if (applicationDataFolder is not null && File.Exists(cacheFile)) { using FileStream cacheStream = File.OpenRead(cacheFile); exportProviderFactory = ThreadHelper.JoinableTaskFactory.Run(() => new CachedComposition().LoadExportProviderFactoryAsync(cacheStream, Resolver.DefaultInstance)); }
private static ExportProvider CreateExportProvider(string?applicationDataFolder) { var stopwatch = Stopwatch.StartNew(); string defaultPluginsPath = Path.Combine(new FileInfo(Application.ExecutablePath).Directory.FullName, "Plugins"); string?userPluginsPath = UserPluginsPath; var pluginFiles = PluginsPathScanner.GetFiles(defaultPluginsPath, userPluginsPath); #if !CI_BUILD pluginFiles = pluginFiles.Where(f => f.Name.StartsWith("GitExtensions.")); #endif var cacheFile = Path.Combine(applicationDataFolder ?? "ignored", "Plugins", "composition.cache"); IExportProviderFactory exportProviderFactory; if (applicationDataFolder is not null && File.Exists(cacheFile)) { using var cacheStream = File.OpenRead(cacheFile); exportProviderFactory = ThreadHelper.JoinableTaskFactory.Run(() => new CachedComposition().LoadExportProviderFactoryAsync(cacheStream, Resolver.DefaultInstance)); }