diff --git a/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.DotNet.verified.txt b/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.DotNet.verified.txt index b16d008ad18..68130c8810e 100644 --- a/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.DotNet.verified.txt +++ b/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.DotNet.verified.txt @@ -5642,6 +5642,7 @@ namespace Akka.Util.Internal public class static Extensions { public static System.Collections.Generic.IDictionary AddAndReturn(this System.Collections.Generic.IDictionary hash, TKey key, TValue value) { } + [System.ObsoleteAttribute("Use the dictionary setter directly")] public static void AddOrSet(this System.Collections.Generic.IDictionary hash, TKey key, TValue value) { } public static T AsInstanceOf(this object self) { } public static string BetweenDoubleQuotes(this string self) { } diff --git a/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.Net.verified.txt b/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.Net.verified.txt index b1c6cb7b794..f109a52de5c 100644 --- a/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.Net.verified.txt +++ b/src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.Net.verified.txt @@ -5631,6 +5631,7 @@ namespace Akka.Util.Internal public class static Extensions { public static System.Collections.Generic.IDictionary AddAndReturn(this System.Collections.Generic.IDictionary hash, TKey key, TValue value) { } + [System.ObsoleteAttribute("Use the dictionary setter directly")] public static void AddOrSet(this System.Collections.Generic.IDictionary hash, TKey key, TValue value) { } public static T AsInstanceOf(this object self) { } public static string BetweenDoubleQuotes(this string self) { } diff --git a/src/core/Akka/Util/Internal/Extensions.cs b/src/core/Akka/Util/Internal/Extensions.cs index 5e74be8e3c8..51924ee4e00 100644 --- a/src/core/Akka/Util/Internal/Extensions.cs +++ b/src/core/Akka/Util/Internal/Extensions.cs @@ -111,12 +111,10 @@ public static string BetweenDoubleQuotes(this string self) /// TBD /// TBD /// TBD + [Obsolete("Use the dictionary setter directly")] public static void AddOrSet(this IDictionary hash, TKey key, TValue value) { - if (hash.ContainsKey(key)) - hash[key] = value; - else - hash.Add(key,value); + hash[key] = value; } /// @@ -146,7 +144,7 @@ public static TValue GetOrElse(this IDictionary hash /// TBD public static IDictionary AddAndReturn(this IDictionary hash, TKey key, TValue value) { - hash.AddOrSet(key, value); + hash[key] = value; return hash; }