Skip to content

Commit

Permalink
Add Obsolete tag for old IndexOf (#20068)
Browse files Browse the repository at this point in the history
  • Loading branch information
drasticactions authored Jan 23, 2024
1 parent 7dbe853 commit 4f32463
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/Core/src/Extensions/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ public static void ForEach<T>(this IEnumerable<T> enumeration, Action<T> action)
}

/// <summary>
///
/// Groups elements from an IEnumerable based on a specified key selector function and returns a dictionary
/// where keys are the computed keys and values are lists of elements with the same key.
/// Used by XAML Hot Reload.
/// </summary>
/// <typeparam name="TSource"></typeparam>
/// <typeparam name="TKey"></typeparam>
/// <param name="enumeration"></param>
/// <param name="func"></param>
/// <returns></returns>
/// <typeparam name="TSource">The type of elements in the input enumeration.</typeparam>
/// <typeparam name="TKey">The type of keys produced by the key selector function.</typeparam>
/// <param name="enumeration">The input IEnumerable of elements to be grouped.</param>
/// <param name="func">A function that extracts a key from an element of the input enumeration.</param>
/// <returns>A dictionary with keys as computed by the key selector function and values as lists of elements
/// that share the same key.</returns>
[Obsolete("Legacy API used in previous versions of XAML Hot Reload. Do not use.")]
public static IDictionary<TKey, List<TSource>> GroupToDictionary<TSource, TKey>(this IEnumerable<TSource> enumeration, Func<TSource, TKey> func)
where TKey : notnull
{
Expand Down Expand Up @@ -76,13 +80,15 @@ public static int IndexOf<T>(this IEnumerable<T> enumerable, T item)

/// <summary>
/// Find the index for the first occurrence of an item within the collection as matched through the specified predicate.
/// Used by XAML Hot Reload.
/// </summary>
/// <typeparam name="T">The type of object contained in this collection.</typeparam>
/// <param name="enumerable">The collection in which to look for the item.</param>
/// <param name="predicate">The predicate used to evaluate each item and see if it matches.
/// The item currently evaluated of type <typeparamref name="T"/> is provided as an input parameter.
/// The resulting value should be a <see cref="bool"/> which is <see langword="true"/> if this is the item to match, otherwise <see langword="false"/>.</param>
/// <returns>The index of the first item to match through <paramref name="predicate"/> in the collection or -1 when no match is not found.</returns>
[Obsolete("Use IndexOf<T>(IEnumerable<T>, T item) instead.")]
public static int IndexOf<T>(this IEnumerable<T> enumerable, Func<T, bool> predicate)
{
var i = 0;
Expand Down

0 comments on commit 4f32463

Please sign in to comment.