diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 7fae983d2..5b7090c00 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -33,6 +33,7 @@ Template for new versions:
* Thanks to new IME support with SDL2, `IClyde.TextInputStart()` and `IClyde.TextInputStop()` must now be appropriately called to start/stop receiving text input when focusing/unfocusing a UI control. This restriction is applied even on the (default) GLFW backend, to enforce consistent usage of these APIs.
* `[GUI]TextEventArgs` have been renamed to `[GUI]TextEnteredEventArgs`, turned into records, and made to carry a `string` rather than a single text `Rune`.
+* IoC and `DependencyCollection` `Register` methods now have a `TInterface : class` constraint.
### New features
diff --git a/Robust.Shared/IoC/DependencyCollection.cs b/Robust.Shared/IoC/DependencyCollection.cs
index 6e9360507..4d6dfbeb0 100644
--- a/Robust.Shared/IoC/DependencyCollection.cs
+++ b/Robust.Shared/IoC/DependencyCollection.cs
@@ -87,6 +87,7 @@ namespace Robust.Shared.IoC
///
public void Register(bool overwrite = false)
where TImplementation : class, TInterface
+ where TInterface : class
{
Register(() =>
{
@@ -126,6 +127,8 @@ namespace Robust.Shared.IoC
///
public void Register(DependencyFactoryDelegate factory, bool overwrite = false)
where TImplementation : class, TInterface
+ where TInterface : class
+
{
var interfaceType = typeof(TInterface);
CheckRegisterInterface(interfaceType, typeof(TImplementation), overwrite);
@@ -206,6 +209,7 @@ namespace Robust.Shared.IoC
///
public void RegisterInstance(object implementation, bool overwrite = false, bool deferInject = false)
+ where TInterface : class
{
RegisterInstance(typeof(TInterface), implementation, overwrite, deferInject);
}
diff --git a/Robust.Shared/IoC/IDependencyCollection.cs b/Robust.Shared/IoC/IDependencyCollection.cs
index ac2e277f0..a28c91f3c 100644
--- a/Robust.Shared/IoC/IDependencyCollection.cs
+++ b/Robust.Shared/IoC/IDependencyCollection.cs
@@ -50,7 +50,8 @@ namespace Robust.Shared.IoC
/// or if an already instantiated interface (by ) is attempting to be overwritten.
///
void Register(bool overwrite = false)
- where TImplementation : class, TInterface;
+ where TImplementation : class, TInterface
+ where TInterface : class;
///
/// Registers an interface to an implementation, to make it accessible to
@@ -68,7 +69,8 @@ namespace Robust.Shared.IoC
/// or if an already instantiated interface (by ) is attempting to be overwritten.
///
void Register(DependencyFactoryDelegate factory, bool overwrite = false)
- where TImplementation : class, TInterface;
+ where TImplementation : class, TInterface
+ where TInterface : class;
///
@@ -113,7 +115,8 @@ namespace Robust.Shared.IoC
/// If this is false, dependencies will be immediately injected. If the registered type requires dependencies
/// that don't exist yet because you have not called BuildGraph, set this to true.
///
- void RegisterInstance(object implementation, bool overwrite = false, bool deferInject = false);
+ void RegisterInstance(object implementation, bool overwrite = false, bool deferInject = false)
+ where TInterface : class;
///
/// Registers an interface to an existing instance of an implementation,
diff --git a/Robust.Shared/IoC/IoCManager.cs b/Robust.Shared/IoC/IoCManager.cs
index 17aa48078..48d2e597b 100644
--- a/Robust.Shared/IoC/IoCManager.cs
+++ b/Robust.Shared/IoC/IoCManager.cs
@@ -101,6 +101,7 @@ namespace Robust.Shared.IoC
///
public static void Register(bool overwrite = false)
where TImplementation : class, TInterface
+ where TInterface : class
{
DebugTools.Assert(_container.IsValueCreated, NoContextAssert);
@@ -141,6 +142,7 @@ namespace Robust.Shared.IoC
///
public static void Register(DependencyFactoryDelegate factory, bool overwrite = false)
where TImplementation : class, TInterface
+ where TInterface : class
{
DebugTools.Assert(_container.IsValueCreated, NoContextAssert);
@@ -166,6 +168,7 @@ namespace Robust.Shared.IoC
/// that don't exist yet because you have not called BuildGraph, set this to true.
///
public static void RegisterInstance(object implementation, bool overwrite = false, bool deferInject = false)
+ where TInterface : class
{
DebugTools.Assert(_container.IsValueCreated, NoContextAssert);