From a743d461ce9efc2b60470a15a3a89fbdb456ac27 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 22 Feb 2019 21:17:52 -0500 Subject: bump deprecation levels for upcoming SMAPI 3.0 release (#606) --- src/SMAPI/Framework/Content/AssetDataForDictionary.cs | 6 +++--- src/SMAPI/Framework/DeprecationManager.cs | 2 +- src/SMAPI/Framework/ModHelpers/ModHelper.cs | 2 +- src/SMAPI/Framework/ModLoading/ModResolver.cs | 2 +- src/SMAPI/Framework/SCore.cs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/SMAPI/Framework') diff --git a/src/SMAPI/Framework/Content/AssetDataForDictionary.cs b/src/SMAPI/Framework/Content/AssetDataForDictionary.cs index fd3edd5d..11a2564c 100644 --- a/src/SMAPI/Framework/Content/AssetDataForDictionary.cs +++ b/src/SMAPI/Framework/Content/AssetDataForDictionary.cs @@ -26,7 +26,7 @@ namespace StardewModdingAPI.Framework.Content [Obsolete("Access " + nameof(AssetData>.Data) + "field directly.")] public void Set(TKey key, TValue value) { - SCore.DeprecationManager.Warn($"AssetDataForDictionary.{nameof(Set)}", "2.10", DeprecationLevel.Info); + SCore.DeprecationManager.Warn($"AssetDataForDictionary.{nameof(Set)}", "2.10", DeprecationLevel.PendingRemoval); this.Data[key] = value; } @@ -36,7 +36,7 @@ namespace StardewModdingAPI.Framework.Content [Obsolete("Access " + nameof(AssetData>.Data) + "field directly.")] public void Set(TKey key, Func value) { - SCore.DeprecationManager.Warn($"AssetDataForDictionary.{nameof(Set)}", "2.10", DeprecationLevel.Info); + SCore.DeprecationManager.Warn($"AssetDataForDictionary.{nameof(Set)}", "2.10", DeprecationLevel.PendingRemoval); this.Data[key] = value(this.Data[key]); } @@ -45,7 +45,7 @@ namespace StardewModdingAPI.Framework.Content [Obsolete("Access " + nameof(AssetData>.Data) + "field directly.")] public void Set(Func replacer) { - SCore.DeprecationManager.Warn($"AssetDataForDictionary.{nameof(Set)}", "2.10", DeprecationLevel.Info); + SCore.DeprecationManager.Warn($"AssetDataForDictionary.{nameof(Set)}", "2.10", DeprecationLevel.PendingRemoval); foreach (var pair in this.Data.ToArray()) this.Data[pair.Key] = replacer(pair.Key, pair.Value); } diff --git a/src/SMAPI/Framework/DeprecationManager.cs b/src/SMAPI/Framework/DeprecationManager.cs index fcdf722e..78cf62c2 100644 --- a/src/SMAPI/Framework/DeprecationManager.cs +++ b/src/SMAPI/Framework/DeprecationManager.cs @@ -38,7 +38,7 @@ namespace StardewModdingAPI.Framework /// Log a deprecation warning for the old-style events. public void WarnForOldEvents() { - this.Warn("legacy events", "2.9", DeprecationLevel.Info); + this.Warn("legacy events", "2.9", DeprecationLevel.PendingRemoval); } /// Log a deprecation warning. diff --git a/src/SMAPI/Framework/ModHelpers/ModHelper.cs b/src/SMAPI/Framework/ModHelpers/ModHelper.cs index 18040a78..6c9838c9 100644 --- a/src/SMAPI/Framework/ModHelpers/ModHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/ModHelper.cs @@ -166,7 +166,7 @@ namespace StardewModdingAPI.Framework.ModHelpers [Obsolete("Use " + nameof(IModHelper) + "." + nameof(IModHelper.ContentPacks) + "." + nameof(IContentPackHelper.CreateTemporary) + " instead")] public IContentPack CreateTransitionalContentPack(string directoryPath, string id, string name, string description, string author, ISemanticVersion version) { - SCore.DeprecationManager.Warn($"{nameof(IModHelper)}.{nameof(IModHelper.CreateTransitionalContentPack)}", "2.5", DeprecationLevel.Info); + SCore.DeprecationManager.Warn($"{nameof(IModHelper)}.{nameof(IModHelper.CreateTransitionalContentPack)}", "2.5", DeprecationLevel.PendingRemoval); return this.ContentPacks.CreateTemporary(directoryPath, id, name, description, author, version); } diff --git a/src/SMAPI/Framework/ModLoading/ModResolver.cs b/src/SMAPI/Framework/ModLoading/ModResolver.cs index a8564524..75d3849d 100644 --- a/src/SMAPI/Framework/ModLoading/ModResolver.cs +++ b/src/SMAPI/Framework/ModLoading/ModResolver.cs @@ -151,7 +151,7 @@ namespace StardewModdingAPI.Framework.ModLoading mod.SetStatus(ModMetadataStatus.Failed, $"its {nameof(IManifest.EntryDll)} value '{mod.Manifest.EntryDll}' doesn't match the actual file capitalisation '{actualFilename}'. The capitalisation must match for crossplatform compatibility."); continue; #else - SCore.DeprecationManager.Warn(mod.DisplayName, $"{nameof(IManifest.EntryDll)} value with case-insensitive capitalisation", "2.11", DeprecationLevel.Info); + SCore.DeprecationManager.Warn(mod.DisplayName, $"{nameof(IManifest.EntryDll)} value with case-insensitive capitalisation", "2.11", DeprecationLevel.PendingRemoval); #endif } } diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index ec3e9f72..e0347eb2 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -929,7 +929,7 @@ namespace StardewModdingAPI.Framework // add deprecation warning for old version format { if (mod.Manifest?.Version is Toolkit.SemanticVersion version && version.IsLegacyFormat) - SCore.DeprecationManager.Warn(mod.DisplayName, "non-string manifest version", "2.8", DeprecationLevel.Info); + SCore.DeprecationManager.Warn(mod.DisplayName, "non-string manifest version", "2.8", DeprecationLevel.PendingRemoval); } #endif -- cgit From c24946c3993c0680153bbf9e536593cc80fc16f0 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 22 Feb 2019 21:50:09 -0500 Subject: make it clear that mods will break in SMAPI 3.0 (#606) --- src/SMAPI/Framework/DeprecationManager.cs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'src/SMAPI/Framework') diff --git a/src/SMAPI/Framework/DeprecationManager.cs b/src/SMAPI/Framework/DeprecationManager.cs index 78cf62c2..3153bbb4 100644 --- a/src/SMAPI/Framework/DeprecationManager.cs +++ b/src/SMAPI/Framework/DeprecationManager.cs @@ -14,7 +14,11 @@ namespace StardewModdingAPI.Framework private readonly HashSet LoggedDeprecations = new HashSet(StringComparer.InvariantCultureIgnoreCase); /// Encapsulates monitoring and logging for a given module. +#if !SMAPI_3_0_STRICT + private readonly Monitor Monitor; +#else private readonly IMonitor Monitor; +#endif /// Tracks the installed mods. private readonly ModRegistry ModRegistry; @@ -22,6 +26,11 @@ namespace StardewModdingAPI.Framework /// The queued deprecation warnings to display. private readonly IList QueuedWarnings = new List(); +#if !SMAPI_3_0_STRICT + /// Whether the one-time deprecation message has been shown. + private bool DeprecationHeaderShown = false; +#endif + /********* ** Public methods @@ -29,7 +38,11 @@ namespace StardewModdingAPI.Framework /// Construct an instance. /// Encapsulates monitoring and logging for a given module. /// Tracks the installed mods. +#if !SMAPI_3_0_STRICT + public DeprecationManager(Monitor monitor, ModRegistry modRegistry) +#else public DeprecationManager(IMonitor monitor, ModRegistry modRegistry) +#endif { this.Monitor = monitor; this.ModRegistry = modRegistry; @@ -68,15 +81,25 @@ namespace StardewModdingAPI.Framework /// Print any queued messages. public void PrintQueued() { +#if !SMAPI_3_0_STRICT + if (!this.DeprecationHeaderShown && this.QueuedWarnings.Any()) + { + this.Monitor.Newline(); + this.Monitor.Log("Some of your mods will break in the upcoming SMAPI 3.0. Please update your mods now, or notify the author if no update is available. See https://mods.smapi.io for links to the latest versions.", LogLevel.Warn); + this.Monitor.Newline(); + this.DeprecationHeaderShown = true; + } +#endif + foreach (DeprecationWarning warning in this.QueuedWarnings.OrderBy(p => p.ModName).ThenBy(p => p.NounPhrase)) { // build message #if SMAPI_3_0_STRICT - string message = $"{warning.ModName ?? "An unknown mod"} uses deprecated code ({warning.NounPhrase} is deprecated since SMAPI {warning.Version})."; + string message = $"{warning.ModName} uses deprecated code ({warning.NounPhrase} is deprecated since SMAPI {warning.Version})."; #else string message = warning.NounPhrase == "legacy events" - ? $"{warning.ModName ?? "An unknown mod"} uses deprecated code (legacy events are deprecated since SMAPI {warning.Version})." - : $"{warning.ModName ?? "An unknown mod"} uses deprecated code ({warning.NounPhrase} is deprecated since SMAPI {warning.Version})."; + ? $"{warning.ModName ?? "An unknown mod"} will break in the upcoming SMAPI 3.0 (legacy events are deprecated since SMAPI {warning.Version})." + : $"{warning.ModName ?? "An unknown mod"} will break in the upcoming SMAPI 3.0 ({warning.NounPhrase} is deprecated since SMAPI {warning.Version})."; #endif // get log level -- cgit