mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Check that PluginInterfaces implement IDalamudService
This commit is contained in:
parent
9ea417c9ef
commit
53a082e68d
1 changed files with 17 additions and 3 deletions
|
|
@ -9,11 +9,14 @@ 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
|
||||
|
|
@ -541,9 +544,11 @@ internal static class ServiceManager
|
|||
if (attr == null)
|
||||
return ServiceKind.None;
|
||||
|
||||
Debug.Assert(
|
||||
type.IsAssignableTo(typeof(IServiceType)),
|
||||
"Service did not inherit from IServiceType");
|
||||
if (!type.IsAssignableTo(typeof(IServiceType)))
|
||||
{
|
||||
Log.Error($"Service {type.Name} did not inherit from IServiceType");
|
||||
Debug.Fail("Service did not inherit from IServiceType");
|
||||
}
|
||||
|
||||
if (attr.IsAssignableTo(typeof(BlockingEarlyLoadedServiceAttribute)))
|
||||
return ServiceKind.BlockingEarlyLoadedService;
|
||||
|
|
@ -552,7 +557,16 @@ internal static class ServiceManager
|
|||
return ServiceKind.EarlyLoadedService;
|
||||
|
||||
if (attr.IsAssignableTo(typeof(ScopedServiceAttribute)))
|
||||
{
|
||||
if (type.GetCustomAttribute<PluginInterfaceAttribute>() != 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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue