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 ++++++++ src/SMAPI/IAssetDataForDictionary.cs | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src') 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 } } diff --git a/src/SMAPI/IAssetDataForDictionary.cs b/src/SMAPI/IAssetDataForDictionary.cs index 53c24346..911599d9 100644 --- a/src/SMAPI/IAssetDataForDictionary.cs +++ b/src/SMAPI/IAssetDataForDictionary.cs @@ -1,26 +1,32 @@ -using System; +using System; using System.Collections.Generic; +using StardewModdingAPI.Framework.Content; namespace StardewModdingAPI { /// Encapsulates access and changes to dictionary content being read from a data file. public interface IAssetDataForDictionary : IAssetData> { +#if !SMAPI_3_0_STRICT /********* ** Public methods *********/ /// Add or replace an entry in the dictionary. /// The entry key. /// The entry value. + [Obsolete("Access " + nameof(AssetData>.Data) + "field directly.")] void Set(TKey key, TValue 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.")] void Set(TKey key, Func value); /// 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.")] void Set(Func replacer); +#endif } } -- cgit