From fd47e992dbdbf4298fd9130b8ef9bfcf52fcab19 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 13 Dec 2018 02:01:23 -0500 Subject: deprecate assetData.AsDictionary().Set --- src/SMAPI/Framework/Content/AssetDataForDictionary.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/SMAPI/Framework/Content') diff --git a/src/SMAPI/Framework/Content/AssetDataForDictionary.cs b/src/SMAPI/Framework/Content/AssetDataForDictionary.cs index 7b80875f..9bd70711 100644 --- a/src/SMAPI/Framework/Content/AssetDataForDictionary.cs +++ b/src/SMAPI/Framework/Content/AssetDataForDictionary.cs @@ -19,28 +19,36 @@ namespace StardewModdingAPI.Framework.Content public AssetDataForDictionary(string locale, string assetName, IDictionary data, Func getNormalisedPath, Action> onDataReplaced) : base(locale, assetName, data, getNormalisedPath, onDataReplaced) { } +#if !SMAPI_3_0_STRICT /// Add or replace an entry in the dictionary. /// The entry key. /// The entry value. + [Obsolete("Access " + nameof(AssetData>.Data) + "field directly.")] public void Set(TKey key, TValue value) { + SCore.DeprecationManager.Warn($"AssetDataForDictionary.{nameof(Set)}", "2.10", DeprecationLevel.Notice); this.Data[key] = value; } /// Add or replace an entry in the dictionary. /// The entry key. /// A callback which accepts the current value and returns the new value. + [Obsolete("Access " + nameof(AssetData>.Data) + "field directly.")] public void Set(TKey key, Func value) { + SCore.DeprecationManager.Warn($"AssetDataForDictionary.{nameof(Set)}", "2.10", DeprecationLevel.Notice); this.Data[key] = value(this.Data[key]); } /// Dynamically replace values in the dictionary. /// A lambda which takes the current key and value for an entry, and returns the new value. + [Obsolete("Access " + nameof(AssetData>.Data) + "field directly.")] public void Set(Func replacer) { + SCore.DeprecationManager.Warn($"AssetDataForDictionary.{nameof(Set)}", "2.10", DeprecationLevel.Notice); foreach (var pair in this.Data.ToArray()) this.Data[pair.Key] = replacer(pair.Key, pair.Value); } +#endif } } -- cgit