using IPA.Loader.Features; using IPA.Utilities; using Mono.Cecil; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; using Version = SemVer.Version; #if NET3 using Net3_Proxy; using Path = Net3_Proxy.Path; #endif namespace IPA.Loader { /// /// A class which describes a loaded plugin. /// public class PluginMetadata { /// /// The assembly the plugin was loaded from. /// /// the loaded Assembly that contains the plugin main type public Assembly Assembly { get; internal set; } /// /// The TypeDefinition for the main type of the plugin. /// /// the Cecil definition for the plugin main type public TypeDefinition PluginType { get; internal set; } /// /// The human readable name of the plugin. /// /// the name of the plugin public string Name { get; internal set; } /// /// The BeatMods ID of the plugin, or null if it doesn't have one. /// /// the updater ID of the plugin public string Id { get; internal set; } /// /// The version of the plugin. /// /// the version of the plugin public Version Version { get; internal set; } /// /// The file the plugin was loaded from. /// /// the file the plugin was loaded from public FileInfo File { get; internal set; } // ReSharper disable once UnusedAutoPropertyAccessor.Global /// /// The features this plugin requests. /// /// the list of features requested by the plugin public IReadOnlyList Features => InternalFeatures; internal readonly List InternalFeatures = new List(); /// /// A list of files (that aren't ) that are associated with this plugin. /// /// a list of associated files public IReadOnlyList AssociatedFiles { get; private set; } = new List(); internal bool IsSelf; /// /// Whether or not this metadata object represents a bare manifest. /// /// if it is bare, otherwise public bool IsBare { get; internal set; } private PluginManifest manifest; internal HashSet Dependencies { get; } = new HashSet(); internal PluginManifest Manifest { get => manifest; set { manifest = value; Name = value.Name; Version = value.Version; Id = value.Id; AssociatedFiles = value.Files .Select(f => Path.Combine(UnityGame.InstallPath, f)) .Select(p => new FileInfo(p)).ToList(); } } /// /// The that the plugin specified in its . /// public RuntimeOptions RuntimeOptions { get; internal set; } /// /// Gets all of the metadata as a readable string. /// /// the readable printable metadata string public override string ToString() => $"{Name}({Id}@{Version})({PluginType?.FullName}) from '{Utils.GetRelativePath(File?.FullName, UnityGame.InstallPath)}'"; } }