diff --git a/Dalamud/IoC/Internal/ServiceContainer.cs b/Dalamud/IoC/Internal/ServiceContainer.cs index 6383b6b11..31d16e02e 100644 --- a/Dalamud/IoC/Internal/ServiceContainer.cs +++ b/Dalamud/IoC/Internal/ServiceContainer.cs @@ -18,7 +18,7 @@ namespace Dalamud.IoC.Internal; /// Dalamud services are constructed via Service{T}.ConstructObject at the moment. /// [ServiceManager.ProvidedService] -internal class ServiceContainer : IServiceType +internal class ServiceContainer : IServiceProvider, IServiceType { private static readonly ModuleLog Log = new("SERVICECONTAINER"); @@ -160,21 +160,10 @@ internal class ServiceContainer : IServiceType /// An implementation of a service scope. public IServiceScope GetScope() => new ServiceScopeImpl(this); - /// - /// Resolves and returns an instance of the specified service type, using either singleton or scoped lifetime as - /// appropriate. - /// - /// The type of the service to resolve. This must be a concrete or interface type registered with the service - /// manager. - /// The scope within which to create scoped services. Required if the requested service type is registered as - /// scoped; otherwise, can be null. - /// An array of objects available for scoped resolution. Used to locate or create scoped service instances when - /// applicable. - /// An instance of the requested service type. Returns a singleton instance if available, a scoped instance if - /// required, or an object from the provided scoped objects if it matches the service type. - /// Thrown if a scoped service is requested but no scope is provided, or if the requested service type cannot be - /// resolved from the scoped objects. - public async Task GetService(Type serviceType, ServiceScopeImpl? scope, object[] scopedObjects) + /// + object? IServiceProvider.GetService(Type serviceType) => this.GetSingletonService(serviceType); + + private async Task GetService(Type serviceType, ServiceScopeImpl? scope, object[] scopedObjects) { if (this.interfaceToTypeMap.TryGetValue(serviceType, out var implementingType)) serviceType = implementingType; diff --git a/Dalamud/IoC/Internal/ServiceScope.cs b/Dalamud/IoC/Internal/ServiceScope.cs index c0c4e0b08..98209eeb7 100644 --- a/Dalamud/IoC/Internal/ServiceScope.cs +++ b/Dalamud/IoC/Internal/ServiceScope.cs @@ -1,4 +1,4 @@ -using System.Collections.Concurrent; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -12,7 +12,7 @@ namespace Dalamud.IoC.Internal; /// /// Container enabling the creation of scoped services. /// -internal interface IServiceScope : IServiceProvider, IAsyncDisposable +internal interface IServiceScope : IAsyncDisposable { /// /// Register objects that may be injected to scoped services, @@ -57,12 +57,6 @@ internal class ServiceScopeImpl : IServiceScope /// The container this scope will use to create services. public ServiceScopeImpl(ServiceContainer container) => this.container = container; - /// - public object? GetService(Type serviceType) - { - return this.container.GetService(serviceType, this, []).ConfigureAwait(false).GetAwaiter().GetResult(); - } - /// public void RegisterPrivateScopes(params object[] scopes) { diff --git a/Dalamud/Plugin/DalamudPluginInterface.cs b/Dalamud/Plugin/DalamudPluginInterface.cs index 6fd9064b6..8455ce164 100644 --- a/Dalamud/Plugin/DalamudPluginInterface.cs +++ b/Dalamud/Plugin/DalamudPluginInterface.cs @@ -86,73 +86,126 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa configuration.DalamudConfigurationSaved += this.OnDalamudConfigurationSaved; } - /// + /// + /// Event that gets fired when loc is changed + /// public event IDalamudPluginInterface.LanguageChangedDelegate? LanguageChanged; - /// + /// + /// Event that is fired when the active list of plugins is changed. + /// public event IDalamudPluginInterface.ActivePluginsChangedDelegate? ActivePluginsChanged; - /// + /// + /// Gets the reason this plugin was loaded. + /// public PluginLoadReason Reason { get; } - /// + /// + /// Gets a value indicating whether auto-updates have already completed this session. + /// public bool IsAutoUpdateComplete => Service.GetNullable()?.IsAutoUpdateComplete ?? false; - /// + /// + /// Gets the repository from which this plugin was installed. + /// + /// If a plugin was installed from the official/main repository, this will return the value of + /// . Developer plugins will return the value of + /// . + /// public string SourceRepository { get; } - /// + /// + /// Gets the current internal plugin name. + /// public string InternalName => this.plugin.InternalName; - /// + /// + /// Gets the plugin's manifest. + /// public IPluginManifest Manifest => this.plugin.Manifest; - /// + /// + /// Gets a value indicating whether this is a dev plugin. + /// public bool IsDev => this.plugin.IsDev; - /// + /// + /// Gets a value indicating whether this is a testing release of a plugin. + /// + /// + /// Dev plugins have undefined behavior for this value, but can be expected to return false. + /// public bool IsTesting { get; } - /// + /// + /// Gets the time that this plugin was loaded. + /// public DateTime LoadTime { get; } - /// + /// + /// Gets the UTC time that this plugin was loaded. + /// public DateTime LoadTimeUTC { get; } - /// + /// + /// Gets the timespan delta from when this plugin was loaded. + /// public TimeSpan LoadTimeDelta => DateTime.Now - this.LoadTime; - /// + /// + /// Gets the directory Dalamud assets are stored in. + /// public DirectoryInfo DalamudAssetDirectory => Service.Get().AssetDirectory; - /// + /// + /// Gets the location of your plugin assembly. + /// public FileInfo AssemblyLocation => this.plugin.DllFile; - /// + /// + /// Gets the directory your plugin configurations are stored in. + /// public DirectoryInfo ConfigDirectory => new(this.GetPluginConfigDirectory()); - /// + /// + /// Gets the config file of your plugin. + /// public FileInfo ConfigFile => this.configs.GetConfigFile(this.plugin.InternalName); - /// + /// + /// Gets the instance which allows you to draw UI into the game via ImGui draw calls. + /// public IUiBuilder UiBuilder { get; private set; } - /// + /// + /// Gets a value indicating whether Dalamud is running in Debug mode or the /xldev menu is open. This can occur on release builds. + /// public bool IsDevMenuOpen => Service.GetNullable() is { IsDevMenuOpen: true }; // Can be null during boot - /// + /// + /// Gets a value indicating whether a debugger is attached. + /// public bool IsDebugging => Debugger.IsAttached; - /// + /// + /// Gets the current UI language in two-letter iso format. + /// public string UiLanguage { get; private set; } - /// + /// + /// Gets serializer class with functions to remove special characters from strings. + /// public ISanitizer Sanitizer { get; } - /// + /// + /// Gets the chat type used by default for plugin messages. + /// public XivChatType GeneralChatType { get; private set; } - /// + /// + /// Gets a list of installed plugins along with their current state. + /// public IEnumerable InstalledPlugins => Service.Get().InstalledPlugins.Select(p => new ExposedPlugin(p)); @@ -161,7 +214,12 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa /// internal UiBuilder LocalUiBuilder => this.uiBuilder; - /// + /// + /// Opens the , with an optional search term. + /// + /// The page to open the installer to. Defaults to the "All Plugins" page. + /// An optional search text to input in the search box. + /// Returns false if the DalamudInterface was null. public bool OpenPluginInstallerTo(PluginInstallerOpenKind openTo = PluginInstallerOpenKind.AllPlugins, string? searchText = null) { var dalamudInterface = Service.GetNullable(); // Can be null during boot @@ -176,7 +234,12 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa return true; } - /// + /// + /// Opens the , with an optional search term. + /// + /// The tab to open the settings to. Defaults to the "General" tab. + /// An optional search text to input in the search box. + /// Returns false if the DalamudInterface was null. public bool OpenDalamudSettingsTo(SettingsOpenKind openTo = SettingsOpenKind.General, string? searchText = null) { var dalamudInterface = Service.GetNullable(); // Can be null during boot @@ -191,7 +254,10 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa return true; } - /// + /// + /// Opens the dev menu bar. + /// + /// Returns false if the DalamudInterface was null. public bool OpenDeveloperMenu() { var dalamudInterface = Service.GetNullable(); // Can be null during boot @@ -230,91 +296,102 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa #region IPC - /// + /// public T GetOrCreateData(string tag, Func dataGenerator) where T : class => Service.Get().GetOrCreateData(tag, dataGenerator); - /// + /// public void RelinquishData(string tag) => Service.Get().RelinquishData(tag); - /// + /// public bool TryGetData(string tag, [NotNullWhen(true)] out T? data) where T : class => Service.Get().TryGetData(tag, out data); - /// + /// public T? GetData(string tag) where T : class => Service.Get().GetData(tag); - /// + /// + /// Gets an IPC provider. + /// + /// The return type for funcs. Use object if this is unused. + /// The name of the IPC registration. + /// An IPC provider. + /// This is thrown when the requested types do not match the previously registered types are different. public ICallGateProvider GetIpcProvider(string name) => new CallGatePubSub(name); - /// + /// public ICallGateProvider GetIpcProvider(string name) => new CallGatePubSub(name); - /// + /// public ICallGateProvider GetIpcProvider(string name) => new CallGatePubSub(name); - /// + /// public ICallGateProvider GetIpcProvider(string name) => new CallGatePubSub(name); - /// + /// public ICallGateProvider GetIpcProvider(string name) => new CallGatePubSub(name); - /// + /// public ICallGateProvider GetIpcProvider(string name) => new CallGatePubSub(name); - /// + /// public ICallGateProvider GetIpcProvider(string name) => new CallGatePubSub(name); - /// + /// public ICallGateProvider GetIpcProvider(string name) => new CallGatePubSub(name); - /// + /// public ICallGateProvider GetIpcProvider(string name) => new CallGatePubSub(name); - /// + /// + /// Gets an IPC subscriber. + /// + /// The return type for funcs. Use object if this is unused. + /// The name of the IPC registration. + /// An IPC subscriber. public ICallGateSubscriber GetIpcSubscriber(string name) => new CallGatePubSub(name); - /// + /// public ICallGateSubscriber GetIpcSubscriber(string name) => new CallGatePubSub(name); - /// + /// public ICallGateSubscriber GetIpcSubscriber(string name) => new CallGatePubSub(name); - /// + /// public ICallGateSubscriber GetIpcSubscriber(string name) => new CallGatePubSub(name); - /// + /// public ICallGateSubscriber GetIpcSubscriber(string name) => new CallGatePubSub(name); - /// + /// public ICallGateSubscriber GetIpcSubscriber(string name) => new CallGatePubSub(name); - /// + /// public ICallGateSubscriber GetIpcSubscriber(string name) => new CallGatePubSub(name); - /// + /// public ICallGateSubscriber GetIpcSubscriber(string name) => new CallGatePubSub(name); - /// + /// public ICallGateSubscriber GetIpcSubscriber(string name) => new CallGatePubSub(name); @@ -322,7 +399,10 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa #region Configuration - /// + /// + /// Save a plugin configuration(inheriting IPluginConfiguration). + /// + /// The current configuration. public void SavePluginConfig(IPluginConfiguration? currentConfig) { if (currentConfig == null) @@ -331,7 +411,10 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa this.configs.Save(currentConfig, this.plugin.InternalName, this.plugin.EffectiveWorkingPluginId); } - /// + /// + /// Get a previously saved plugin configuration or null if none was saved before. + /// + /// A previously saved config or null if none was saved before. public IPluginConfiguration? GetPluginConfig() { // This is done to support json deserialization of plugin configurations @@ -355,22 +438,22 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa return this.configs.Load(this.plugin.InternalName, this.plugin.EffectiveWorkingPluginId); } - /// + /// + /// Get the config directory. + /// + /// directory with path of AppData/XIVLauncher/pluginConfig/PluginInternalName. public string GetPluginConfigDirectory() => this.configs.GetDirectory(this.plugin.InternalName); - /// + /// + /// Get the loc directory. + /// + /// directory with path of AppData/XIVLauncher/pluginConfig/PluginInternalName/loc. public string GetPluginLocDirectory() => this.configs.GetDirectory(Path.Combine(this.plugin.InternalName, "loc")); #endregion #region Dependency Injection - /// - public object? GetService(Type serviceType) - { - return this.plugin.ServiceScope.GetService(serviceType); - } - /// public T? Create(params object[] scopedObjects) where T : class { @@ -419,7 +502,8 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa #endregion - /// + /// Unregister the plugin and dispose all references. + /// Dalamud internal use only. public void Dispose() { Service.Get().RemoveChatLinkHandler(this.plugin.InternalName); diff --git a/Dalamud/Plugin/IDalamudPluginInterface.cs b/Dalamud/Plugin/IDalamudPluginInterface.cs index d1b6977d4..e1dd34f87 100644 --- a/Dalamud/Plugin/IDalamudPluginInterface.cs +++ b/Dalamud/Plugin/IDalamudPluginInterface.cs @@ -8,6 +8,8 @@ using System.Threading.Tasks; using Dalamud.Configuration; using Dalamud.Game.Text; using Dalamud.Game.Text.Sanitizer; +using Dalamud.Game.Text.SeStringHandling; +using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Interface; using Dalamud.Interface.Internal.Windows.PluginInstaller; using Dalamud.Interface.Internal.Windows.Settings; @@ -22,7 +24,7 @@ namespace Dalamud.Plugin; /// /// This interface acts as an interface to various objects needed to interact with Dalamud and the game. /// -public interface IDalamudPluginInterface : IServiceProvider +public interface IDalamudPluginInterface { /// /// Delegate for localization change with two-letter iso lang code. diff --git a/Dalamud/Plugin/Services/IAddonEventManager.cs b/Dalamud/Plugin/Services/IAddonEventManager.cs index 6b7b1166e..c6499e4e2 100644 --- a/Dalamud/Plugin/Services/IAddonEventManager.cs +++ b/Dalamud/Plugin/Services/IAddonEventManager.cs @@ -1,4 +1,4 @@ -using Dalamud.Game.Addon.Events; +using Dalamud.Game.Addon.Events; using Dalamud.Game.Addon.Events.EventDataTypes; namespace Dalamud.Plugin.Services; @@ -6,7 +6,7 @@ namespace Dalamud.Plugin.Services; /// /// Service provider for addon event management. /// -public interface IAddonEventManager : IDalamudService +public interface IAddonEventManager { /// /// Delegate to be called when an event is received. diff --git a/Dalamud/Plugin/Services/IAddonLifecycle.cs b/Dalamud/Plugin/Services/IAddonLifecycle.cs index 1269b13dc..ebf629b85 100644 --- a/Dalamud/Plugin/Services/IAddonLifecycle.cs +++ b/Dalamud/Plugin/Services/IAddonLifecycle.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Runtime.InteropServices; using Dalamud.Game.Addon.Lifecycle; @@ -9,7 +9,7 @@ namespace Dalamud.Plugin.Services; /// /// This class provides events for in-game addon lifecycles. /// -public interface IAddonLifecycle : IDalamudService +public interface IAddonLifecycle { /// /// Delegate for receiving addon lifecycle event messages. diff --git a/Dalamud/Plugin/Services/IAetheryteList.cs b/Dalamud/Plugin/Services/IAetheryteList.cs index 58b82ebf6..88c2ff616 100644 --- a/Dalamud/Plugin/Services/IAetheryteList.cs +++ b/Dalamud/Plugin/Services/IAetheryteList.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Dalamud.Game.ClientState.Aetherytes; @@ -7,7 +7,7 @@ namespace Dalamud.Plugin.Services; /// /// This collection represents the list of available Aetherytes in the Teleport window. /// -public interface IAetheryteList : IDalamudService, IReadOnlyCollection +public interface IAetheryteList : IReadOnlyCollection { /// /// Gets the amount of Aetherytes the local player has unlocked. diff --git a/Dalamud/Plugin/Services/IBuddyList.cs b/Dalamud/Plugin/Services/IBuddyList.cs index 8d3790b6d..77c0b9c17 100644 --- a/Dalamud/Plugin/Services/IBuddyList.cs +++ b/Dalamud/Plugin/Services/IBuddyList.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Dalamud.Game.ClientState.Buddy; @@ -8,7 +8,7 @@ namespace Dalamud.Plugin.Services; /// This collection represents the buddies present in your squadron or trust party. /// It does not include the local player. /// -public interface IBuddyList : IDalamudService, IReadOnlyCollection +public interface IBuddyList : IReadOnlyCollection { /// /// Gets the amount of battle buddies the local player has. diff --git a/Dalamud/Plugin/Services/IChatGui.cs b/Dalamud/Plugin/Services/IChatGui.cs index 572ac6c95..c474ca386 100644 --- a/Dalamud/Plugin/Services/IChatGui.cs +++ b/Dalamud/Plugin/Services/IChatGui.cs @@ -10,7 +10,7 @@ namespace Dalamud.Plugin.Services; /// /// This class handles interacting with the native chat UI. /// -public interface IChatGui : IDalamudService +public interface IChatGui { /// /// A delegate type used with the event. diff --git a/Dalamud/Plugin/Services/IClientState.cs b/Dalamud/Plugin/Services/IClientState.cs index 2555b3b30..36bf2e296 100644 --- a/Dalamud/Plugin/Services/IClientState.cs +++ b/Dalamud/Plugin/Services/IClientState.cs @@ -8,7 +8,7 @@ namespace Dalamud.Plugin.Services; /// /// This class represents the state of the game client at the time of access. /// -public interface IClientState : IDalamudService +public interface IClientState { /// /// A delegate type used for the event. diff --git a/Dalamud/Plugin/Services/ICommandManager.cs b/Dalamud/Plugin/Services/ICommandManager.cs index 46138cd71..a6bc4763f 100644 --- a/Dalamud/Plugin/Services/ICommandManager.cs +++ b/Dalamud/Plugin/Services/ICommandManager.cs @@ -1,4 +1,4 @@ -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using Dalamud.Game.Command; @@ -7,7 +7,7 @@ namespace Dalamud.Plugin.Services; /// /// This class manages registered in-game slash commands. /// -public interface ICommandManager : IDalamudService +public interface ICommandManager { /// /// Gets a read-only list of all registered commands. diff --git a/Dalamud/Plugin/Services/ICondition.cs b/Dalamud/Plugin/Services/ICondition.cs index c37117f3c..4ea9e7f76 100644 --- a/Dalamud/Plugin/Services/ICondition.cs +++ b/Dalamud/Plugin/Services/ICondition.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Dalamud.Game.ClientState.Conditions; @@ -7,7 +7,7 @@ namespace Dalamud.Plugin.Services; /// /// Provides access to conditions (generally player state). You can check whether a player is in combat, mounted, etc. /// -public interface ICondition : IDalamudService +public interface ICondition { /// /// A delegate type used with the event. diff --git a/Dalamud/Plugin/Services/IConsole.cs b/Dalamud/Plugin/Services/IConsole.cs index be920a5c9..0b6832efb 100644 --- a/Dalamud/Plugin/Services/IConsole.cs +++ b/Dalamud/Plugin/Services/IConsole.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using Dalamud.Console; @@ -8,7 +8,7 @@ namespace Dalamud.Plugin.Services; /// Provides functions to register console commands and variables. /// [Experimental("Dalamud001")] -public interface IConsole : IDalamudService +public interface IConsole { /// /// Gets this plugin's namespace prefix, derived off its internal name. diff --git a/Dalamud/Plugin/Services/IContextMenu.cs b/Dalamud/Plugin/Services/IContextMenu.cs index ed99f595e..02f773441 100644 --- a/Dalamud/Plugin/Services/IContextMenu.cs +++ b/Dalamud/Plugin/Services/IContextMenu.cs @@ -5,7 +5,7 @@ namespace Dalamud.Plugin.Services; /// /// This class provides methods for interacting with the game's context menu. /// -public interface IContextMenu : IDalamudService +public interface IContextMenu { /// /// A delegate type used for the event. diff --git a/Dalamud/Plugin/Services/IDalamudService.cs b/Dalamud/Plugin/Services/IDalamudService.cs deleted file mode 100644 index 1472b27da..000000000 --- a/Dalamud/Plugin/Services/IDalamudService.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Dalamud.Plugin.Services; - -/// -/// Marker interface for Dalamud services. -/// -/// -/// This interface is implemented by all services provided through Dalamud's -/// dependency injection system. -/// -public interface IDalamudService; diff --git a/Dalamud/Plugin/Services/IDataManager.cs b/Dalamud/Plugin/Services/IDataManager.cs index 474d34ecb..65c51a9fb 100644 --- a/Dalamud/Plugin/Services/IDataManager.cs +++ b/Dalamud/Plugin/Services/IDataManager.cs @@ -14,7 +14,7 @@ namespace Dalamud.Plugin.Services; /// /// This class provides data for Dalamud-internal features, but can also be used by plugins if needed. /// -public interface IDataManager : IDalamudService +public interface IDataManager { /// /// Gets the current game client language. diff --git a/Dalamud/Plugin/Services/IDtrBar.cs b/Dalamud/Plugin/Services/IDtrBar.cs index a24327e23..8ab34c6f2 100644 --- a/Dalamud/Plugin/Services/IDtrBar.cs +++ b/Dalamud/Plugin/Services/IDtrBar.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Dalamud.Game.Gui.Dtr; using Dalamud.Game.Text.SeStringHandling; @@ -8,7 +8,7 @@ namespace Dalamud.Plugin.Services; /// /// Class used to interface with the server info bar. /// -public interface IDtrBar : IDalamudService +public interface IDtrBar { /// /// Gets a read-only copy of the list of all DTR bar entries. diff --git a/Dalamud/Plugin/Services/IDutyState.cs b/Dalamud/Plugin/Services/IDutyState.cs index 9ad2e3c24..3d49f68cb 100644 --- a/Dalamud/Plugin/Services/IDutyState.cs +++ b/Dalamud/Plugin/Services/IDutyState.cs @@ -1,9 +1,9 @@ -namespace Dalamud.Plugin.Services; +namespace Dalamud.Plugin.Services; /// /// This class represents the state of the currently occupied duty. /// -public interface IDutyState : IDalamudService +public interface IDutyState { /// /// Event that gets fired when the duty starts. diff --git a/Dalamud/Plugin/Services/IFateTable.cs b/Dalamud/Plugin/Services/IFateTable.cs index 3392d8e23..d10141050 100644 --- a/Dalamud/Plugin/Services/IFateTable.cs +++ b/Dalamud/Plugin/Services/IFateTable.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Dalamud.Game.ClientState.Fates; @@ -7,7 +7,7 @@ namespace Dalamud.Plugin.Services; /// /// This collection represents the currently available Fate events. /// -public interface IFateTable : IDalamudService, IReadOnlyCollection +public interface IFateTable : IReadOnlyCollection { /// /// Gets the address of the Fate table. diff --git a/Dalamud/Plugin/Services/IFlyTextGui.cs b/Dalamud/Plugin/Services/IFlyTextGui.cs index 6c0e40fd6..04fae351d 100644 --- a/Dalamud/Plugin/Services/IFlyTextGui.cs +++ b/Dalamud/Plugin/Services/IFlyTextGui.cs @@ -1,4 +1,4 @@ -using Dalamud.Game.Gui.FlyText; +using Dalamud.Game.Gui.FlyText; using Dalamud.Game.Text.SeStringHandling; namespace Dalamud.Plugin.Services; @@ -6,7 +6,7 @@ namespace Dalamud.Plugin.Services; /// /// This class facilitates interacting with and creating native in-game "fly text". /// -public interface IFlyTextGui : IDalamudService +public interface IFlyTextGui { /// /// The delegate defining the type for the FlyText event. diff --git a/Dalamud/Plugin/Services/IFramework.cs b/Dalamud/Plugin/Services/IFramework.cs index 3524ca668..f1a4b6906 100644 --- a/Dalamud/Plugin/Services/IFramework.cs +++ b/Dalamud/Plugin/Services/IFramework.cs @@ -1,4 +1,4 @@ -using System.Threading; +using System.Threading; using System.Threading.Tasks; using Dalamud.Interface.Internal.Windows.Data.Widgets; @@ -24,7 +24,7 @@ namespace Dalamud.Plugin.Services; /// See to see the difference in behaviors, and how would a misuse of these /// functions result in a deadlock. /// -public interface IFramework : IDalamudService +public interface IFramework { /// /// A delegate type used with the event. diff --git a/Dalamud/Plugin/Services/IGameConfig.cs b/Dalamud/Plugin/Services/IGameConfig.cs index 10883c6d1..5d8378659 100644 --- a/Dalamud/Plugin/Services/IGameConfig.cs +++ b/Dalamud/Plugin/Services/IGameConfig.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; using Dalamud.Game.Config; using Dalamud.Plugin.Internal.Types; @@ -17,7 +17,7 @@ namespace Dalamud.Plugin.Services; /// If property access from the plugin constructor is desired, do the value retrieval asynchronously via /// ; do not wait for the result right away. /// -public interface IGameConfig : IDalamudService +public interface IGameConfig { /// /// Event which is fired when any game config option is changed. diff --git a/Dalamud/Plugin/Services/IGameGui.cs b/Dalamud/Plugin/Services/IGameGui.cs index 933252ff4..6c2e0083e 100644 --- a/Dalamud/Plugin/Services/IGameGui.cs +++ b/Dalamud/Plugin/Services/IGameGui.cs @@ -9,7 +9,7 @@ namespace Dalamud.Plugin.Services; /// /// A class handling many aspects of the in-game UI. /// -public unsafe interface IGameGui : IDalamudService +public unsafe interface IGameGui { /// /// Event which is fired when the game UI hiding is toggled. diff --git a/Dalamud/Plugin/Services/IGameInteropProvider.cs b/Dalamud/Plugin/Services/IGameInteropProvider.cs index 645d70ac6..99e36c7ed 100644 --- a/Dalamud/Plugin/Services/IGameInteropProvider.cs +++ b/Dalamud/Plugin/Services/IGameInteropProvider.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; using Dalamud.Hooking; using Dalamud.Utility.Signatures; @@ -8,7 +8,7 @@ namespace Dalamud.Plugin.Services; /// /// Service responsible for the creation of hooks. /// -public interface IGameInteropProvider : IDalamudService +public interface IGameInteropProvider { /// /// Available hooking backends. diff --git a/Dalamud/Plugin/Services/IGameInventory.cs b/Dalamud/Plugin/Services/IGameInventory.cs index cba1c9872..0dff1ff03 100644 --- a/Dalamud/Plugin/Services/IGameInventory.cs +++ b/Dalamud/Plugin/Services/IGameInventory.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Dalamud.Game.Inventory; using Dalamud.Game.Inventory.InventoryEventArgTypes; @@ -8,7 +8,7 @@ namespace Dalamud.Plugin.Services; /// /// This class provides events for the in-game inventory. /// -public interface IGameInventory : IDalamudService +public interface IGameInventory { /// /// Delegate function to be called when inventories have been changed. diff --git a/Dalamud/Plugin/Services/IGameLifecycle.cs b/Dalamud/Plugin/Services/IGameLifecycle.cs index 8fae3fc0e..caa64ed23 100644 --- a/Dalamud/Plugin/Services/IGameLifecycle.cs +++ b/Dalamud/Plugin/Services/IGameLifecycle.cs @@ -1,11 +1,11 @@ -using System.Threading; +using System.Threading; namespace Dalamud.Plugin.Services; /// /// Class offering cancellation tokens for common gameplay events. /// -public interface IGameLifecycle : IDalamudService +public interface IGameLifecycle { /// /// Gets a token that is cancelled when Dalamud is unloading. diff --git a/Dalamud/Plugin/Services/IGameNetwork.cs b/Dalamud/Plugin/Services/IGameNetwork.cs index 4abf20834..969176da7 100644 --- a/Dalamud/Plugin/Services/IGameNetwork.cs +++ b/Dalamud/Plugin/Services/IGameNetwork.cs @@ -1,4 +1,4 @@ -using Dalamud.Game.Network; +using Dalamud.Game.Network; namespace Dalamud.Plugin.Services; @@ -6,7 +6,7 @@ namespace Dalamud.Plugin.Services; /// This class handles interacting with game network events. /// [Obsolete("Will be removed in a future release. Use packet handler hooks instead.", true)] -public interface IGameNetwork : IDalamudService +public interface IGameNetwork { // TODO(v9): we shouldn't be passing pointers to the actual data here diff --git a/Dalamud/Plugin/Services/IGamepadState.cs b/Dalamud/Plugin/Services/IGamepadState.cs index bdb07b91b..2816c927e 100644 --- a/Dalamud/Plugin/Services/IGamepadState.cs +++ b/Dalamud/Plugin/Services/IGamepadState.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using Dalamud.Bindings.ImGui; using Dalamud.Game.ClientState.GamePad; @@ -10,7 +10,7 @@ namespace Dalamud.Plugin.Services; /// /// Will block game's gamepad input if is set. /// -public interface IGamepadState : IDalamudService +public interface IGamepadState { /// /// Gets the pointer to the current instance of the GamepadInput struct. diff --git a/Dalamud/Plugin/Services/IJobGauges.cs b/Dalamud/Plugin/Services/IJobGauges.cs index 3313de7f6..4489a7be7 100644 --- a/Dalamud/Plugin/Services/IJobGauges.cs +++ b/Dalamud/Plugin/Services/IJobGauges.cs @@ -1,11 +1,11 @@ -using Dalamud.Game.ClientState.JobGauge.Types; +using Dalamud.Game.ClientState.JobGauge.Types; namespace Dalamud.Plugin.Services; /// /// This class converts in-memory Job gauge data to structs. /// -public interface IJobGauges : IDalamudService +public interface IJobGauges { /// /// Gets the address of the JobGauge data. diff --git a/Dalamud/Plugin/Services/IKeyState.cs b/Dalamud/Plugin/Services/IKeyState.cs index 06d6c9b49..de78978ca 100644 --- a/Dalamud/Plugin/Services/IKeyState.cs +++ b/Dalamud/Plugin/Services/IKeyState.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Dalamud.Game.ClientState.Keys; @@ -16,7 +16,7 @@ namespace Dalamud.Plugin.Services; /// index & 2 = key up (ephemeral). /// index & 3 = short key press (ephemeral). /// -public interface IKeyState : IDalamudService +public interface IKeyState { /// /// Get or set the key-pressed state for a given vkCode. diff --git a/Dalamud/Plugin/Services/IMarketBoard.cs b/Dalamud/Plugin/Services/IMarketBoard.cs index 0bdfad175..3fded6987 100644 --- a/Dalamud/Plugin/Services/IMarketBoard.cs +++ b/Dalamud/Plugin/Services/IMarketBoard.cs @@ -1,11 +1,11 @@ -using Dalamud.Game.Network.Structures; +using Dalamud.Game.Network.Structures; namespace Dalamud.Plugin.Services; /// /// Provides access to market board related events as the client receives/sends them. /// -public interface IMarketBoard : IDalamudService +public interface IMarketBoard { /// /// A delegate type used with the event. diff --git a/Dalamud/Plugin/Services/INamePlateGui.cs b/Dalamud/Plugin/Services/INamePlateGui.cs index b58b5b7d0..eb2579bae 100644 --- a/Dalamud/Plugin/Services/INamePlateGui.cs +++ b/Dalamud/Plugin/Services/INamePlateGui.cs @@ -7,7 +7,7 @@ namespace Dalamud.Plugin.Services; /// /// Class used to modify the data used when rendering nameplates. /// -public interface INamePlateGui : IDalamudService +public interface INamePlateGui { /// /// The delegate used for receiving nameplate update events. diff --git a/Dalamud/Plugin/Services/INotificationManager.cs b/Dalamud/Plugin/Services/INotificationManager.cs index 6d9dbf584..7d9ccd0b0 100644 --- a/Dalamud/Plugin/Services/INotificationManager.cs +++ b/Dalamud/Plugin/Services/INotificationManager.cs @@ -3,7 +3,7 @@ using Dalamud.Interface.ImGuiNotification; namespace Dalamud.Plugin.Services; /// Manager for notifications provided by Dalamud using ImGui. -public interface INotificationManager : IDalamudService +public interface INotificationManager { /// Adds a notification. /// The new notification. diff --git a/Dalamud/Plugin/Services/IObjectTable.cs b/Dalamud/Plugin/Services/IObjectTable.cs index be8e50dea..36cd72ebe 100644 --- a/Dalamud/Plugin/Services/IObjectTable.cs +++ b/Dalamud/Plugin/Services/IObjectTable.cs @@ -8,7 +8,7 @@ namespace Dalamud.Plugin.Services; /// /// This collection represents the currently spawned FFXIV game objects. /// -public interface IObjectTable : IDalamudService, IEnumerable +public interface IObjectTable : IEnumerable { /// /// Gets the address of the object table. diff --git a/Dalamud/Plugin/Services/IPartyFinderGui.cs b/Dalamud/Plugin/Services/IPartyFinderGui.cs index d9b14baed..fb7a49acd 100644 --- a/Dalamud/Plugin/Services/IPartyFinderGui.cs +++ b/Dalamud/Plugin/Services/IPartyFinderGui.cs @@ -1,11 +1,11 @@ -using Dalamud.Game.Gui.PartyFinder.Types; +using Dalamud.Game.Gui.PartyFinder.Types; namespace Dalamud.Plugin.Services; /// /// This class handles interacting with the native PartyFinder window. /// -public interface IPartyFinderGui : IDalamudService +public interface IPartyFinderGui { /// /// Event type fired each time the game receives an individual Party Finder listing. diff --git a/Dalamud/Plugin/Services/IPartyList.cs b/Dalamud/Plugin/Services/IPartyList.cs index 1af3fa962..b046f36db 100644 --- a/Dalamud/Plugin/Services/IPartyList.cs +++ b/Dalamud/Plugin/Services/IPartyList.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Dalamud.Game.ClientState.Party; @@ -7,7 +7,7 @@ namespace Dalamud.Plugin.Services; /// /// This collection represents the actors present in your party or alliance. /// -public interface IPartyList : IDalamudService, IReadOnlyCollection +public interface IPartyList : IReadOnlyCollection { /// /// Gets the amount of party members the local player has. diff --git a/Dalamud/Plugin/Services/IPlayerState.cs b/Dalamud/Plugin/Services/IPlayerState.cs index 1416dfb77..425ffc963 100644 --- a/Dalamud/Plugin/Services/IPlayerState.cs +++ b/Dalamud/Plugin/Services/IPlayerState.cs @@ -12,7 +12,7 @@ namespace Dalamud.Plugin.Services; /// /// Interface for determining the players state. /// -public interface IPlayerState : IDalamudService +public interface IPlayerState { /// /// Gets a value indicating whether the local players data is loaded. diff --git a/Dalamud/Plugin/Services/IPluginLog.cs b/Dalamud/Plugin/Services/IPluginLog.cs index 38786f0d2..38406fd91 100644 --- a/Dalamud/Plugin/Services/IPluginLog.cs +++ b/Dalamud/Plugin/Services/IPluginLog.cs @@ -1,4 +1,4 @@ -using Serilog; +using Serilog; using Serilog.Events; #pragma warning disable CS1573 // See https://github.com/dotnet/roslyn/issues/40325 @@ -8,7 +8,7 @@ namespace Dalamud.Plugin.Services; /// /// An opinionated service to handle logging for plugins. /// -public interface IPluginLog : IDalamudService +public interface IPluginLog { /// /// Gets a Serilog ILogger instance for this plugin. This is the entrypoint for plugins that wish to use more diff --git a/Dalamud/Plugin/Services/ISeStringEvaluator.cs b/Dalamud/Plugin/Services/ISeStringEvaluator.cs index 8ab7adad1..4efc29e3e 100644 --- a/Dalamud/Plugin/Services/ISeStringEvaluator.cs +++ b/Dalamud/Plugin/Services/ISeStringEvaluator.cs @@ -9,7 +9,7 @@ namespace Dalamud.Plugin.Services; /// /// Defines a service for retrieving localized text for various in-game entities. /// -public interface ISeStringEvaluator : IDalamudService +public interface ISeStringEvaluator { /// /// Evaluates macros in a . diff --git a/Dalamud/Plugin/Services/ISigScanner.cs b/Dalamud/Plugin/Services/ISigScanner.cs index fbbd8b05a..ac0f2c55f 100644 --- a/Dalamud/Plugin/Services/ISigScanner.cs +++ b/Dalamud/Plugin/Services/ISigScanner.cs @@ -2,14 +2,12 @@ using System.Collections.Generic; using System.Diagnostics; using System.Threading; -using Dalamud.Plugin.Services; - namespace Dalamud.Game; /// /// A SigScanner facilitates searching for memory signatures in a given ProcessModule. /// -public interface ISigScanner : IDalamudService +public interface ISigScanner { /// /// Gets a value indicating whether the search on this module is performed on a copy. diff --git a/Dalamud/Plugin/Services/ITargetManager.cs b/Dalamud/Plugin/Services/ITargetManager.cs index 9c9fce550..5ba9f390e 100644 --- a/Dalamud/Plugin/Services/ITargetManager.cs +++ b/Dalamud/Plugin/Services/ITargetManager.cs @@ -1,12 +1,11 @@ -using Dalamud.Game.ClientState.Objects.Types; -using Dalamud.Plugin.Services; +using Dalamud.Game.ClientState.Objects.Types; namespace Dalamud.Game.ClientState.Objects; /// /// Get and set various kinds of targets for the player. /// -public interface ITargetManager : IDalamudService +public interface ITargetManager { /// /// Gets or sets the current target. diff --git a/Dalamud/Plugin/Services/ITextureProvider.cs b/Dalamud/Plugin/Services/ITextureProvider.cs index 7cd1b7c86..a8ad76995 100644 --- a/Dalamud/Plugin/Services/ITextureProvider.cs +++ b/Dalamud/Plugin/Services/ITextureProvider.cs @@ -32,7 +32,7 @@ namespace Dalamud.Plugin.Services; /// . /// /// -public interface ITextureProvider : IDalamudService +public interface ITextureProvider { /// Creates an empty texture. /// Texture specifications. diff --git a/Dalamud/Plugin/Services/ITextureReadbackProvider.cs b/Dalamud/Plugin/Services/ITextureReadbackProvider.cs index 00b684cbb..3d2894355 100644 --- a/Dalamud/Plugin/Services/ITextureReadbackProvider.cs +++ b/Dalamud/Plugin/Services/ITextureReadbackProvider.cs @@ -3,13 +3,14 @@ using System.IO; using System.Threading; using System.Threading.Tasks; +using Dalamud.Interface.Internal; using Dalamud.Interface.Textures; using Dalamud.Interface.Textures.TextureWraps; namespace Dalamud.Plugin.Services; /// Service that grants you to read instances of . -public interface ITextureReadbackProvider : IDalamudService +public interface ITextureReadbackProvider { /// Gets the raw data of a texture wrap. /// The source texture wrap. diff --git a/Dalamud/Plugin/Services/ITextureSubstitutionProvider.cs b/Dalamud/Plugin/Services/ITextureSubstitutionProvider.cs index dcd1b00cc..371fbaf0f 100644 --- a/Dalamud/Plugin/Services/ITextureSubstitutionProvider.cs +++ b/Dalamud/Plugin/Services/ITextureSubstitutionProvider.cs @@ -1,11 +1,11 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace Dalamud.Plugin.Services; /// /// Service that grants you the ability to replace texture data that is to be loaded by Dalamud. /// -public interface ITextureSubstitutionProvider : IDalamudService +public interface ITextureSubstitutionProvider { /// /// Delegate describing a function that may be used to intercept and replace texture data. diff --git a/Dalamud/Plugin/Services/ITitleScreenMenu.cs b/Dalamud/Plugin/Services/ITitleScreenMenu.cs index 50bae62a1..9f7b17ea3 100644 --- a/Dalamud/Plugin/Services/ITitleScreenMenu.cs +++ b/Dalamud/Plugin/Services/ITitleScreenMenu.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Dalamud.Interface; using Dalamud.Interface.Textures; @@ -8,7 +8,7 @@ namespace Dalamud.Plugin.Services; /// /// Interface for class responsible for managing elements in the title screen menu. /// -public interface ITitleScreenMenu : IDalamudService +public interface ITitleScreenMenu { /// /// Gets the list of read only entries in the title screen menu. diff --git a/Dalamud/Plugin/Services/IToastGui.cs b/Dalamud/Plugin/Services/IToastGui.cs index c472cbb1f..ef83e95ac 100644 --- a/Dalamud/Plugin/Services/IToastGui.cs +++ b/Dalamud/Plugin/Services/IToastGui.cs @@ -1,4 +1,4 @@ -using Dalamud.Game.Gui.Toast; +using Dalamud.Game.Gui.Toast; using Dalamud.Game.Text.SeStringHandling; namespace Dalamud.Plugin.Services; @@ -6,7 +6,7 @@ namespace Dalamud.Plugin.Services; /// /// This class facilitates interacting with and creating native toast windows. /// -public interface IToastGui : IDalamudService +public interface IToastGui { /// /// A delegate type used when a normal toast window appears. diff --git a/Dalamud/Plugin/Services/IUnlockState.cs b/Dalamud/Plugin/Services/IUnlockState.cs index a0d733f55..00f2df190 100644 --- a/Dalamud/Plugin/Services/IUnlockState.cs +++ b/Dalamud/Plugin/Services/IUnlockState.cs @@ -11,7 +11,7 @@ namespace Dalamud.Plugin.Services; /// Interface for determining unlock state of various content in the game. /// [Experimental("UnlockState")] -public interface IUnlockState : IDalamudService +public interface IUnlockState { /// /// A delegate type used for the event. diff --git a/Dalamud/Service/ServiceManager.cs b/Dalamud/Service/ServiceManager.cs index 88c6366fd..9847f7147 100644 --- a/Dalamud/Service/ServiceManager.cs +++ b/Dalamud/Service/ServiceManager.cs @@ -9,14 +9,11 @@ using System.Threading.Tasks; using Dalamud.Configuration.Internal; using Dalamud.Game; -using Dalamud.IoC; using Dalamud.IoC.Internal; using Dalamud.Logging.Internal; -using Dalamud.Plugin.Services; using Dalamud.Storage; using Dalamud.Utility; using Dalamud.Utility.Timing; - using JetBrains.Annotations; // API10 TODO: Move to Dalamud.Service namespace. Some plugins reflect this... including my own, oops. There's a todo @@ -544,11 +541,9 @@ internal static class ServiceManager if (attr == null) return ServiceKind.None; - if (!type.IsAssignableTo(typeof(IServiceType))) - { - Log.Error($"Service {type.Name} did not inherit from IServiceType"); - Debug.Fail("Service did not inherit from IServiceType"); - } + Debug.Assert( + type.IsAssignableTo(typeof(IServiceType)), + "Service did not inherit from IServiceType"); if (attr.IsAssignableTo(typeof(BlockingEarlyLoadedServiceAttribute))) return ServiceKind.BlockingEarlyLoadedService; @@ -557,16 +552,7 @@ internal static class ServiceManager return ServiceKind.EarlyLoadedService; if (attr.IsAssignableTo(typeof(ScopedServiceAttribute))) - { - if (type.GetCustomAttribute() != null - && !type.IsAssignableTo(typeof(IDalamudService))) - { - Log.Error($"Plugin-scoped service {type.Name} must inherit from IDalamudService"); - Debug.Fail("Plugin-scoped service must inherit from IDalamudService"); - } - return ServiceKind.ScopedService; - } return ServiceKind.ProvidedService; }