Skip to content

Commit

Permalink
obsolete AddOrSet (#7408)
Browse files Browse the repository at this point in the history
* obsolete AddOrSet

* added API approvals

---------

Co-authored-by: Aaron Stannard <aaron@petabridge.com>
Co-authored-by: Gregorius Soedharmo <arkatufus@yahoo.com>
  • Loading branch information
3 people authored Jan 13, 2025
1 parent f362af5 commit 39cce0a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5642,6 +5642,7 @@ namespace Akka.Util.Internal
public class static Extensions
{
public static System.Collections.Generic.IDictionary<TKey, TValue> AddAndReturn<TKey, TValue>(this System.Collections.Generic.IDictionary<TKey, TValue> hash, TKey key, TValue value) { }
[System.ObsoleteAttribute("Use the dictionary setter directly")]
public static void AddOrSet<TKey, TValue>(this System.Collections.Generic.IDictionary<TKey, TValue> hash, TKey key, TValue value) { }
public static T AsInstanceOf<T>(this object self) { }
public static string BetweenDoubleQuotes(this string self) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5631,6 +5631,7 @@ namespace Akka.Util.Internal
public class static Extensions
{
public static System.Collections.Generic.IDictionary<TKey, TValue> AddAndReturn<TKey, TValue>(this System.Collections.Generic.IDictionary<TKey, TValue> hash, TKey key, TValue value) { }
[System.ObsoleteAttribute("Use the dictionary setter directly")]
public static void AddOrSet<TKey, TValue>(this System.Collections.Generic.IDictionary<TKey, TValue> hash, TKey key, TValue value) { }
public static T AsInstanceOf<T>(this object self) { }
public static string BetweenDoubleQuotes(this string self) { }
Expand Down
8 changes: 3 additions & 5 deletions src/core/Akka/Util/Internal/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,10 @@ public static string BetweenDoubleQuotes(this string self)
/// <param name="hash">TBD</param>
/// <param name="key">TBD</param>
/// <param name="value">TBD</param>
[Obsolete("Use the dictionary setter directly")]
public static void AddOrSet<TKey, TValue>(this IDictionary<TKey, TValue> hash, TKey key, TValue value)
{
if (hash.ContainsKey(key))
hash[key] = value;
else
hash.Add(key,value);
hash[key] = value;
}

/// <summary>
Expand Down Expand Up @@ -146,7 +144,7 @@ public static TValue GetOrElse<TKey, TValue>(this IDictionary<TKey, TValue> hash
/// <returns>TBD</returns>
public static IDictionary<TKey, TValue> AddAndReturn<TKey, TValue>(this IDictionary<TKey, TValue> hash, TKey key, TValue value)
{
hash.AddOrSet(key, value);
hash[key] = value;
return hash;
}

Expand Down

0 comments on commit 39cce0a

Please sign in to comment.