summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Extensions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI/Extensions.cs')
-rw-r--r--src/StardewModdingAPI/Extensions.cs33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/StardewModdingAPI/Extensions.cs b/src/StardewModdingAPI/Extensions.cs
index d76523cd..a14ca613 100644
--- a/src/StardewModdingAPI/Extensions.cs
+++ b/src/StardewModdingAPI/Extensions.cs
@@ -5,6 +5,7 @@ using System.Linq;
using System.Reflection;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
+using StardewModdingAPI.Framework;
namespace StardewModdingAPI
{
@@ -26,7 +27,7 @@ namespace StardewModdingAPI
{
get
{
- Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.Random)}", "1.0");
+ Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.Random)}", "1.0", DeprecationLevel.Info);
return Extensions._random;
}
}
@@ -39,7 +40,7 @@ namespace StardewModdingAPI
/// <param name="key">The key to check.</param>
public static bool IsKeyDown(this Keys key)
{
- Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.IsKeyDown)}", "1.0");
+ Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.IsKeyDown)}", "1.0", DeprecationLevel.Info);
return Keyboard.GetState().IsKeyDown(key);
}
@@ -47,7 +48,7 @@ namespace StardewModdingAPI
/// <summary>Get a random color.</summary>
public static Color RandomColour()
{
- Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.RandomColour)}", "1.0");
+ Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.RandomColour)}", "1.0", DeprecationLevel.Info);
return new Color(Extensions.Random.Next(0, 255), Extensions.Random.Next(0, 255), Extensions.Random.Next(0, 255));
}
@@ -58,7 +59,7 @@ namespace StardewModdingAPI
[Obsolete("The usage of ToSingular has changed. Please update your call to use ToSingular<T>")]
public static string ToSingular(this IEnumerable ienum, string split = ", ")
{
- Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.ToSingular)}", "1.0");
+ Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.ToSingular)}", "1.0", DeprecationLevel.Info);
Log.Error("The usage of ToSingular has changed. Please update your call to use ToSingular<T>");
return "";
}
@@ -69,7 +70,7 @@ namespace StardewModdingAPI
/// <param name="split">The value separator.</param>
public static string ToSingular<T>(this IEnumerable<T> ienum, string split = ", ")
{
- Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.ToSingular)}", "1.0");
+ Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.ToSingular)}", "1.0", DeprecationLevel.Info);
//Apparently Keys[] won't split normally :l
if (typeof(T) == typeof(Keys))
@@ -83,7 +84,7 @@ namespace StardewModdingAPI
/// <param name="o">The value.</param>
public static bool IsInt32(this object o)
{
- Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.IsInt32)}", "1.0");
+ Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.IsInt32)}", "1.0", DeprecationLevel.Info);
int i;
return int.TryParse(o.ToString(), out i);
@@ -93,7 +94,7 @@ namespace StardewModdingAPI
/// <param name="o">The value.</param>
public static int AsInt32(this object o)
{
- Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.AsInt32)}", "1.0");
+ Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.AsInt32)}", "1.0", DeprecationLevel.Info);
return int.Parse(o.ToString());
}
@@ -102,7 +103,7 @@ namespace StardewModdingAPI
/// <param name="o">The value.</param>
public static bool IsBool(this object o)
{
- Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.IsBool)}", "1.0");
+ Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.IsBool)}", "1.0", DeprecationLevel.Info);
bool b;
return bool.TryParse(o.ToString(), out b);
@@ -112,7 +113,7 @@ namespace StardewModdingAPI
/// <param name="o">The value.</param>
public static bool AsBool(this object o)
{
- Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.AsBool)}", "1.0");
+ Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.AsBool)}", "1.0", DeprecationLevel.Info);
return bool.Parse(o.ToString());
}
@@ -121,7 +122,7 @@ namespace StardewModdingAPI
/// <param name="enumerable">The values to hash.</param>
public static int GetHash(this IEnumerable enumerable)
{
- Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.GetHash)}", "1.0");
+ Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.GetHash)}", "1.0", DeprecationLevel.Info);
var hash = 0;
foreach (var v in enumerable)
@@ -134,7 +135,7 @@ namespace StardewModdingAPI
/// <param name="o">The value.</param>
public static T Cast<T>(this object o) where T : class
{
- Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.Cast)}", "1.0");
+ Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.Cast)}", "1.0", DeprecationLevel.Info);
return o as T;
}
@@ -143,7 +144,7 @@ namespace StardewModdingAPI
/// <param name="o">The object to scan.</param>
public static FieldInfo[] GetPrivateFields(this object o)
{
- Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.GetPrivateFields)}", "1.0");
+ Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.GetPrivateFields)}", "1.0", DeprecationLevel.Info);
return o.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static);
}
@@ -152,7 +153,7 @@ namespace StardewModdingAPI
/// <param name="name">The name of the field to find.</param>
public static FieldInfo GetBaseFieldInfo(this Type t, string name)
{
- Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.GetBaseFieldValue)}", "1.0");
+ Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.GetBaseFieldValue)}", "1.0", DeprecationLevel.Info);
return t.GetField(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static);
}
@@ -162,7 +163,7 @@ namespace StardewModdingAPI
/// <param name="name">The name of the field to find.</param>
public static T GetBaseFieldValue<T>(this Type t, object o, string name) where T : class
{
- Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.GetBaseFieldValue)}", "1.0");
+ Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.GetBaseFieldValue)}", "1.0", DeprecationLevel.Info);
return t.GetBaseFieldInfo(name).GetValue(o) as T;
}
@@ -173,7 +174,7 @@ namespace StardewModdingAPI
/// <param name="newValue">The value to set.</param>
public static void SetBaseFieldValue<T>(this Type t, object o, string name, object newValue) where T : class
{
- Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.SetBaseFieldValue)}", "1.0");
+ Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.SetBaseFieldValue)}", "1.0", DeprecationLevel.Info);
t.GetBaseFieldInfo(name).SetValue(o, newValue as T);
}
@@ -181,7 +182,7 @@ namespace StardewModdingAPI
/// <param name="st">The string to copy.</param>
public static string RemoveNumerics(this string st)
{
- Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.RemoveNumerics)}", "1.0");
+ Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.RemoveNumerics)}", "1.0", DeprecationLevel.Info);
var s = st;
foreach (var c in s)
{