diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-11-05 16:20:31 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-11-05 16:20:31 -0400 |
commit | 8d8b640779061a5cd001890c15f6f00a602df463 (patch) | |
tree | 02f746c96cc09e64075b799782c4cd232a0b3473 /src/StardewModdingAPI/Program.cs | |
parent | 0749fdcbe5d991df9e7c1ad91fd48c198fcc1dbb (diff) | |
download | SMAPI-8d8b640779061a5cd001890c15f6f00a602df463.tar.gz SMAPI-8d8b640779061a5cd001890c15f6f00a602df463.tar.bz2 SMAPI-8d8b640779061a5cd001890c15f6f00a602df463.zip |
add deprecation warnings (#165)
Diffstat (limited to 'src/StardewModdingAPI/Program.cs')
-rw-r--r-- | src/StardewModdingAPI/Program.cs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs index c0129036..3831e3d4 100644 --- a/src/StardewModdingAPI/Program.cs +++ b/src/StardewModdingAPI/Program.cs @@ -54,6 +54,8 @@ namespace StardewModdingAPI /// <summary>The game's build type (i.e. GOG vs Steam).</summary> public static int BuildType => (int)Program.StardewProgramType.GetField("buildType", BindingFlags.Public | BindingFlags.Static).GetValue(null); + /// <summary>Manages deprecation warnings.</summary> + internal static readonly DeprecationManager DeprecationManager = new DeprecationManager(); /********* ** Public methods @@ -267,6 +269,10 @@ namespace StardewModdingAPI Log.Error($"{errorPrefix}: manifest doesn't specify an entry DLL."); continue; } + + // log deprecated fields + if(manifest.UsedAuthourField) + Program.DeprecationManager.Warn(manifest.Name, $"{nameof(Manifest)}.{nameof(Manifest.Authour)}", "1.0"); } catch (Exception ex) { @@ -277,6 +283,7 @@ namespace StardewModdingAPI // create per-save directory if (manifest.PerSaveConfigs) { + Program.DeprecationManager.Warn($"{nameof(Manifest)}.{nameof(Manifest.PerSaveConfigs)}", "1.0"); try { string psDir = Path.Combine(directory, "psconfigs"); @@ -312,13 +319,21 @@ namespace StardewModdingAPI Mod modEntry = (Mod)modAssembly.CreateInstance(modEntryType.ToString()); if (modEntry != null) { + // add as possible source of deprecation warnings + Program.DeprecationManager.AddMod(modAssembly, manifest.Name); + + // hook up mod modEntry.Helper = helper; modEntry.PathOnDisk = directory; modEntry.Manifest = manifest; Log.Info($"Loaded mod: {modEntry.Manifest.Name} by {modEntry.Manifest.Author}, v{modEntry.Manifest.Version} | {modEntry.Manifest.Description}\n@ {targDll}"); Program.ModsLoaded += 1; - modEntry.Entry(); // obsolete + modEntry.Entry(); // deprecated modEntry.Entry(modEntry.Helper); + + // raise deprecation warning for old Entry() method + if (Program.DeprecationManager.IsVirtualMethodImplemented(modEntryType, typeof(Mod), nameof(Mod.Entry))) + Program.DeprecationManager.Warn(manifest.Name, $"an old version of {nameof(Mod)}.{nameof(Mod.Entry)}", "1.0"); } } else |