You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

714 lines
27 KiB

  1. using IPA.Config;
  2. using IPA.Loader.Features;
  3. using IPA.Logging;
  4. using IPA.Utilities;
  5. using Mono.Cecil;
  6. using Newtonsoft.Json;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.IO;
  10. using System.Linq;
  11. using System.Reflection;
  12. using System.Text.RegularExpressions;
  13. using System.Threading.Tasks;
  14. using Version = SemVer.Version;
  15. #if NET3
  16. using Net3_Proxy;
  17. using Path = Net3_Proxy.Path;
  18. using File = Net3_Proxy.File;
  19. using Directory = Net3_Proxy.Directory;
  20. #endif
  21. namespace IPA.Loader
  22. {
  23. /// <summary>
  24. /// A type to manage the loading of plugins.
  25. /// </summary>
  26. public class PluginLoader
  27. {
  28. internal static Task LoadTask() =>
  29. #if NET3
  30. TaskEx.Run(() =>
  31. #else
  32. Task.Run(() =>
  33. #endif
  34. {
  35. YeetIfNeeded();
  36. LoadMetadata();
  37. Resolve();
  38. ComputeLoadOrder();
  39. FilterDisabled();
  40. ResolveDependencies();
  41. });
  42. /// <summary>
  43. /// A class which describes a loaded plugin.
  44. /// </summary>
  45. public class PluginMetadata
  46. {
  47. /// <summary>
  48. /// The assembly the plugin was loaded from.
  49. /// </summary>
  50. /// <value>the loaded Assembly that contains the plugin main type</value>
  51. public Assembly Assembly { get; internal set; }
  52. /// <summary>
  53. /// The TypeDefinition for the main type of the plugin.
  54. /// </summary>
  55. /// <value>the Cecil definition for the plugin main type</value>
  56. public TypeDefinition PluginType { get; internal set; }
  57. /// <summary>
  58. /// The human readable name of the plugin.
  59. /// </summary>
  60. /// <value>the name of the plugin</value>
  61. public string Name { get; internal set; }
  62. /// <summary>
  63. /// The BeatMods ID of the plugin, or null if it doesn't have one.
  64. /// </summary>
  65. /// <value>the updater ID of the plugin</value>
  66. public string Id { get; internal set; }
  67. /// <summary>
  68. /// The version of the plugin.
  69. /// </summary>
  70. /// <value>the version of the plugin</value>
  71. public Version Version { get; internal set; }
  72. /// <summary>
  73. /// The file the plugin was loaded from.
  74. /// </summary>
  75. /// <value>the file the plugin was loaded from</value>
  76. public FileInfo File { get; internal set; }
  77. // ReSharper disable once UnusedAutoPropertyAccessor.Global
  78. /// <summary>
  79. /// The features this plugin requests.
  80. /// </summary>
  81. /// <value>the list of features requested by the plugin</value>
  82. public IReadOnlyList<Feature> Features => InternalFeatures;
  83. internal readonly List<Feature> InternalFeatures = new List<Feature>();
  84. internal bool IsSelf;
  85. /// <summary>
  86. /// Whether or not this metadata object represents a bare manifest.
  87. /// </summary>
  88. /// <value><see langword="true"/> if it is bare, <see langword="false"/> otherwise</value>
  89. public bool IsBare { get; internal set; }
  90. private PluginManifest manifest;
  91. internal HashSet<PluginMetadata> Dependencies { get; } = new HashSet<PluginMetadata>();
  92. internal PluginManifest Manifest
  93. {
  94. get => manifest;
  95. set
  96. {
  97. manifest = value;
  98. Name = value.Name;
  99. Version = value.Version;
  100. Id = value.Id;
  101. }
  102. }
  103. /// <summary>
  104. /// Gets all of the metadata as a readable string.
  105. /// </summary>
  106. /// <returns>the readable printable metadata string</returns>
  107. public override string ToString() => $"{Name}({Id}@{Version})({PluginType?.FullName}) from '{Utils.GetRelativePath(File?.FullName, BeatSaber.InstallPath)}'";
  108. }
  109. /// <summary>
  110. /// A container object for all the data relating to a plugin.
  111. /// </summary>
  112. public class PluginInfo
  113. {
  114. internal IPlugin Plugin { get; set; }
  115. /// <summary>
  116. /// Metadata for the plugin.
  117. /// </summary>
  118. /// <value>the metadata for this plugin</value>
  119. public PluginMetadata Metadata { get; internal set; } = new PluginMetadata();
  120. }
  121. internal static void YeetIfNeeded()
  122. {
  123. string pluginDir = BeatSaber.PluginsPath;
  124. var gameVer = BeatSaber.GameVersion;
  125. var lastVerS = SelfConfig.LastGameVersion_;
  126. var lastVer = lastVerS != null ? new AlmostVersion(lastVerS, gameVer) : null;
  127. if (SelfConfig.YeetMods_ && lastVer != null && gameVer != lastVer)
  128. {
  129. var oldPluginsName = Path.Combine(BeatSaber.InstallPath, $"Old {lastVer} Plugins");
  130. var newPluginsName = Path.Combine(BeatSaber.InstallPath, $"Old {gameVer} Plugins");
  131. if (Directory.Exists(oldPluginsName))
  132. Directory.Delete(oldPluginsName, true);
  133. Directory.Move(pluginDir, oldPluginsName);
  134. if (Directory.Exists(newPluginsName))
  135. Directory.Move(newPluginsName, pluginDir);
  136. else
  137. Directory.CreateDirectory(pluginDir);
  138. }
  139. SelfConfig.Instance.LastGameVersion = gameVer.ToString();
  140. }
  141. internal static List<PluginMetadata> PluginsMetadata = new List<PluginMetadata>();
  142. internal static List<PluginMetadata> DisabledPlugins = new List<PluginMetadata>();
  143. private static readonly Regex embeddedTextDescriptionPattern = new Regex(@"#!\[(.+)\]", RegexOptions.Compiled | RegexOptions.Singleline);
  144. internal static void LoadMetadata()
  145. {
  146. string[] plugins = Directory.GetFiles(BeatSaber.PluginsPath, "*.dll");
  147. try
  148. {
  149. var selfMeta = new PluginMetadata
  150. {
  151. Assembly = Assembly.GetExecutingAssembly(),
  152. File = new FileInfo(Path.Combine(BeatSaber.InstallPath, "IPA.exe")),
  153. PluginType = null,
  154. IsSelf = true
  155. };
  156. string manifest;
  157. using (var manifestReader =
  158. new StreamReader(
  159. selfMeta.Assembly.GetManifestResourceStream(typeof(PluginLoader), "manifest.json") ??
  160. throw new InvalidOperationException()))
  161. manifest = manifestReader.ReadToEnd();
  162. selfMeta.Manifest = JsonConvert.DeserializeObject<PluginManifest>(manifest);
  163. PluginsMetadata.Add(selfMeta);
  164. }
  165. catch (Exception e)
  166. {
  167. Logger.loader.Critical("Error loading own manifest");
  168. Logger.loader.Critical(e);
  169. }
  170. foreach (var plugin in plugins)
  171. {
  172. var metadata = new PluginMetadata
  173. {
  174. File = new FileInfo(Path.Combine(BeatSaber.PluginsPath, plugin)),
  175. IsSelf = false
  176. };
  177. try
  178. {
  179. var pluginModule = AssemblyDefinition.ReadAssembly(plugin, new ReaderParameters
  180. {
  181. ReadingMode = ReadingMode.Immediate,
  182. ReadWrite = false,
  183. AssemblyResolver = new CecilLibLoader()
  184. }).MainModule;
  185. string pluginNs = "";
  186. foreach (var resource in pluginModule.Resources)
  187. {
  188. const string manifestSuffix = ".manifest.json";
  189. if (!(resource is EmbeddedResource embedded) ||
  190. !embedded.Name.EndsWith(manifestSuffix)) continue;
  191. pluginNs = embedded.Name.Substring(0, embedded.Name.Length - manifestSuffix.Length);
  192. string manifest;
  193. using (var manifestReader = new StreamReader(embedded.GetResourceStream()))
  194. manifest = manifestReader.ReadToEnd();
  195. metadata.Manifest = JsonConvert.DeserializeObject<PluginManifest>(manifest);
  196. break;
  197. }
  198. if (metadata.Manifest == null)
  199. {
  200. #if DIRE_LOADER_WARNINGS
  201. Logger.loader.Error($"Could not find manifest.json for {Path.GetFileName(plugin)}");
  202. #else
  203. Logger.loader.Notice($"No manifest.json in {Path.GetFileName(plugin)}");
  204. #endif
  205. continue;
  206. }
  207. foreach (var type in pluginModule.Types)
  208. {
  209. if (type.Namespace != pluginNs) continue;
  210. // TODO: change this to just IPlugin
  211. if (type.HasInterface(typeof(IPlugin).FullName))
  212. {
  213. metadata.PluginType = type;
  214. break;
  215. }
  216. }
  217. if (metadata.PluginType == null)
  218. {
  219. Logger.loader.Error($"No plugin found in the manifest namespace ({pluginNs}) in {Path.GetFileName(plugin)}");
  220. continue;
  221. }
  222. Logger.loader.Debug($"Adding info for {Path.GetFileName(plugin)}");
  223. PluginsMetadata.Add(metadata);
  224. }
  225. catch (Exception e)
  226. {
  227. Logger.loader.Error($"Could not load data for plugin {Path.GetFileName(plugin)}");
  228. Logger.loader.Error(e);
  229. ignoredPlugins.Add(metadata);
  230. }
  231. }
  232. IEnumerable<string> bareManifests = Directory.GetFiles(BeatSaber.PluginsPath, "*.json");
  233. bareManifests = bareManifests.Concat(Directory.GetFiles(BeatSaber.PluginsPath, "*.manifest"));
  234. foreach (var manifest in bareManifests)
  235. {
  236. try
  237. {
  238. var metadata = new PluginMetadata
  239. {
  240. File = new FileInfo(Path.Combine(BeatSaber.PluginsPath, manifest)),
  241. IsSelf = false,
  242. IsBare = true,
  243. };
  244. metadata.Manifest = JsonConvert.DeserializeObject<PluginManifest>(File.ReadAllText(manifest));
  245. Logger.loader.Debug($"Adding info for bare manifest {Path.GetFileName(manifest)}");
  246. PluginsMetadata.Add(metadata);
  247. }
  248. catch (Exception e)
  249. {
  250. Logger.loader.Error($"Could not load data for bare manifest {Path.GetFileName(manifest)}");
  251. Logger.loader.Error(e);
  252. }
  253. }
  254. foreach (var meta in PluginsMetadata)
  255. { // process description include
  256. var lines = meta.Manifest.Description.Split('\n');
  257. var m = embeddedTextDescriptionPattern.Match(lines[0]);
  258. if (m.Success)
  259. {
  260. if (meta.IsBare)
  261. {
  262. Logger.loader.Warn($"Bare manifest cannot specify description file");
  263. meta.Manifest.Description = string.Join("\n", lines.Skip(1).StrJP()); // ignore first line
  264. continue;
  265. }
  266. var name = m.Groups[1].Value;
  267. string description;
  268. if (!meta.IsSelf)
  269. {
  270. var resc = meta.PluginType.Module.Resources.Select(r => r as EmbeddedResource)
  271. .NonNull()
  272. .FirstOrDefault(r => r.Name == name);
  273. if (resc == null)
  274. {
  275. Logger.loader.Warn($"Could not find description file for plugin {meta.Name} ({name}); ignoring include");
  276. meta.Manifest.Description = string.Join("\n", lines.Skip(1).StrJP()); // ignore first line
  277. continue;
  278. }
  279. using (var reader = new StreamReader(resc.GetResourceStream()))
  280. description = reader.ReadToEnd();
  281. }
  282. else
  283. {
  284. using (var descriptionReader =
  285. new StreamReader(
  286. meta.Assembly.GetManifestResourceStream(name) ??
  287. throw new InvalidOperationException()))
  288. description = descriptionReader.ReadToEnd();
  289. }
  290. meta.Manifest.Description = description;
  291. }
  292. }
  293. }
  294. // keep track of these for the updater; it should still be able to update mods not loaded
  295. // TODO: add ignore reason
  296. internal static HashSet<PluginMetadata> ignoredPlugins = new HashSet<PluginMetadata>();
  297. internal static void Resolve()
  298. { // resolves duplicates and conflicts, etc
  299. PluginsMetadata.Sort((a, b) => b.Version.CompareTo(a.Version));
  300. var ids = new HashSet<string>();
  301. var ignore = new HashSet<PluginMetadata>();
  302. var resolved = new List<PluginMetadata>(PluginsMetadata.Count);
  303. foreach (var meta in PluginsMetadata)
  304. {
  305. if (meta.Id != null)
  306. {
  307. if (ids.Contains(meta.Id))
  308. {
  309. Logger.loader.Warn($"Found duplicates of {meta.Id}, using newest");
  310. ignore.Add(meta);
  311. ignoredPlugins.Add(meta);
  312. continue; // because of sorted order, hightest order will always be the first one
  313. }
  314. bool processedLater = false;
  315. foreach (var meta2 in PluginsMetadata)
  316. {
  317. if (ignore.Contains(meta2)) continue;
  318. if (meta == meta2)
  319. {
  320. processedLater = true;
  321. continue;
  322. }
  323. if (!meta2.Manifest.Conflicts.ContainsKey(meta.Id)) continue;
  324. var range = meta2.Manifest.Conflicts[meta.Id];
  325. if (!range.IsSatisfied(meta.Version)) continue;
  326. Logger.loader.Warn($"{meta.Id}@{meta.Version} conflicts with {meta2.Name}");
  327. if (processedLater)
  328. {
  329. Logger.loader.Warn($"Ignoring {meta2.Name}");
  330. ignore.Add(meta2);
  331. }
  332. else
  333. {
  334. Logger.loader.Warn($"Ignoring {meta.Name}");
  335. ignore.Add(meta);
  336. break;
  337. }
  338. }
  339. }
  340. if (ignore.Contains(meta))
  341. {
  342. ignoredPlugins.Add(meta);
  343. continue;
  344. }
  345. if (meta.Id != null)
  346. ids.Add(meta.Id);
  347. resolved.Add(meta);
  348. }
  349. PluginsMetadata = resolved;
  350. }
  351. private static void FilterDisabled()
  352. {
  353. var enabled = new List<PluginMetadata>(PluginsMetadata.Count);
  354. var disabled = DisabledConfig.Instance.DisabledModIds;
  355. foreach (var meta in PluginsMetadata)
  356. {
  357. if (disabled.Contains(meta.Id ?? meta.Name))
  358. DisabledPlugins.Add(meta);
  359. else
  360. enabled.Add(meta);
  361. }
  362. PluginsMetadata = enabled;
  363. }
  364. internal static void ComputeLoadOrder()
  365. {
  366. #if DEBUG
  367. Logger.loader.Debug(string.Join(", ", PluginsMetadata.Select(p => p.ToString()).StrJP()));
  368. #endif
  369. bool InsertInto(HashSet<PluginMetadata> root, PluginMetadata meta, bool isRoot = false)
  370. { // this is slow, and hella recursive
  371. bool inserted = false;
  372. foreach (var sr in root)
  373. {
  374. inserted = inserted || InsertInto(sr.Dependencies, meta);
  375. if (meta.Id != null)
  376. if (sr.Manifest.Dependencies.ContainsKey(meta.Id) || sr.Manifest.LoadAfter.Contains(meta.Id))
  377. inserted = inserted || sr.Dependencies.Add(meta);
  378. if (sr.Id != null)
  379. if (meta.Manifest.LoadBefore.Contains(sr.Id))
  380. inserted = inserted || sr.Dependencies.Add(meta);
  381. }
  382. if (isRoot)
  383. {
  384. foreach (var sr in root)
  385. {
  386. InsertInto(meta.Dependencies, sr);
  387. if (sr.Id != null)
  388. if (meta.Manifest.Dependencies.ContainsKey(sr.Id) || meta.Manifest.LoadAfter.Contains(sr.Id))
  389. meta.Dependencies.Add(sr);
  390. if (meta.Id != null)
  391. if (sr.Manifest.LoadBefore.Contains(meta.Id))
  392. meta.Dependencies.Add(sr);
  393. }
  394. root.Add(meta);
  395. }
  396. return inserted;
  397. }
  398. var pluginTree = new HashSet<PluginMetadata>();
  399. foreach (var meta in PluginsMetadata)
  400. InsertInto(pluginTree, meta, true);
  401. void DeTree(List<PluginMetadata> into, HashSet<PluginMetadata> tree)
  402. {
  403. foreach (var st in tree)
  404. if (!into.Contains(st))
  405. {
  406. DeTree(into, st.Dependencies);
  407. into.Add(st);
  408. }
  409. }
  410. PluginsMetadata = new List<PluginMetadata>();
  411. DeTree(PluginsMetadata, pluginTree);
  412. #if DEBUG
  413. Logger.loader.Debug(string.Join(", ", PluginsMetadata.Select(p => p.ToString()).StrJP()));
  414. #endif
  415. }
  416. internal static void ResolveDependencies()
  417. {
  418. var metadata = new List<PluginMetadata>();
  419. var pluginsToLoad = new Dictionary<string, Version>();
  420. var disabledLookup = DisabledPlugins.NonNull(m => m.Id).ToDictionary(m => m.Id, m => m.Version);
  421. foreach (var meta in PluginsMetadata)
  422. {
  423. bool load = true;
  424. bool disable = false;
  425. foreach (var dep in meta.Manifest.Dependencies)
  426. {
  427. #if DEBUG
  428. Logger.loader.Debug($"Looking for dependency {dep.Key} with version range {dep.Value.Intersect(new SemVer.Range("*.*.*"))}");
  429. #endif
  430. if (pluginsToLoad.ContainsKey(dep.Key) && dep.Value.IsSatisfied(pluginsToLoad[dep.Key]))
  431. continue;
  432. load = false;
  433. if (disabledLookup.ContainsKey(dep.Key) && dep.Value.IsSatisfied(disabledLookup[dep.Key]))
  434. {
  435. disable = true;
  436. Logger.loader.Warn($"Dependency {dep.Key} was found, but disabled. Disabling {meta.Name} too.");
  437. }
  438. else
  439. Logger.loader.Warn($"{meta.Name} is missing dependency {dep.Key}@{dep.Value}");
  440. break;
  441. }
  442. if (load)
  443. {
  444. metadata.Add(meta);
  445. if (meta.Id != null)
  446. pluginsToLoad.Add(meta.Id, meta.Version);
  447. }
  448. else if (disable)
  449. {
  450. DisabledPlugins.Add(meta);
  451. DisabledConfig.Instance.DisabledModIds.Add(meta.Id ?? meta.Name);
  452. }
  453. else
  454. ignoredPlugins.Add(meta);
  455. }
  456. PluginsMetadata = metadata;
  457. }
  458. internal static void InitFeatures()
  459. {
  460. var parsedFeatures = PluginsMetadata.Select(m =>
  461. (metadata: m,
  462. features: m.Manifest.Features.Select(feature =>
  463. (feature, parsed: Ref.Create<Feature.FeatureParse?>(null))
  464. ).ToList()
  465. )
  466. ).ToList();
  467. while (DefineFeature.NewFeature)
  468. {
  469. DefineFeature.NewFeature = false;
  470. foreach (var (metadata, features) in parsedFeatures)
  471. for (var i = 0; i < features.Count; i++)
  472. {
  473. var feature = features[i];
  474. var success = Feature.TryParseFeature(feature.feature, metadata, out var featureObj,
  475. out var exception, out var valid, out var parsed, feature.parsed.Value);
  476. if (!success && !valid && featureObj == null && exception == null) // no feature of type found
  477. feature.parsed.Value = parsed;
  478. else if (success)
  479. {
  480. if (valid && featureObj.StoreOnPlugin)
  481. metadata.InternalFeatures.Add(featureObj);
  482. else if (!valid)
  483. Logger.features.Warn(
  484. $"Feature not valid on {metadata.Name}: {featureObj.InvalidMessage}");
  485. features.RemoveAt(i--);
  486. }
  487. else
  488. {
  489. Logger.features.Error($"Error parsing feature definition on {metadata.Name}");
  490. Logger.features.Error(exception);
  491. features.RemoveAt(i--);
  492. }
  493. }
  494. foreach (var plugin in PluginsMetadata)
  495. foreach (var feature in plugin.Features)
  496. feature.Evaluate();
  497. }
  498. foreach (var plugin in parsedFeatures)
  499. {
  500. if (plugin.features.Count <= 0) continue;
  501. Logger.features.Warn($"On plugin {plugin.metadata.Name}:");
  502. foreach (var feature in plugin.features)
  503. Logger.features.Warn($" Feature not found with name {feature.feature}");
  504. }
  505. }
  506. internal static void ReleaseAll(bool full = false)
  507. {
  508. if (full)
  509. ignoredPlugins = new HashSet<PluginMetadata>();
  510. else
  511. {
  512. foreach (var m in PluginsMetadata)
  513. ignoredPlugins.Add(m);
  514. foreach (var m in ignoredPlugins)
  515. { // clean them up so we can still use the metadata for updates
  516. m.InternalFeatures.Clear();
  517. m.PluginType = null;
  518. m.Assembly = null;
  519. }
  520. }
  521. PluginsMetadata = new List<PluginMetadata>();
  522. DisabledPlugins = new List<PluginMetadata>();
  523. Feature.Reset();
  524. GC.Collect();
  525. }
  526. internal static void Load(PluginMetadata meta)
  527. {
  528. if (meta.Assembly == null && meta.PluginType != null)
  529. meta.Assembly = Assembly.LoadFrom(meta.File.FullName);
  530. }
  531. internal static PluginInfo InitPlugin(PluginMetadata meta)
  532. {
  533. if (meta.PluginType == null)
  534. return new PluginInfo()
  535. {
  536. Metadata = meta,
  537. Plugin = null
  538. };
  539. var info = new PluginInfo();
  540. if (meta.Manifest.GameVersion != BeatSaber.GameVersion)
  541. Logger.loader.Warn($"Mod {meta.Name} developed for game version {meta.Manifest.GameVersion}, so it may not work properly.");
  542. try
  543. { // TODO: add dependency checking for when features prevent loading
  544. Load(meta);
  545. Feature denyingFeature = null;
  546. if (!meta.Features.All(f => (denyingFeature = f).BeforeLoad(meta)))
  547. {
  548. Logger.loader.Warn(
  549. $"Feature {denyingFeature?.GetType()} denied plugin {meta.Name} from loading! {denyingFeature?.InvalidMessage}");
  550. ignoredPlugins.Add(meta);
  551. return null;
  552. }
  553. var type = meta.Assembly.GetType(meta.PluginType.FullName);
  554. var instance = Activator.CreateInstance(type) as IPlugin;
  555. info.Metadata = meta;
  556. info.Plugin = instance;
  557. var init = type.GetMethod("Init", BindingFlags.Instance | BindingFlags.Public);
  558. if (init != null)
  559. {
  560. denyingFeature = null;
  561. if (!meta.Features.All(f => (denyingFeature = f).BeforeInit(info)))
  562. {
  563. Logger.loader.Warn(
  564. $"Feature {denyingFeature?.GetType()} denied plugin {meta.Name} from initializing! {denyingFeature?.InvalidMessage}");
  565. ignoredPlugins.Add(meta);
  566. return null;
  567. }
  568. PluginInitInjector.Inject(init, info);
  569. }
  570. foreach (var feature in meta.Features)
  571. try
  572. {
  573. feature.AfterInit(info, info.Plugin);
  574. }
  575. catch (Exception e)
  576. {
  577. Logger.loader.Critical($"Feature errored in {nameof(Feature.AfterInit)}: {e}");
  578. }
  579. try // TODO: move this out to after all plugins have been inited
  580. {
  581. instance.OnEnable();
  582. }
  583. catch (Exception e)
  584. {
  585. Logger.loader.Error($"Error occurred trying to enable {meta.Name}");
  586. Logger.loader.Error(e);
  587. return null; // is enable failure a full load failure?
  588. }
  589. }
  590. catch (AmbiguousMatchException)
  591. {
  592. Logger.loader.Error($"Only one Init allowed per plugin (ambiguous match in {meta.Name})");
  593. // not adding to ignoredPlugins here because this should only happen in a development context
  594. // if someone fucks this up on release thats on them
  595. return null;
  596. }
  597. catch (Exception e)
  598. {
  599. Logger.loader.Error($"Could not init plugin {meta.Name}: {e}");
  600. ignoredPlugins.Add(meta);
  601. return null;
  602. }
  603. return info;
  604. }
  605. internal static List<PluginInfo> LoadPlugins()
  606. {
  607. InitFeatures();
  608. DisabledPlugins.ForEach(Load); // make sure they get loaded into memory so their metadata and stuff can be read more easily
  609. return PluginsMetadata.Select(InitPlugin).NonNull().ToList();
  610. }
  611. }
  612. }