summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/release-notes.md2
-rw-r--r--src/SMAPI/Framework/Content/AssetDataForDictionary.cs8
-rw-r--r--src/SMAPI/IAssetDataForDictionary.cs8
3 files changed, 17 insertions, 1 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index de0bdf71..e51ff0a5 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -7,6 +7,8 @@
* For modders:
* Added dedicated content pack API.
+ * **Deprecations:**
+ * The `assetData.AsDictionary<TKey, TValue>().Set` methods are deprecated and will be removed in SMAPI 3.0. Mods should access the `Data` property directly instead.
## 2.9.1
* For players:
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<TKey, TValue> data, Func<string, string> getNormalisedPath, Action<IDictionary<TKey, TValue>> onDataReplaced)
: base(locale, assetName, data, getNormalisedPath, onDataReplaced) { }
+#if !SMAPI_3_0_STRICT
/// <summary>Add or replace an entry in the dictionary.</summary>
/// <param name="key">The entry key.</param>
/// <param name="value">The entry value.</param>
+ [Obsolete("Access " + nameof(AssetData<IDictionary<TKey, TValue>>.Data) + "field directly.")]
public void Set(TKey key, TValue value)
{
+ SCore.DeprecationManager.Warn($"AssetDataForDictionary.{nameof(Set)}", "2.10", DeprecationLevel.Notice);
this.Data[key] = value;
}
/// <summary>Add or replace an entry in the dictionary.</summary>
/// <param name="key">The entry key.</param>
/// <param name="value">A callback which accepts the current value and returns the new value.</param>
+ [Obsolete("Access " + nameof(AssetData<IDictionary<TKey, TValue>>.Data) + "field directly.")]
public void Set(TKey key, Func<TValue, TValue> value)
{
+ SCore.DeprecationManager.Warn($"AssetDataForDictionary.{nameof(Set)}", "2.10", DeprecationLevel.Notice);
this.Data[key] = value(this.Data[key]);
}
/// <summary>Dynamically replace values in the dictionary.</summary>
/// <param name="replacer">A lambda which takes the current key and value for an entry, and returns the new value.</param>
+ [Obsolete("Access " + nameof(AssetData<IDictionary<TKey, TValue>>.Data) + "field directly.")]
public void Set(Func<TKey, TValue, TValue> 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
{
/// <summary>Encapsulates access and changes to dictionary content being read from a data file.</summary>
public interface IAssetDataForDictionary<TKey, TValue> : IAssetData<IDictionary<TKey, TValue>>
{
+#if !SMAPI_3_0_STRICT
/*********
** Public methods
*********/
/// <summary>Add or replace an entry in the dictionary.</summary>
/// <param name="key">The entry key.</param>
/// <param name="value">The entry value.</param>
+ [Obsolete("Access " + nameof(AssetData<IDictionary<TKey, TValue>>.Data) + "field directly.")]
void Set(TKey key, TValue value);
/// <summary>Add or replace an entry in the dictionary.</summary>
/// <param name="key">The entry key.</param>
/// <param name="value">A callback which accepts the current value and returns the new value.</param>
+ [Obsolete("Access " + nameof(AssetData<IDictionary<TKey, TValue>>.Data) + "field directly.")]
void Set(TKey key, Func<TValue, TValue> value);
/// <summary>Dynamically replace values in the dictionary.</summary>
/// <param name="replacer">A lambda which takes the current key and value for an entry, and returns the new value.</param>
+ [Obsolete("Access " + nameof(AssetData<IDictionary<TKey, TValue>>.Data) + "field directly.")]
void Set(Func<TKey, TValue, TValue> replacer);
+#endif
}
}