summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework/InternalExtensions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI/Framework/InternalExtensions.cs')
-rw-r--r--src/StardewModdingAPI/Framework/InternalExtensions.cs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/StardewModdingAPI/Framework/InternalExtensions.cs b/src/StardewModdingAPI/Framework/InternalExtensions.cs
index 415785d9..c4bd2d35 100644
--- a/src/StardewModdingAPI/Framework/InternalExtensions.cs
+++ b/src/StardewModdingAPI/Framework/InternalExtensions.cs
@@ -86,5 +86,26 @@ namespace StardewModdingAPI.Framework
// anything else
return exception.ToString();
}
+
+ /****
+ ** Deprecation
+ ****/
+ /// <summary>Log a deprecation warning for mods using an event.</summary>
+ /// <param name="deprecationManager">The deprecation manager to extend.</param>
+ /// <param name="handlers">The event handlers.</param>
+ /// <param name="nounPhrase">A noun phrase describing what is deprecated.</param>
+ /// <param name="version">The SMAPI version which deprecated it.</param>
+ /// <param name="severity">How deprecated the code is.</param>
+ public static void WarnForEvent(this DeprecationManager deprecationManager, Delegate[] handlers, string nounPhrase, string version, DeprecationLevel severity)
+ {
+ if (handlers == null || !handlers.Any())
+ return;
+
+ foreach (Delegate handler in handlers)
+ {
+ string modName = Program.ModRegistry.GetModFrom(handler) ?? "an unknown mod"; // suppress stack trace for unknown mods, not helpful here
+ deprecationManager.Warn(modName, nounPhrase, version, severity);
+ }
+ }
}
}