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.

93 lines
3.2 KiB

  1. using IPA.Loader.Features;
  2. using IPA.Utilities;
  3. using Mono.Cecil;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Reflection;
  7. using Version = SemVer.Version;
  8. namespace IPA.Loader
  9. {
  10. /// <summary>
  11. /// A class which describes a loaded plugin.
  12. /// </summary>
  13. public class PluginMetadata
  14. {
  15. /// <summary>
  16. /// The assembly the plugin was loaded from.
  17. /// </summary>
  18. /// <value>the loaded Assembly that contains the plugin main type</value>
  19. public Assembly Assembly { get; internal set; }
  20. /// <summary>
  21. /// The TypeDefinition for the main type of the plugin.
  22. /// </summary>
  23. /// <value>the Cecil definition for the plugin main type</value>
  24. public TypeDefinition PluginType { get; internal set; }
  25. /// <summary>
  26. /// The human readable name of the plugin.
  27. /// </summary>
  28. /// <value>the name of the plugin</value>
  29. public string Name { get; internal set; }
  30. /// <summary>
  31. /// The BeatMods ID of the plugin, or null if it doesn't have one.
  32. /// </summary>
  33. /// <value>the updater ID of the plugin</value>
  34. public string Id { get; internal set; }
  35. /// <summary>
  36. /// The version of the plugin.
  37. /// </summary>
  38. /// <value>the version of the plugin</value>
  39. public Version Version { get; internal set; }
  40. /// <summary>
  41. /// The file the plugin was loaded from.
  42. /// </summary>
  43. /// <value>the file the plugin was loaded from</value>
  44. public FileInfo File { get; internal set; }
  45. // ReSharper disable once UnusedAutoPropertyAccessor.Global
  46. /// <summary>
  47. /// The features this plugin requests.
  48. /// </summary>
  49. /// <value>the list of features requested by the plugin</value>
  50. public IReadOnlyList<Feature> Features => InternalFeatures;
  51. internal readonly List<Feature> InternalFeatures = new List<Feature>();
  52. internal bool IsSelf;
  53. /// <summary>
  54. /// Whether or not this metadata object represents a bare manifest.
  55. /// </summary>
  56. /// <value><see langword="true"/> if it is bare, <see langword="false"/> otherwise</value>
  57. public bool IsBare { get; internal set; }
  58. private PluginManifest manifest;
  59. internal HashSet<PluginMetadata> Dependencies { get; } = new HashSet<PluginMetadata>();
  60. internal PluginManifest Manifest
  61. {
  62. get => manifest;
  63. set
  64. {
  65. manifest = value;
  66. Name = value.Name;
  67. Version = value.Version;
  68. Id = value.Id;
  69. }
  70. }
  71. public RuntimeOptions RuntimeOptions { get; internal set; }
  72. public bool IsAttributePlugin { get; internal set; } = false;
  73. /// <summary>
  74. /// Gets all of the metadata as a readable string.
  75. /// </summary>
  76. /// <returns>the readable printable metadata string</returns>
  77. public override string ToString() => $"{Name}({Id}@{Version})({PluginType?.FullName}) from '{Utils.GetRelativePath(File?.FullName, BeatSaber.InstallPath)}'";
  78. }
  79. }