From 080ebc087ec50fd16e3a01d9529109f2bedbb222 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 May 2026 14:54:21 +0000 Subject: [PATCH 1/6] Initial plan From 64da99fb4aac0f11d091fe098a19c2ab9f024066 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 May 2026 15:07:00 +0000 Subject: [PATCH 2/6] Add LINQ FirstOrDefault support wrappers for NS collection generics Agent-Logs-Url: https://github.com/dotnet/macios/sessions/04597ed5-86b1-4feb-b522-8990c6006023 Co-authored-by: rolfbjarne <249268+rolfbjarne@users.noreply.github.com> --- src/Foundation/NSCollectionLinqExtensions.cs | 85 +++++++++++++++++++ src/frameworks.sources | 1 + tests/monotouch-test/Foundation/ArrayTest.cs | 9 ++ .../Foundation/NSMutableArray1Test.cs | 9 ++ tests/monotouch-test/Foundation/NSSet1Test.cs | 9 ++ 5 files changed, 113 insertions(+) create mode 100644 src/Foundation/NSCollectionLinqExtensions.cs diff --git a/src/Foundation/NSCollectionLinqExtensions.cs b/src/Foundation/NSCollectionLinqExtensions.cs new file mode 100644 index 000000000000..c9365fcd0647 --- /dev/null +++ b/src/Foundation/NSCollectionLinqExtensions.cs @@ -0,0 +1,85 @@ +using System.Collections.Generic; + +#nullable enable + +namespace System.Linq { + public static class NSCollectionLinqExtensions { + public static TKey? FirstOrDefault (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.FirstOrDefault ((IEnumerable) source); + } + + public static TKey? FirstOrDefault (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.FirstOrDefault ((IEnumerable) source, predicate); + } + + public static TKey? FirstOrDefault (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.FirstOrDefault ((IEnumerable) source); + } + + public static TKey? FirstOrDefault (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.FirstOrDefault ((IEnumerable) source, predicate); + } + + public static TKey? FirstOrDefault (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.FirstOrDefault ((IEnumerable) source); + } + + public static TKey? FirstOrDefault (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.FirstOrDefault ((IEnumerable) source, predicate); + } + + public static TValue? FirstOrDefault (this Foundation.NSMutableArray source) where TValue : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.FirstOrDefault ((IEnumerable) source); + } + + public static TValue? FirstOrDefault (this Foundation.NSMutableArray source, Func predicate) where TValue : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.FirstOrDefault ((IEnumerable) source, predicate); + } + + public static TKey? FirstOrDefault (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.FirstOrDefault ((IEnumerable) source); + } + + public static TKey? FirstOrDefault (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.FirstOrDefault ((IEnumerable) source, predicate); + } + + public static TKey? FirstOrDefault (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.FirstOrDefault ((IEnumerable) source); + } + + public static TKey? FirstOrDefault (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.FirstOrDefault ((IEnumerable) source, predicate); + } + } +} diff --git a/src/frameworks.sources b/src/frameworks.sources index accf45f75e36..4ea1cd028503 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -852,6 +852,7 @@ FOUNDATION_SOURCES = \ Foundation/NSOrderedCollectionDifference.cs \ Foundation/NSOrderedCollectionDifference_1.cs \ Foundation/NSConnection.cs \ + Foundation/NSCollectionLinqExtensions.cs \ Foundation/NSData.cs \ Foundation/NSDate.cs \ Foundation/NSDictionary.cs \ diff --git a/tests/monotouch-test/Foundation/ArrayTest.cs b/tests/monotouch-test/Foundation/ArrayTest.cs index 8965e909538c..10cc12004972 100644 --- a/tests/monotouch-test/Foundation/ArrayTest.cs +++ b/tests/monotouch-test/Foundation/ArrayTest.cs @@ -199,5 +199,14 @@ public void Enumerator () Assert.That (list [0].ToString (), Is.EqualTo ("abc"), "Value"); } } + + [Test] + public void LinqFirstOrDefault_MutableArray () + { + using var array = new NSMutableArray (); + array.Add ((NSString) "abc"); + var first = array.FirstOrDefault (); + Assert.That (first, Is.EqualTo ((NSString) "abc"), "FirstOrDefault"); + } } } diff --git a/tests/monotouch-test/Foundation/NSMutableArray1Test.cs b/tests/monotouch-test/Foundation/NSMutableArray1Test.cs index c5189f2b0944..63ada4fc6ce8 100644 --- a/tests/monotouch-test/Foundation/NSMutableArray1Test.cs +++ b/tests/monotouch-test/Foundation/NSMutableArray1Test.cs @@ -1,4 +1,5 @@ using System.Collections; +using System.Linq; namespace MonoTouchFixtures.Foundation { @@ -238,5 +239,13 @@ public void IEnumerable1Test_EnumeratorType () Console.WriteLine (item.LongValue); } } + + [Test] + public void LinqFirstOrDefaultTest () + { + using var arr = new NSMutableArray ((NSString) "1", (NSString) "2"); + var first = arr.FirstOrDefault (); + Assert.That (first, Is.EqualTo ((NSString) "1"), "FirstOrDefault"); + } } } diff --git a/tests/monotouch-test/Foundation/NSSet1Test.cs b/tests/monotouch-test/Foundation/NSSet1Test.cs index 782309ea9224..6e049a3f35d3 100644 --- a/tests/monotouch-test/Foundation/NSSet1Test.cs +++ b/tests/monotouch-test/Foundation/NSSet1Test.cs @@ -294,6 +294,15 @@ public void IEnumerable1Test_EnumeratorType () } } + [Test] + public void LinqFirstOrDefaultTest () + { + using var st = new NSSet ((NSString) "1", (NSString) "2"); + var first = st.FirstOrDefault (); + Assert.That (first, Is.Not.Null, "FirstOrDefault"); + Assert.That (st.Contains (first), Is.True, "Contains"); + } + [Test] public void IEnumerableTest () { From c40d8390b2cd6c5e97e5126ad0cc7c0e632ccdde Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 May 2026 15:07:37 +0000 Subject: [PATCH 3/6] Align generic type naming in NS collection LINQ extensions Agent-Logs-Url: https://github.com/dotnet/macios/sessions/04597ed5-86b1-4feb-b522-8990c6006023 Co-authored-by: rolfbjarne <249268+rolfbjarne@users.noreply.github.com> --- src/Foundation/NSCollectionLinqExtensions.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Foundation/NSCollectionLinqExtensions.cs b/src/Foundation/NSCollectionLinqExtensions.cs index c9365fcd0647..6b106908b93f 100644 --- a/src/Foundation/NSCollectionLinqExtensions.cs +++ b/src/Foundation/NSCollectionLinqExtensions.cs @@ -43,17 +43,17 @@ public static class NSCollectionLinqExtensions { return Enumerable.FirstOrDefault ((IEnumerable) source, predicate); } - public static TValue? FirstOrDefault (this Foundation.NSMutableArray source) where TValue : class, Foundation.INativeObject + public static TKey? FirstOrDefault (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject { ArgumentNullException.ThrowIfNull (source); - return Enumerable.FirstOrDefault ((IEnumerable) source); + return Enumerable.FirstOrDefault ((IEnumerable) source); } - public static TValue? FirstOrDefault (this Foundation.NSMutableArray source, Func predicate) where TValue : class, Foundation.INativeObject + public static TKey? FirstOrDefault (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); - return Enumerable.FirstOrDefault ((IEnumerable) source, predicate); + return Enumerable.FirstOrDefault ((IEnumerable) source, predicate); } public static TKey? FirstOrDefault (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject From 21dd1baa923d6aa07fc64c898edd67cbc3c55751 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 25 May 2026 11:50:19 +0000 Subject: [PATCH 4/6] Add all LINQ method overloads with XML docs and tests for all 6 NS generic collections Agent-Logs-Url: https://github.com/dotnet/macios/sessions/64b2c1cf-9d19-4995-a591-9392aad2cfc5 Co-authored-by: rolfbjarne <249268+rolfbjarne@users.noreply.github.com> --- src/Foundation/NSCollectionLinqExtensions.cs | 2840 ++++++++++++++++- .../Foundation/NSCollectionLinqTest.cs | 1521 +++++++++ 2 files changed, 4345 insertions(+), 16 deletions(-) create mode 100644 tests/monotouch-test/Foundation/NSCollectionLinqTest.cs diff --git a/src/Foundation/NSCollectionLinqExtensions.cs b/src/Foundation/NSCollectionLinqExtensions.cs index 6b106908b93f..fa636d2ae0a0 100644 --- a/src/Foundation/NSCollectionLinqExtensions.cs +++ b/src/Foundation/NSCollectionLinqExtensions.cs @@ -4,12 +4,50 @@ namespace System.Linq { public static class NSCollectionLinqExtensions { + // NSSet + /// Returns the first element of . + /// The element type of the collection. + /// The source collection. + /// The first element in . + /// Thrown when is . + /// Thrown when is empty. + public static TKey First (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.First ((IEnumerable) source); + } + + /// Returns the first element of that satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The first element in that passes the test in . + /// Thrown when or is . + /// Thrown when no element satisfies the condition in . + public static TKey First (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.First ((IEnumerable) source, predicate); + } + + /// Returns the first element of , or if the collection is empty. + /// The element type of the collection. + /// The source collection. + /// The first element in , or if the collection is empty. + /// Thrown when is . public static TKey? FirstOrDefault (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.FirstOrDefault ((IEnumerable) source); } + /// Returns the first element of that satisfies a condition, or if no such element is found. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The first element in that passes the test in , or if no such element is found. + /// Thrown when or is . public static TKey? FirstOrDefault (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject { ArgumentNullException.ThrowIfNull (source); @@ -17,12 +55,480 @@ public static class NSCollectionLinqExtensions { return Enumerable.FirstOrDefault ((IEnumerable) source, predicate); } + /// Returns the last element of . + /// The element type of the collection. + /// The source collection. + /// The last element in . + /// Thrown when is . + /// Thrown when is empty. + public static TKey Last (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Last ((IEnumerable) source); + } + + /// Returns the last element of that satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The last element in that passes the test in . + /// Thrown when or is . + /// Thrown when no element satisfies the condition in . + public static TKey Last (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Last ((IEnumerable) source, predicate); + } + + /// Returns the last element of , or if the collection is empty. + /// The element type of the collection. + /// The source collection. + /// The last element in , or if the collection is empty. + /// Thrown when is . + public static TKey? LastOrDefault (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.LastOrDefault ((IEnumerable) source); + } + + /// Returns the last element of that satisfies a condition, or if no such element is found. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The last element in that passes the test in , or if no such element is found. + /// Thrown when or is . + public static TKey? LastOrDefault (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.LastOrDefault ((IEnumerable) source, predicate); + } + + /// Returns the only element of . + /// The element type of the collection. + /// The source collection. + /// The single element of . + /// Thrown when is . + /// Thrown when is empty or contains more than one element. + public static TKey Single (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Single ((IEnumerable) source); + } + + /// Returns the only element of that satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The single element in that passes the test in . + /// Thrown when or is . + /// Thrown when no element or more than one element satisfies the condition in . + public static TKey Single (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Single ((IEnumerable) source, predicate); + } + + /// Returns the only element of , or if the collection is empty. + /// The element type of the collection. + /// The source collection. + /// The single element of , or if the collection is empty. + /// Thrown when is . + /// Thrown when contains more than one element. + public static TKey? SingleOrDefault (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.SingleOrDefault ((IEnumerable) source); + } + + /// Returns the only element of that satisfies a condition, or if no such element is found. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The single element in that passes the test in , or if no such element is found. + /// Thrown when or is . + /// Thrown when more than one element satisfies the condition in . + public static TKey? SingleOrDefault (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.SingleOrDefault ((IEnumerable) source, predicate); + } + + /// Returns the element at a specified index in . + /// The element type of the collection. + /// The source collection. + /// The zero-based index of the element to retrieve. + /// The element at position in . + /// Thrown when is . + /// Thrown when is less than 0 or greater than or equal to the number of elements in . + public static TKey ElementAt (this Foundation.NSSet source, int index) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ElementAt ((IEnumerable) source, index); + } + + /// Returns the element at a specified index in , or if the index is out of range. + /// The element type of the collection. + /// The source collection. + /// The zero-based index of the element to retrieve. + /// The element at position in , or if the index is out of range. + /// Thrown when is . + public static TKey? ElementAtOrDefault (this Foundation.NSSet source, int index) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ElementAtOrDefault ((IEnumerable) source, index); + } + + /// Determines whether contains any elements. + /// The element type of the collection. + /// The source collection. + /// if contains any elements; otherwise . + /// Thrown when is . + public static bool Any (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Any ((IEnumerable) source); + } + + /// Determines whether any element of satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// if any element in passes the test in ; otherwise . + /// Thrown when or is . + public static bool Any (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Any ((IEnumerable) source, predicate); + } + + /// Determines whether all elements of satisfy a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// if every element in passes the test in , or if the collection is empty; otherwise . + /// Thrown when or is . + public static bool All (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.All ((IEnumerable) source, predicate); + } + + /// Returns the number of elements in . + /// The element type of the collection. + /// The source collection. + /// The number of elements in . + /// Thrown when is . + public static int Count (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Count ((IEnumerable) source); + } + + /// Returns the number of elements in that satisfy a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The number of elements in that pass the test in . + /// Thrown when or is . + public static int Count (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Count ((IEnumerable) source, predicate); + } + + /// Returns a that represents the total number of elements in . + /// The element type of the collection. + /// The source collection. + /// The number of elements in . + /// Thrown when is . + public static long LongCount (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.LongCount ((IEnumerable) source); + } + + /// Returns a that represents the number of elements in that satisfy a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The number of elements in that pass the test in . + /// Thrown when or is . + public static long LongCount (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.LongCount ((IEnumerable) source, predicate); + } + + /// Filters elements of based on a predicate. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// An that contains elements from that satisfy the condition. + /// Thrown when or is . + public static IEnumerable Where (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Where ((IEnumerable) source, predicate); + } + + /// Filters elements of based on a predicate that incorporates each element's index. + /// The element type of the collection. + /// The source collection. + /// A function to test each element; the second parameter represents the zero-based index of the element. + /// An that contains elements from that satisfy the condition. + /// Thrown when or is . + public static IEnumerable Where (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Where ((IEnumerable) source, predicate); + } + + /// Projects each element of into a new form. + /// The element type of the collection. + /// The type of the value returned by . + /// The source collection. + /// A transform function to apply to each element. + /// An whose elements are the result of invoking the transform function on each element of . + /// Thrown when or is . + public static IEnumerable Select (this Foundation.NSSet source, Func selector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (selector); + return Enumerable.Select ((IEnumerable) source, selector); + } + + /// Projects each element of into a new form by incorporating each element's index. + /// The element type of the collection. + /// The type of the value returned by . + /// The source collection. + /// A transform function to apply to each element; the second parameter represents the zero-based index of the element. + /// An whose elements are the result of invoking the transform function on each element of . + /// Thrown when or is . + public static IEnumerable Select (this Foundation.NSSet source, Func selector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (selector); + return Enumerable.Select ((IEnumerable) source, selector); + } + + /// Sorts the elements of in ascending order according to a key. + /// The element type of the collection. + /// The type of the key returned by . + /// The source collection. + /// A function to extract a key from an element. + /// An whose elements are sorted according to a key. + /// Thrown when or is . + public static IOrderedEnumerable OrderBy (this Foundation.NSSet source, Func keySelector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (keySelector); + return Enumerable.OrderBy ((IEnumerable) source, keySelector); + } + + /// Sorts the elements of in descending order according to a key. + /// The element type of the collection. + /// The type of the key returned by . + /// The source collection. + /// A function to extract a key from an element. + /// An whose elements are sorted in descending order according to a key. + /// Thrown when or is . + public static IOrderedEnumerable OrderByDescending (this Foundation.NSSet source, Func keySelector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (keySelector); + return Enumerable.OrderByDescending ((IEnumerable) source, keySelector); + } + + /// Bypasses a specified number of elements in and returns the remaining elements. + /// The element type of the collection. + /// The source collection. + /// The number of elements to skip before returning the remaining elements. + /// An that contains elements after the skipped ones. + /// Thrown when is . + public static IEnumerable Skip (this Foundation.NSSet source, int count) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Skip ((IEnumerable) source, count); + } + + /// Bypasses elements in as long as a condition is true, then returns the remaining elements. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// An that contains the elements starting at the first element that does not satisfy the condition. + /// Thrown when or is . + public static IEnumerable SkipWhile (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.SkipWhile ((IEnumerable) source, predicate); + } + + /// Returns a specified number of contiguous elements from the start of . + /// The element type of the collection. + /// The source collection. + /// The number of elements to return. + /// An that contains the specified number of elements from the start of . + /// Thrown when is . + public static IEnumerable Take (this Foundation.NSSet source, int count) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Take ((IEnumerable) source, count); + } + + /// Returns elements from as long as a specified condition is true. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// An that contains elements from as long as the condition is true. + /// Thrown when or is . + public static IEnumerable TakeWhile (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.TakeWhile ((IEnumerable) source, predicate); + } + + /// Returns distinct elements from . + /// The element type of the collection. + /// The source collection. + /// An that contains distinct elements from . + /// Thrown when is . + public static IEnumerable Distinct (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Distinct ((IEnumerable) source); + } + + /// Inverts the order of the elements in . + /// The element type of the collection. + /// The source collection. + /// An whose elements correspond to those of in reverse order. + /// Thrown when is . + public static IEnumerable Reverse (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Reverse ((IEnumerable) source); + } + + /// Concatenates with another sequence. + /// The element type of the collection. + /// The source collection. + /// The sequence to concatenate to . + /// An that contains the concatenated elements of the two sequences. + /// Thrown when or is . + public static IEnumerable Concat (this Foundation.NSSet source, IEnumerable second) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (second); + return Enumerable.Concat ((IEnumerable) source, second); + } + + /// Creates a from . + /// The element type of the collection. + /// The source collection. + /// A that contains elements from . + /// Thrown when is . + public static List ToList (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ToList ((IEnumerable) source); + } + + /// Creates an array from . + /// The element type of the collection. + /// The source collection. + /// An array that contains elements from . + /// Thrown when is . + public static TKey [] ToArray (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ToArray ((IEnumerable) source); + } + + /// Applies an accumulator function over . + /// The element type of the collection. + /// The source collection. + /// An accumulator function to be invoked on each element. + /// The final accumulator value. + /// Thrown when or is . + /// Thrown when is empty. + public static TKey Aggregate (this Foundation.NSSet source, Func func) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (func); + return Enumerable.Aggregate ((IEnumerable) source, func); + } + + /// Applies an accumulator function over with a seed value. + /// The element type of the collection. + /// The type of the accumulator value. + /// The source collection. + /// The initial accumulator value. + /// An accumulator function to be invoked on each element. + /// The final accumulator value. + /// Thrown when or is . + public static TAccumulate Aggregate (this Foundation.NSSet source, TAccumulate seed, Func func) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (func); + return Enumerable.Aggregate ((IEnumerable) source, seed, func); + } + + // NSMutableSet + /// Returns the first element of . + /// The element type of the collection. + /// The source collection. + /// The first element in . + /// Thrown when is . + /// Thrown when is empty. + public static TKey First (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.First ((IEnumerable) source); + } + + /// Returns the first element of that satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The first element in that passes the test in . + /// Thrown when or is . + /// Thrown when no element satisfies the condition in . + public static TKey First (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.First ((IEnumerable) source, predicate); + } + + /// Returns the first element of , or if the collection is empty. + /// The element type of the collection. + /// The source collection. + /// The first element in , or if the collection is empty. + /// Thrown when is . public static TKey? FirstOrDefault (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.FirstOrDefault ((IEnumerable) source); } + /// Returns the first element of that satisfies a condition, or if no such element is found. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The first element in that passes the test in , or if no such element is found. + /// Thrown when or is . public static TKey? FirstOrDefault (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject { ArgumentNullException.ThrowIfNull (source); @@ -30,56 +536,2358 @@ public static class NSCollectionLinqExtensions { return Enumerable.FirstOrDefault ((IEnumerable) source, predicate); } - public static TKey? FirstOrDefault (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + /// Returns the last element of . + /// The element type of the collection. + /// The source collection. + /// The last element in . + /// Thrown when is . + /// Thrown when is empty. + public static TKey Last (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject { ArgumentNullException.ThrowIfNull (source); - return Enumerable.FirstOrDefault ((IEnumerable) source); + return Enumerable.Last ((IEnumerable) source); } - public static TKey? FirstOrDefault (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + /// Returns the last element of that satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The last element in that passes the test in . + /// Thrown when or is . + /// Thrown when no element satisfies the condition in . + public static TKey Last (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); - return Enumerable.FirstOrDefault ((IEnumerable) source, predicate); + return Enumerable.Last ((IEnumerable) source, predicate); } - public static TKey? FirstOrDefault (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + /// Returns the last element of , or if the collection is empty. + /// The element type of the collection. + /// The source collection. + /// The last element in , or if the collection is empty. + /// Thrown when is . + public static TKey? LastOrDefault (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject { ArgumentNullException.ThrowIfNull (source); - return Enumerable.FirstOrDefault ((IEnumerable) source); + return Enumerable.LastOrDefault ((IEnumerable) source); } - public static TKey? FirstOrDefault (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + /// Returns the last element of that satisfies a condition, or if no such element is found. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The last element in that passes the test in , or if no such element is found. + /// Thrown when or is . + public static TKey? LastOrDefault (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); - return Enumerable.FirstOrDefault ((IEnumerable) source, predicate); + return Enumerable.LastOrDefault ((IEnumerable) source, predicate); } - public static TKey? FirstOrDefault (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + /// Returns the only element of . + /// The element type of the collection. + /// The source collection. + /// The single element of . + /// Thrown when is . + /// Thrown when is empty or contains more than one element. + public static TKey Single (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject { ArgumentNullException.ThrowIfNull (source); - return Enumerable.FirstOrDefault ((IEnumerable) source); + return Enumerable.Single ((IEnumerable) source); } - public static TKey? FirstOrDefault (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + /// Returns the only element of that satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The single element in that passes the test in . + /// Thrown when or is . + /// Thrown when no element or more than one element satisfies the condition in . + public static TKey Single (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); - return Enumerable.FirstOrDefault ((IEnumerable) source, predicate); + return Enumerable.Single ((IEnumerable) source, predicate); } - public static TKey? FirstOrDefault (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + /// Returns the only element of , or if the collection is empty. + /// The element type of the collection. + /// The source collection. + /// The single element of , or if the collection is empty. + /// Thrown when is . + /// Thrown when contains more than one element. + public static TKey? SingleOrDefault (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject { ArgumentNullException.ThrowIfNull (source); - return Enumerable.FirstOrDefault ((IEnumerable) source); + return Enumerable.SingleOrDefault ((IEnumerable) source); } - public static TKey? FirstOrDefault (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + /// Returns the only element of that satisfies a condition, or if no such element is found. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The single element in that passes the test in , or if no such element is found. + /// Thrown when or is . + /// Thrown when more than one element satisfies the condition in . + public static TKey? SingleOrDefault (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); - return Enumerable.FirstOrDefault ((IEnumerable) source, predicate); + return Enumerable.SingleOrDefault ((IEnumerable) source, predicate); + } + + /// Returns the element at a specified index in . + /// The element type of the collection. + /// The source collection. + /// The zero-based index of the element to retrieve. + /// The element at position in . + /// Thrown when is . + /// Thrown when is less than 0 or greater than or equal to the number of elements in . + public static TKey ElementAt (this Foundation.NSMutableSet source, int index) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ElementAt ((IEnumerable) source, index); + } + + /// Returns the element at a specified index in , or if the index is out of range. + /// The element type of the collection. + /// The source collection. + /// The zero-based index of the element to retrieve. + /// The element at position in , or if the index is out of range. + /// Thrown when is . + public static TKey? ElementAtOrDefault (this Foundation.NSMutableSet source, int index) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ElementAtOrDefault ((IEnumerable) source, index); + } + + /// Determines whether contains any elements. + /// The element type of the collection. + /// The source collection. + /// if contains any elements; otherwise . + /// Thrown when is . + public static bool Any (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Any ((IEnumerable) source); + } + + /// Determines whether any element of satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// if any element in passes the test in ; otherwise . + /// Thrown when or is . + public static bool Any (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Any ((IEnumerable) source, predicate); + } + + /// Determines whether all elements of satisfy a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// if every element in passes the test in , or if the collection is empty; otherwise . + /// Thrown when or is . + public static bool All (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.All ((IEnumerable) source, predicate); + } + + /// Returns the number of elements in . + /// The element type of the collection. + /// The source collection. + /// The number of elements in . + /// Thrown when is . + public static int Count (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Count ((IEnumerable) source); + } + + /// Returns the number of elements in that satisfy a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The number of elements in that pass the test in . + /// Thrown when or is . + public static int Count (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Count ((IEnumerable) source, predicate); + } + + /// Returns a that represents the total number of elements in . + /// The element type of the collection. + /// The source collection. + /// The number of elements in . + /// Thrown when is . + public static long LongCount (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.LongCount ((IEnumerable) source); + } + + /// Returns a that represents the number of elements in that satisfy a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The number of elements in that pass the test in . + /// Thrown when or is . + public static long LongCount (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.LongCount ((IEnumerable) source, predicate); + } + + /// Filters elements of based on a predicate. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// An that contains elements from that satisfy the condition. + /// Thrown when or is . + public static IEnumerable Where (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Where ((IEnumerable) source, predicate); + } + + /// Filters elements of based on a predicate that incorporates each element's index. + /// The element type of the collection. + /// The source collection. + /// A function to test each element; the second parameter represents the zero-based index of the element. + /// An that contains elements from that satisfy the condition. + /// Thrown when or is . + public static IEnumerable Where (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Where ((IEnumerable) source, predicate); + } + + /// Projects each element of into a new form. + /// The element type of the collection. + /// The type of the value returned by . + /// The source collection. + /// A transform function to apply to each element. + /// An whose elements are the result of invoking the transform function on each element of . + /// Thrown when or is . + public static IEnumerable Select (this Foundation.NSMutableSet source, Func selector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (selector); + return Enumerable.Select ((IEnumerable) source, selector); + } + + /// Projects each element of into a new form by incorporating each element's index. + /// The element type of the collection. + /// The type of the value returned by . + /// The source collection. + /// A transform function to apply to each element; the second parameter represents the zero-based index of the element. + /// An whose elements are the result of invoking the transform function on each element of . + /// Thrown when or is . + public static IEnumerable Select (this Foundation.NSMutableSet source, Func selector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (selector); + return Enumerable.Select ((IEnumerable) source, selector); + } + + /// Sorts the elements of in ascending order according to a key. + /// The element type of the collection. + /// The type of the key returned by . + /// The source collection. + /// A function to extract a key from an element. + /// An whose elements are sorted according to a key. + /// Thrown when or is . + public static IOrderedEnumerable OrderBy (this Foundation.NSMutableSet source, Func keySelector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (keySelector); + return Enumerable.OrderBy ((IEnumerable) source, keySelector); + } + + /// Sorts the elements of in descending order according to a key. + /// The element type of the collection. + /// The type of the key returned by . + /// The source collection. + /// A function to extract a key from an element. + /// An whose elements are sorted in descending order according to a key. + /// Thrown when or is . + public static IOrderedEnumerable OrderByDescending (this Foundation.NSMutableSet source, Func keySelector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (keySelector); + return Enumerable.OrderByDescending ((IEnumerable) source, keySelector); + } + + /// Bypasses a specified number of elements in and returns the remaining elements. + /// The element type of the collection. + /// The source collection. + /// The number of elements to skip before returning the remaining elements. + /// An that contains elements after the skipped ones. + /// Thrown when is . + public static IEnumerable Skip (this Foundation.NSMutableSet source, int count) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Skip ((IEnumerable) source, count); + } + + /// Bypasses elements in as long as a condition is true, then returns the remaining elements. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// An that contains the elements starting at the first element that does not satisfy the condition. + /// Thrown when or is . + public static IEnumerable SkipWhile (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.SkipWhile ((IEnumerable) source, predicate); + } + + /// Returns a specified number of contiguous elements from the start of . + /// The element type of the collection. + /// The source collection. + /// The number of elements to return. + /// An that contains the specified number of elements from the start of . + /// Thrown when is . + public static IEnumerable Take (this Foundation.NSMutableSet source, int count) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Take ((IEnumerable) source, count); + } + + /// Returns elements from as long as a specified condition is true. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// An that contains elements from as long as the condition is true. + /// Thrown when or is . + public static IEnumerable TakeWhile (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.TakeWhile ((IEnumerable) source, predicate); + } + + /// Returns distinct elements from . + /// The element type of the collection. + /// The source collection. + /// An that contains distinct elements from . + /// Thrown when is . + public static IEnumerable Distinct (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Distinct ((IEnumerable) source); + } + + /// Inverts the order of the elements in . + /// The element type of the collection. + /// The source collection. + /// An whose elements correspond to those of in reverse order. + /// Thrown when is . + public static IEnumerable Reverse (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Reverse ((IEnumerable) source); + } + + /// Concatenates with another sequence. + /// The element type of the collection. + /// The source collection. + /// The sequence to concatenate to . + /// An that contains the concatenated elements of the two sequences. + /// Thrown when or is . + public static IEnumerable Concat (this Foundation.NSMutableSet source, IEnumerable second) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (second); + return Enumerable.Concat ((IEnumerable) source, second); + } + + /// Creates a from . + /// The element type of the collection. + /// The source collection. + /// A that contains elements from . + /// Thrown when is . + public static List ToList (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ToList ((IEnumerable) source); + } + + /// Creates an array from . + /// The element type of the collection. + /// The source collection. + /// An array that contains elements from . + /// Thrown when is . + public static TKey [] ToArray (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ToArray ((IEnumerable) source); + } + + /// Applies an accumulator function over . + /// The element type of the collection. + /// The source collection. + /// An accumulator function to be invoked on each element. + /// The final accumulator value. + /// Thrown when or is . + /// Thrown when is empty. + public static TKey Aggregate (this Foundation.NSMutableSet source, Func func) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (func); + return Enumerable.Aggregate ((IEnumerable) source, func); + } + + /// Applies an accumulator function over with a seed value. + /// The element type of the collection. + /// The type of the accumulator value. + /// The source collection. + /// The initial accumulator value. + /// An accumulator function to be invoked on each element. + /// The final accumulator value. + /// Thrown when or is . + public static TAccumulate Aggregate (this Foundation.NSMutableSet source, TAccumulate seed, Func func) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (func); + return Enumerable.Aggregate ((IEnumerable) source, seed, func); + } + + // NSArray + /// Returns the first element of . + /// The element type of the collection. + /// The source collection. + /// The first element in . + /// Thrown when is . + /// Thrown when is empty. + public static TKey First (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.First ((IEnumerable) source); + } + + /// Returns the first element of that satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The first element in that passes the test in . + /// Thrown when or is . + /// Thrown when no element satisfies the condition in . + public static TKey First (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.First ((IEnumerable) source, predicate); + } + + /// Returns the first element of , or if the collection is empty. + /// The element type of the collection. + /// The source collection. + /// The first element in , or if the collection is empty. + /// Thrown when is . + public static TKey? FirstOrDefault (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.FirstOrDefault ((IEnumerable) source); + } + + /// Returns the first element of that satisfies a condition, or if no such element is found. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The first element in that passes the test in , or if no such element is found. + /// Thrown when or is . + public static TKey? FirstOrDefault (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.FirstOrDefault ((IEnumerable) source, predicate); + } + + /// Returns the last element of . + /// The element type of the collection. + /// The source collection. + /// The last element in . + /// Thrown when is . + /// Thrown when is empty. + public static TKey Last (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Last ((IEnumerable) source); + } + + /// Returns the last element of that satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The last element in that passes the test in . + /// Thrown when or is . + /// Thrown when no element satisfies the condition in . + public static TKey Last (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Last ((IEnumerable) source, predicate); + } + + /// Returns the last element of , or if the collection is empty. + /// The element type of the collection. + /// The source collection. + /// The last element in , or if the collection is empty. + /// Thrown when is . + public static TKey? LastOrDefault (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.LastOrDefault ((IEnumerable) source); + } + + /// Returns the last element of that satisfies a condition, or if no such element is found. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The last element in that passes the test in , or if no such element is found. + /// Thrown when or is . + public static TKey? LastOrDefault (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.LastOrDefault ((IEnumerable) source, predicate); + } + + /// Returns the only element of . + /// The element type of the collection. + /// The source collection. + /// The single element of . + /// Thrown when is . + /// Thrown when is empty or contains more than one element. + public static TKey Single (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Single ((IEnumerable) source); + } + + /// Returns the only element of that satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The single element in that passes the test in . + /// Thrown when or is . + /// Thrown when no element or more than one element satisfies the condition in . + public static TKey Single (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Single ((IEnumerable) source, predicate); + } + + /// Returns the only element of , or if the collection is empty. + /// The element type of the collection. + /// The source collection. + /// The single element of , or if the collection is empty. + /// Thrown when is . + /// Thrown when contains more than one element. + public static TKey? SingleOrDefault (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.SingleOrDefault ((IEnumerable) source); + } + + /// Returns the only element of that satisfies a condition, or if no such element is found. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The single element in that passes the test in , or if no such element is found. + /// Thrown when or is . + /// Thrown when more than one element satisfies the condition in . + public static TKey? SingleOrDefault (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.SingleOrDefault ((IEnumerable) source, predicate); + } + + /// Returns the element at a specified index in . + /// The element type of the collection. + /// The source collection. + /// The zero-based index of the element to retrieve. + /// The element at position in . + /// Thrown when is . + /// Thrown when is less than 0 or greater than or equal to the number of elements in . + public static TKey ElementAt (this Foundation.NSArray source, int index) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ElementAt ((IEnumerable) source, index); + } + + /// Returns the element at a specified index in , or if the index is out of range. + /// The element type of the collection. + /// The source collection. + /// The zero-based index of the element to retrieve. + /// The element at position in , or if the index is out of range. + /// Thrown when is . + public static TKey? ElementAtOrDefault (this Foundation.NSArray source, int index) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ElementAtOrDefault ((IEnumerable) source, index); + } + + /// Determines whether contains any elements. + /// The element type of the collection. + /// The source collection. + /// if contains any elements; otherwise . + /// Thrown when is . + public static bool Any (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Any ((IEnumerable) source); + } + + /// Determines whether any element of satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// if any element in passes the test in ; otherwise . + /// Thrown when or is . + public static bool Any (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Any ((IEnumerable) source, predicate); + } + + /// Determines whether all elements of satisfy a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// if every element in passes the test in , or if the collection is empty; otherwise . + /// Thrown when or is . + public static bool All (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.All ((IEnumerable) source, predicate); + } + + /// Returns the number of elements in . + /// The element type of the collection. + /// The source collection. + /// The number of elements in . + /// Thrown when is . + public static int Count (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Count ((IEnumerable) source); + } + + /// Returns the number of elements in that satisfy a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The number of elements in that pass the test in . + /// Thrown when or is . + public static int Count (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Count ((IEnumerable) source, predicate); + } + + /// Returns a that represents the total number of elements in . + /// The element type of the collection. + /// The source collection. + /// The number of elements in . + /// Thrown when is . + public static long LongCount (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.LongCount ((IEnumerable) source); + } + + /// Returns a that represents the number of elements in that satisfy a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The number of elements in that pass the test in . + /// Thrown when or is . + public static long LongCount (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.LongCount ((IEnumerable) source, predicate); + } + + /// Filters elements of based on a predicate. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// An that contains elements from that satisfy the condition. + /// Thrown when or is . + public static IEnumerable Where (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Where ((IEnumerable) source, predicate); + } + + /// Filters elements of based on a predicate that incorporates each element's index. + /// The element type of the collection. + /// The source collection. + /// A function to test each element; the second parameter represents the zero-based index of the element. + /// An that contains elements from that satisfy the condition. + /// Thrown when or is . + public static IEnumerable Where (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Where ((IEnumerable) source, predicate); + } + + /// Projects each element of into a new form. + /// The element type of the collection. + /// The type of the value returned by . + /// The source collection. + /// A transform function to apply to each element. + /// An whose elements are the result of invoking the transform function on each element of . + /// Thrown when or is . + public static IEnumerable Select (this Foundation.NSArray source, Func selector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (selector); + return Enumerable.Select ((IEnumerable) source, selector); + } + + /// Projects each element of into a new form by incorporating each element's index. + /// The element type of the collection. + /// The type of the value returned by . + /// The source collection. + /// A transform function to apply to each element; the second parameter represents the zero-based index of the element. + /// An whose elements are the result of invoking the transform function on each element of . + /// Thrown when or is . + public static IEnumerable Select (this Foundation.NSArray source, Func selector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (selector); + return Enumerable.Select ((IEnumerable) source, selector); + } + + /// Sorts the elements of in ascending order according to a key. + /// The element type of the collection. + /// The type of the key returned by . + /// The source collection. + /// A function to extract a key from an element. + /// An whose elements are sorted according to a key. + /// Thrown when or is . + public static IOrderedEnumerable OrderBy (this Foundation.NSArray source, Func keySelector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (keySelector); + return Enumerable.OrderBy ((IEnumerable) source, keySelector); + } + + /// Sorts the elements of in descending order according to a key. + /// The element type of the collection. + /// The type of the key returned by . + /// The source collection. + /// A function to extract a key from an element. + /// An whose elements are sorted in descending order according to a key. + /// Thrown when or is . + public static IOrderedEnumerable OrderByDescending (this Foundation.NSArray source, Func keySelector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (keySelector); + return Enumerable.OrderByDescending ((IEnumerable) source, keySelector); + } + + /// Bypasses a specified number of elements in and returns the remaining elements. + /// The element type of the collection. + /// The source collection. + /// The number of elements to skip before returning the remaining elements. + /// An that contains elements after the skipped ones. + /// Thrown when is . + public static IEnumerable Skip (this Foundation.NSArray source, int count) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Skip ((IEnumerable) source, count); + } + + /// Bypasses elements in as long as a condition is true, then returns the remaining elements. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// An that contains the elements starting at the first element that does not satisfy the condition. + /// Thrown when or is . + public static IEnumerable SkipWhile (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.SkipWhile ((IEnumerable) source, predicate); + } + + /// Returns a specified number of contiguous elements from the start of . + /// The element type of the collection. + /// The source collection. + /// The number of elements to return. + /// An that contains the specified number of elements from the start of . + /// Thrown when is . + public static IEnumerable Take (this Foundation.NSArray source, int count) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Take ((IEnumerable) source, count); + } + + /// Returns elements from as long as a specified condition is true. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// An that contains elements from as long as the condition is true. + /// Thrown when or is . + public static IEnumerable TakeWhile (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.TakeWhile ((IEnumerable) source, predicate); + } + + /// Returns distinct elements from . + /// The element type of the collection. + /// The source collection. + /// An that contains distinct elements from . + /// Thrown when is . + public static IEnumerable Distinct (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Distinct ((IEnumerable) source); + } + + /// Inverts the order of the elements in . + /// The element type of the collection. + /// The source collection. + /// An whose elements correspond to those of in reverse order. + /// Thrown when is . + public static IEnumerable Reverse (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Reverse ((IEnumerable) source); + } + + /// Concatenates with another sequence. + /// The element type of the collection. + /// The source collection. + /// The sequence to concatenate to . + /// An that contains the concatenated elements of the two sequences. + /// Thrown when or is . + public static IEnumerable Concat (this Foundation.NSArray source, IEnumerable second) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (second); + return Enumerable.Concat ((IEnumerable) source, second); + } + + /// Creates a from . + /// The element type of the collection. + /// The source collection. + /// A that contains elements from . + /// Thrown when is . + public static List ToList (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ToList ((IEnumerable) source); + } + + /// Creates an array from . + /// The element type of the collection. + /// The source collection. + /// An array that contains elements from . + /// Thrown when is . + public static TKey [] ToArray (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ToArray ((IEnumerable) source); + } + + /// Applies an accumulator function over . + /// The element type of the collection. + /// The source collection. + /// An accumulator function to be invoked on each element. + /// The final accumulator value. + /// Thrown when or is . + /// Thrown when is empty. + public static TKey Aggregate (this Foundation.NSArray source, Func func) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (func); + return Enumerable.Aggregate ((IEnumerable) source, func); + } + + /// Applies an accumulator function over with a seed value. + /// The element type of the collection. + /// The type of the accumulator value. + /// The source collection. + /// The initial accumulator value. + /// An accumulator function to be invoked on each element. + /// The final accumulator value. + /// Thrown when or is . + public static TAccumulate Aggregate (this Foundation.NSArray source, TAccumulate seed, Func func) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (func); + return Enumerable.Aggregate ((IEnumerable) source, seed, func); + } + + // NSMutableArray + /// Returns the first element of . + /// The element type of the collection. + /// The source collection. + /// The first element in . + /// Thrown when is . + /// Thrown when is empty. + public static TKey First (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.First ((IEnumerable) source); + } + + /// Returns the first element of that satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The first element in that passes the test in . + /// Thrown when or is . + /// Thrown when no element satisfies the condition in . + public static TKey First (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.First ((IEnumerable) source, predicate); + } + + /// Returns the first element of , or if the collection is empty. + /// The element type of the collection. + /// The source collection. + /// The first element in , or if the collection is empty. + /// Thrown when is . + public static TKey? FirstOrDefault (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.FirstOrDefault ((IEnumerable) source); + } + + /// Returns the first element of that satisfies a condition, or if no such element is found. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The first element in that passes the test in , or if no such element is found. + /// Thrown when or is . + public static TKey? FirstOrDefault (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.FirstOrDefault ((IEnumerable) source, predicate); + } + + /// Returns the last element of . + /// The element type of the collection. + /// The source collection. + /// The last element in . + /// Thrown when is . + /// Thrown when is empty. + public static TKey Last (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Last ((IEnumerable) source); + } + + /// Returns the last element of that satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The last element in that passes the test in . + /// Thrown when or is . + /// Thrown when no element satisfies the condition in . + public static TKey Last (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Last ((IEnumerable) source, predicate); + } + + /// Returns the last element of , or if the collection is empty. + /// The element type of the collection. + /// The source collection. + /// The last element in , or if the collection is empty. + /// Thrown when is . + public static TKey? LastOrDefault (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.LastOrDefault ((IEnumerable) source); + } + + /// Returns the last element of that satisfies a condition, or if no such element is found. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The last element in that passes the test in , or if no such element is found. + /// Thrown when or is . + public static TKey? LastOrDefault (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.LastOrDefault ((IEnumerable) source, predicate); + } + + /// Returns the only element of . + /// The element type of the collection. + /// The source collection. + /// The single element of . + /// Thrown when is . + /// Thrown when is empty or contains more than one element. + public static TKey Single (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Single ((IEnumerable) source); + } + + /// Returns the only element of that satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The single element in that passes the test in . + /// Thrown when or is . + /// Thrown when no element or more than one element satisfies the condition in . + public static TKey Single (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Single ((IEnumerable) source, predicate); + } + + /// Returns the only element of , or if the collection is empty. + /// The element type of the collection. + /// The source collection. + /// The single element of , or if the collection is empty. + /// Thrown when is . + /// Thrown when contains more than one element. + public static TKey? SingleOrDefault (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.SingleOrDefault ((IEnumerable) source); + } + + /// Returns the only element of that satisfies a condition, or if no such element is found. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The single element in that passes the test in , or if no such element is found. + /// Thrown when or is . + /// Thrown when more than one element satisfies the condition in . + public static TKey? SingleOrDefault (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.SingleOrDefault ((IEnumerable) source, predicate); + } + + /// Returns the element at a specified index in . + /// The element type of the collection. + /// The source collection. + /// The zero-based index of the element to retrieve. + /// The element at position in . + /// Thrown when is . + /// Thrown when is less than 0 or greater than or equal to the number of elements in . + public static TKey ElementAt (this Foundation.NSMutableArray source, int index) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ElementAt ((IEnumerable) source, index); + } + + /// Returns the element at a specified index in , or if the index is out of range. + /// The element type of the collection. + /// The source collection. + /// The zero-based index of the element to retrieve. + /// The element at position in , or if the index is out of range. + /// Thrown when is . + public static TKey? ElementAtOrDefault (this Foundation.NSMutableArray source, int index) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ElementAtOrDefault ((IEnumerable) source, index); + } + + /// Determines whether contains any elements. + /// The element type of the collection. + /// The source collection. + /// if contains any elements; otherwise . + /// Thrown when is . + public static bool Any (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Any ((IEnumerable) source); + } + + /// Determines whether any element of satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// if any element in passes the test in ; otherwise . + /// Thrown when or is . + public static bool Any (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Any ((IEnumerable) source, predicate); + } + + /// Determines whether all elements of satisfy a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// if every element in passes the test in , or if the collection is empty; otherwise . + /// Thrown when or is . + public static bool All (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.All ((IEnumerable) source, predicate); + } + + /// Returns the number of elements in . + /// The element type of the collection. + /// The source collection. + /// The number of elements in . + /// Thrown when is . + public static int Count (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Count ((IEnumerable) source); + } + + /// Returns the number of elements in that satisfy a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The number of elements in that pass the test in . + /// Thrown when or is . + public static int Count (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Count ((IEnumerable) source, predicate); + } + + /// Returns a that represents the total number of elements in . + /// The element type of the collection. + /// The source collection. + /// The number of elements in . + /// Thrown when is . + public static long LongCount (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.LongCount ((IEnumerable) source); + } + + /// Returns a that represents the number of elements in that satisfy a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The number of elements in that pass the test in . + /// Thrown when or is . + public static long LongCount (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.LongCount ((IEnumerable) source, predicate); + } + + /// Filters elements of based on a predicate. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// An that contains elements from that satisfy the condition. + /// Thrown when or is . + public static IEnumerable Where (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Where ((IEnumerable) source, predicate); + } + + /// Filters elements of based on a predicate that incorporates each element's index. + /// The element type of the collection. + /// The source collection. + /// A function to test each element; the second parameter represents the zero-based index of the element. + /// An that contains elements from that satisfy the condition. + /// Thrown when or is . + public static IEnumerable Where (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Where ((IEnumerable) source, predicate); + } + + /// Projects each element of into a new form. + /// The element type of the collection. + /// The type of the value returned by . + /// The source collection. + /// A transform function to apply to each element. + /// An whose elements are the result of invoking the transform function on each element of . + /// Thrown when or is . + public static IEnumerable Select (this Foundation.NSMutableArray source, Func selector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (selector); + return Enumerable.Select ((IEnumerable) source, selector); + } + + /// Projects each element of into a new form by incorporating each element's index. + /// The element type of the collection. + /// The type of the value returned by . + /// The source collection. + /// A transform function to apply to each element; the second parameter represents the zero-based index of the element. + /// An whose elements are the result of invoking the transform function on each element of . + /// Thrown when or is . + public static IEnumerable Select (this Foundation.NSMutableArray source, Func selector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (selector); + return Enumerable.Select ((IEnumerable) source, selector); + } + + /// Sorts the elements of in ascending order according to a key. + /// The element type of the collection. + /// The type of the key returned by . + /// The source collection. + /// A function to extract a key from an element. + /// An whose elements are sorted according to a key. + /// Thrown when or is . + public static IOrderedEnumerable OrderBy (this Foundation.NSMutableArray source, Func keySelector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (keySelector); + return Enumerable.OrderBy ((IEnumerable) source, keySelector); + } + + /// Sorts the elements of in descending order according to a key. + /// The element type of the collection. + /// The type of the key returned by . + /// The source collection. + /// A function to extract a key from an element. + /// An whose elements are sorted in descending order according to a key. + /// Thrown when or is . + public static IOrderedEnumerable OrderByDescending (this Foundation.NSMutableArray source, Func keySelector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (keySelector); + return Enumerable.OrderByDescending ((IEnumerable) source, keySelector); + } + + /// Bypasses a specified number of elements in and returns the remaining elements. + /// The element type of the collection. + /// The source collection. + /// The number of elements to skip before returning the remaining elements. + /// An that contains elements after the skipped ones. + /// Thrown when is . + public static IEnumerable Skip (this Foundation.NSMutableArray source, int count) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Skip ((IEnumerable) source, count); + } + + /// Bypasses elements in as long as a condition is true, then returns the remaining elements. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// An that contains the elements starting at the first element that does not satisfy the condition. + /// Thrown when or is . + public static IEnumerable SkipWhile (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.SkipWhile ((IEnumerable) source, predicate); + } + + /// Returns a specified number of contiguous elements from the start of . + /// The element type of the collection. + /// The source collection. + /// The number of elements to return. + /// An that contains the specified number of elements from the start of . + /// Thrown when is . + public static IEnumerable Take (this Foundation.NSMutableArray source, int count) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Take ((IEnumerable) source, count); + } + + /// Returns elements from as long as a specified condition is true. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// An that contains elements from as long as the condition is true. + /// Thrown when or is . + public static IEnumerable TakeWhile (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.TakeWhile ((IEnumerable) source, predicate); + } + + /// Returns distinct elements from . + /// The element type of the collection. + /// The source collection. + /// An that contains distinct elements from . + /// Thrown when is . + public static IEnumerable Distinct (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Distinct ((IEnumerable) source); + } + + /// Inverts the order of the elements in . + /// The element type of the collection. + /// The source collection. + /// An whose elements correspond to those of in reverse order. + /// Thrown when is . + public static IEnumerable Reverse (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Reverse ((IEnumerable) source); + } + + /// Concatenates with another sequence. + /// The element type of the collection. + /// The source collection. + /// The sequence to concatenate to . + /// An that contains the concatenated elements of the two sequences. + /// Thrown when or is . + public static IEnumerable Concat (this Foundation.NSMutableArray source, IEnumerable second) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (second); + return Enumerable.Concat ((IEnumerable) source, second); + } + + /// Creates a from . + /// The element type of the collection. + /// The source collection. + /// A that contains elements from . + /// Thrown when is . + public static List ToList (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ToList ((IEnumerable) source); + } + + /// Creates an array from . + /// The element type of the collection. + /// The source collection. + /// An array that contains elements from . + /// Thrown when is . + public static TKey [] ToArray (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ToArray ((IEnumerable) source); + } + + /// Applies an accumulator function over . + /// The element type of the collection. + /// The source collection. + /// An accumulator function to be invoked on each element. + /// The final accumulator value. + /// Thrown when or is . + /// Thrown when is empty. + public static TKey Aggregate (this Foundation.NSMutableArray source, Func func) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (func); + return Enumerable.Aggregate ((IEnumerable) source, func); + } + + /// Applies an accumulator function over with a seed value. + /// The element type of the collection. + /// The type of the accumulator value. + /// The source collection. + /// The initial accumulator value. + /// An accumulator function to be invoked on each element. + /// The final accumulator value. + /// Thrown when or is . + public static TAccumulate Aggregate (this Foundation.NSMutableArray source, TAccumulate seed, Func func) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (func); + return Enumerable.Aggregate ((IEnumerable) source, seed, func); + } + + // NSOrderedSet + /// Returns the first element of . + /// The element type of the collection. + /// The source collection. + /// The first element in . + /// Thrown when is . + /// Thrown when is empty. + public static TKey First (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.First ((IEnumerable) source); + } + + /// Returns the first element of that satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The first element in that passes the test in . + /// Thrown when or is . + /// Thrown when no element satisfies the condition in . + public static TKey First (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.First ((IEnumerable) source, predicate); + } + + /// Returns the first element of , or if the collection is empty. + /// The element type of the collection. + /// The source collection. + /// The first element in , or if the collection is empty. + /// Thrown when is . + public static TKey? FirstOrDefault (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.FirstOrDefault ((IEnumerable) source); + } + + /// Returns the first element of that satisfies a condition, or if no such element is found. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The first element in that passes the test in , or if no such element is found. + /// Thrown when or is . + public static TKey? FirstOrDefault (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.FirstOrDefault ((IEnumerable) source, predicate); + } + + /// Returns the last element of . + /// The element type of the collection. + /// The source collection. + /// The last element in . + /// Thrown when is . + /// Thrown when is empty. + public static TKey Last (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Last ((IEnumerable) source); + } + + /// Returns the last element of that satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The last element in that passes the test in . + /// Thrown when or is . + /// Thrown when no element satisfies the condition in . + public static TKey Last (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Last ((IEnumerable) source, predicate); + } + + /// Returns the last element of , or if the collection is empty. + /// The element type of the collection. + /// The source collection. + /// The last element in , or if the collection is empty. + /// Thrown when is . + public static TKey? LastOrDefault (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.LastOrDefault ((IEnumerable) source); + } + + /// Returns the last element of that satisfies a condition, or if no such element is found. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The last element in that passes the test in , or if no such element is found. + /// Thrown when or is . + public static TKey? LastOrDefault (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.LastOrDefault ((IEnumerable) source, predicate); + } + + /// Returns the only element of . + /// The element type of the collection. + /// The source collection. + /// The single element of . + /// Thrown when is . + /// Thrown when is empty or contains more than one element. + public static TKey Single (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Single ((IEnumerable) source); + } + + /// Returns the only element of that satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The single element in that passes the test in . + /// Thrown when or is . + /// Thrown when no element or more than one element satisfies the condition in . + public static TKey Single (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Single ((IEnumerable) source, predicate); + } + + /// Returns the only element of , or if the collection is empty. + /// The element type of the collection. + /// The source collection. + /// The single element of , or if the collection is empty. + /// Thrown when is . + /// Thrown when contains more than one element. + public static TKey? SingleOrDefault (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.SingleOrDefault ((IEnumerable) source); + } + + /// Returns the only element of that satisfies a condition, or if no such element is found. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The single element in that passes the test in , or if no such element is found. + /// Thrown when or is . + /// Thrown when more than one element satisfies the condition in . + public static TKey? SingleOrDefault (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.SingleOrDefault ((IEnumerable) source, predicate); + } + + /// Returns the element at a specified index in . + /// The element type of the collection. + /// The source collection. + /// The zero-based index of the element to retrieve. + /// The element at position in . + /// Thrown when is . + /// Thrown when is less than 0 or greater than or equal to the number of elements in . + public static TKey ElementAt (this Foundation.NSOrderedSet source, int index) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ElementAt ((IEnumerable) source, index); + } + + /// Returns the element at a specified index in , or if the index is out of range. + /// The element type of the collection. + /// The source collection. + /// The zero-based index of the element to retrieve. + /// The element at position in , or if the index is out of range. + /// Thrown when is . + public static TKey? ElementAtOrDefault (this Foundation.NSOrderedSet source, int index) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ElementAtOrDefault ((IEnumerable) source, index); + } + + /// Determines whether contains any elements. + /// The element type of the collection. + /// The source collection. + /// if contains any elements; otherwise . + /// Thrown when is . + public static bool Any (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Any ((IEnumerable) source); + } + + /// Determines whether any element of satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// if any element in passes the test in ; otherwise . + /// Thrown when or is . + public static bool Any (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Any ((IEnumerable) source, predicate); + } + + /// Determines whether all elements of satisfy a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// if every element in passes the test in , or if the collection is empty; otherwise . + /// Thrown when or is . + public static bool All (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.All ((IEnumerable) source, predicate); + } + + /// Returns the number of elements in . + /// The element type of the collection. + /// The source collection. + /// The number of elements in . + /// Thrown when is . + public static int Count (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Count ((IEnumerable) source); + } + + /// Returns the number of elements in that satisfy a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The number of elements in that pass the test in . + /// Thrown when or is . + public static int Count (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Count ((IEnumerable) source, predicate); + } + + /// Returns a that represents the total number of elements in . + /// The element type of the collection. + /// The source collection. + /// The number of elements in . + /// Thrown when is . + public static long LongCount (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.LongCount ((IEnumerable) source); + } + + /// Returns a that represents the number of elements in that satisfy a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The number of elements in that pass the test in . + /// Thrown when or is . + public static long LongCount (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.LongCount ((IEnumerable) source, predicate); + } + + /// Filters elements of based on a predicate. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// An that contains elements from that satisfy the condition. + /// Thrown when or is . + public static IEnumerable Where (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Where ((IEnumerable) source, predicate); + } + + /// Filters elements of based on a predicate that incorporates each element's index. + /// The element type of the collection. + /// The source collection. + /// A function to test each element; the second parameter represents the zero-based index of the element. + /// An that contains elements from that satisfy the condition. + /// Thrown when or is . + public static IEnumerable Where (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Where ((IEnumerable) source, predicate); + } + + /// Projects each element of into a new form. + /// The element type of the collection. + /// The type of the value returned by . + /// The source collection. + /// A transform function to apply to each element. + /// An whose elements are the result of invoking the transform function on each element of . + /// Thrown when or is . + public static IEnumerable Select (this Foundation.NSOrderedSet source, Func selector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (selector); + return Enumerable.Select ((IEnumerable) source, selector); + } + + /// Projects each element of into a new form by incorporating each element's index. + /// The element type of the collection. + /// The type of the value returned by . + /// The source collection. + /// A transform function to apply to each element; the second parameter represents the zero-based index of the element. + /// An whose elements are the result of invoking the transform function on each element of . + /// Thrown when or is . + public static IEnumerable Select (this Foundation.NSOrderedSet source, Func selector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (selector); + return Enumerable.Select ((IEnumerable) source, selector); + } + + /// Sorts the elements of in ascending order according to a key. + /// The element type of the collection. + /// The type of the key returned by . + /// The source collection. + /// A function to extract a key from an element. + /// An whose elements are sorted according to a key. + /// Thrown when or is . + public static IOrderedEnumerable OrderBy (this Foundation.NSOrderedSet source, Func keySelector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (keySelector); + return Enumerable.OrderBy ((IEnumerable) source, keySelector); + } + + /// Sorts the elements of in descending order according to a key. + /// The element type of the collection. + /// The type of the key returned by . + /// The source collection. + /// A function to extract a key from an element. + /// An whose elements are sorted in descending order according to a key. + /// Thrown when or is . + public static IOrderedEnumerable OrderByDescending (this Foundation.NSOrderedSet source, Func keySelector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (keySelector); + return Enumerable.OrderByDescending ((IEnumerable) source, keySelector); + } + + /// Bypasses a specified number of elements in and returns the remaining elements. + /// The element type of the collection. + /// The source collection. + /// The number of elements to skip before returning the remaining elements. + /// An that contains elements after the skipped ones. + /// Thrown when is . + public static IEnumerable Skip (this Foundation.NSOrderedSet source, int count) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Skip ((IEnumerable) source, count); + } + + /// Bypasses elements in as long as a condition is true, then returns the remaining elements. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// An that contains the elements starting at the first element that does not satisfy the condition. + /// Thrown when or is . + public static IEnumerable SkipWhile (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.SkipWhile ((IEnumerable) source, predicate); + } + + /// Returns a specified number of contiguous elements from the start of . + /// The element type of the collection. + /// The source collection. + /// The number of elements to return. + /// An that contains the specified number of elements from the start of . + /// Thrown when is . + public static IEnumerable Take (this Foundation.NSOrderedSet source, int count) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Take ((IEnumerable) source, count); + } + + /// Returns elements from as long as a specified condition is true. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// An that contains elements from as long as the condition is true. + /// Thrown when or is . + public static IEnumerable TakeWhile (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.TakeWhile ((IEnumerable) source, predicate); + } + + /// Returns distinct elements from . + /// The element type of the collection. + /// The source collection. + /// An that contains distinct elements from . + /// Thrown when is . + public static IEnumerable Distinct (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Distinct ((IEnumerable) source); + } + + /// Inverts the order of the elements in . + /// The element type of the collection. + /// The source collection. + /// An whose elements correspond to those of in reverse order. + /// Thrown when is . + public static IEnumerable Reverse (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Reverse ((IEnumerable) source); + } + + /// Concatenates with another sequence. + /// The element type of the collection. + /// The source collection. + /// The sequence to concatenate to . + /// An that contains the concatenated elements of the two sequences. + /// Thrown when or is . + public static IEnumerable Concat (this Foundation.NSOrderedSet source, IEnumerable second) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (second); + return Enumerable.Concat ((IEnumerable) source, second); + } + + /// Creates a from . + /// The element type of the collection. + /// The source collection. + /// A that contains elements from . + /// Thrown when is . + public static List ToList (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ToList ((IEnumerable) source); + } + + /// Creates an array from . + /// The element type of the collection. + /// The source collection. + /// An array that contains elements from . + /// Thrown when is . + public static TKey [] ToArray (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ToArray ((IEnumerable) source); + } + + /// Applies an accumulator function over . + /// The element type of the collection. + /// The source collection. + /// An accumulator function to be invoked on each element. + /// The final accumulator value. + /// Thrown when or is . + /// Thrown when is empty. + public static TKey Aggregate (this Foundation.NSOrderedSet source, Func func) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (func); + return Enumerable.Aggregate ((IEnumerable) source, func); + } + + /// Applies an accumulator function over with a seed value. + /// The element type of the collection. + /// The type of the accumulator value. + /// The source collection. + /// The initial accumulator value. + /// An accumulator function to be invoked on each element. + /// The final accumulator value. + /// Thrown when or is . + public static TAccumulate Aggregate (this Foundation.NSOrderedSet source, TAccumulate seed, Func func) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (func); + return Enumerable.Aggregate ((IEnumerable) source, seed, func); + } + + // NSMutableOrderedSet + /// Returns the first element of . + /// The element type of the collection. + /// The source collection. + /// The first element in . + /// Thrown when is . + /// Thrown when is empty. + public static TKey First (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.First ((IEnumerable) source); + } + + /// Returns the first element of that satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The first element in that passes the test in . + /// Thrown when or is . + /// Thrown when no element satisfies the condition in . + public static TKey First (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.First ((IEnumerable) source, predicate); + } + + /// Returns the first element of , or if the collection is empty. + /// The element type of the collection. + /// The source collection. + /// The first element in , or if the collection is empty. + /// Thrown when is . + public static TKey? FirstOrDefault (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.FirstOrDefault ((IEnumerable) source); + } + + /// Returns the first element of that satisfies a condition, or if no such element is found. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The first element in that passes the test in , or if no such element is found. + /// Thrown when or is . + public static TKey? FirstOrDefault (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.FirstOrDefault ((IEnumerable) source, predicate); + } + + /// Returns the last element of . + /// The element type of the collection. + /// The source collection. + /// The last element in . + /// Thrown when is . + /// Thrown when is empty. + public static TKey Last (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Last ((IEnumerable) source); + } + + /// Returns the last element of that satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The last element in that passes the test in . + /// Thrown when or is . + /// Thrown when no element satisfies the condition in . + public static TKey Last (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Last ((IEnumerable) source, predicate); + } + + /// Returns the last element of , or if the collection is empty. + /// The element type of the collection. + /// The source collection. + /// The last element in , or if the collection is empty. + /// Thrown when is . + public static TKey? LastOrDefault (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.LastOrDefault ((IEnumerable) source); + } + + /// Returns the last element of that satisfies a condition, or if no such element is found. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The last element in that passes the test in , or if no such element is found. + /// Thrown when or is . + public static TKey? LastOrDefault (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.LastOrDefault ((IEnumerable) source, predicate); + } + + /// Returns the only element of . + /// The element type of the collection. + /// The source collection. + /// The single element of . + /// Thrown when is . + /// Thrown when is empty or contains more than one element. + public static TKey Single (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Single ((IEnumerable) source); + } + + /// Returns the only element of that satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The single element in that passes the test in . + /// Thrown when or is . + /// Thrown when no element or more than one element satisfies the condition in . + public static TKey Single (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Single ((IEnumerable) source, predicate); + } + + /// Returns the only element of , or if the collection is empty. + /// The element type of the collection. + /// The source collection. + /// The single element of , or if the collection is empty. + /// Thrown when is . + /// Thrown when contains more than one element. + public static TKey? SingleOrDefault (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.SingleOrDefault ((IEnumerable) source); + } + + /// Returns the only element of that satisfies a condition, or if no such element is found. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The single element in that passes the test in , or if no such element is found. + /// Thrown when or is . + /// Thrown when more than one element satisfies the condition in . + public static TKey? SingleOrDefault (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.SingleOrDefault ((IEnumerable) source, predicate); + } + + /// Returns the element at a specified index in . + /// The element type of the collection. + /// The source collection. + /// The zero-based index of the element to retrieve. + /// The element at position in . + /// Thrown when is . + /// Thrown when is less than 0 or greater than or equal to the number of elements in . + public static TKey ElementAt (this Foundation.NSMutableOrderedSet source, int index) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ElementAt ((IEnumerable) source, index); + } + + /// Returns the element at a specified index in , or if the index is out of range. + /// The element type of the collection. + /// The source collection. + /// The zero-based index of the element to retrieve. + /// The element at position in , or if the index is out of range. + /// Thrown when is . + public static TKey? ElementAtOrDefault (this Foundation.NSMutableOrderedSet source, int index) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ElementAtOrDefault ((IEnumerable) source, index); + } + + /// Determines whether contains any elements. + /// The element type of the collection. + /// The source collection. + /// if contains any elements; otherwise . + /// Thrown when is . + public static bool Any (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Any ((IEnumerable) source); + } + + /// Determines whether any element of satisfies a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// if any element in passes the test in ; otherwise . + /// Thrown when or is . + public static bool Any (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Any ((IEnumerable) source, predicate); + } + + /// Determines whether all elements of satisfy a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// if every element in passes the test in , or if the collection is empty; otherwise . + /// Thrown when or is . + public static bool All (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.All ((IEnumerable) source, predicate); + } + + /// Returns the number of elements in . + /// The element type of the collection. + /// The source collection. + /// The number of elements in . + /// Thrown when is . + public static int Count (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Count ((IEnumerable) source); + } + + /// Returns the number of elements in that satisfy a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The number of elements in that pass the test in . + /// Thrown when or is . + public static int Count (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Count ((IEnumerable) source, predicate); + } + + /// Returns a that represents the total number of elements in . + /// The element type of the collection. + /// The source collection. + /// The number of elements in . + /// Thrown when is . + public static long LongCount (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.LongCount ((IEnumerable) source); + } + + /// Returns a that represents the number of elements in that satisfy a condition. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// The number of elements in that pass the test in . + /// Thrown when or is . + public static long LongCount (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.LongCount ((IEnumerable) source, predicate); + } + + /// Filters elements of based on a predicate. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// An that contains elements from that satisfy the condition. + /// Thrown when or is . + public static IEnumerable Where (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Where ((IEnumerable) source, predicate); + } + + /// Filters elements of based on a predicate that incorporates each element's index. + /// The element type of the collection. + /// The source collection. + /// A function to test each element; the second parameter represents the zero-based index of the element. + /// An that contains elements from that satisfy the condition. + /// Thrown when or is . + public static IEnumerable Where (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.Where ((IEnumerable) source, predicate); + } + + /// Projects each element of into a new form. + /// The element type of the collection. + /// The type of the value returned by . + /// The source collection. + /// A transform function to apply to each element. + /// An whose elements are the result of invoking the transform function on each element of . + /// Thrown when or is . + public static IEnumerable Select (this Foundation.NSMutableOrderedSet source, Func selector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (selector); + return Enumerable.Select ((IEnumerable) source, selector); + } + + /// Projects each element of into a new form by incorporating each element's index. + /// The element type of the collection. + /// The type of the value returned by . + /// The source collection. + /// A transform function to apply to each element; the second parameter represents the zero-based index of the element. + /// An whose elements are the result of invoking the transform function on each element of . + /// Thrown when or is . + public static IEnumerable Select (this Foundation.NSMutableOrderedSet source, Func selector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (selector); + return Enumerable.Select ((IEnumerable) source, selector); + } + + /// Sorts the elements of in ascending order according to a key. + /// The element type of the collection. + /// The type of the key returned by . + /// The source collection. + /// A function to extract a key from an element. + /// An whose elements are sorted according to a key. + /// Thrown when or is . + public static IOrderedEnumerable OrderBy (this Foundation.NSMutableOrderedSet source, Func keySelector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (keySelector); + return Enumerable.OrderBy ((IEnumerable) source, keySelector); + } + + /// Sorts the elements of in descending order according to a key. + /// The element type of the collection. + /// The type of the key returned by . + /// The source collection. + /// A function to extract a key from an element. + /// An whose elements are sorted in descending order according to a key. + /// Thrown when or is . + public static IOrderedEnumerable OrderByDescending (this Foundation.NSMutableOrderedSet source, Func keySelector) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (keySelector); + return Enumerable.OrderByDescending ((IEnumerable) source, keySelector); + } + + /// Bypasses a specified number of elements in and returns the remaining elements. + /// The element type of the collection. + /// The source collection. + /// The number of elements to skip before returning the remaining elements. + /// An that contains elements after the skipped ones. + /// Thrown when is . + public static IEnumerable Skip (this Foundation.NSMutableOrderedSet source, int count) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Skip ((IEnumerable) source, count); + } + + /// Bypasses elements in as long as a condition is true, then returns the remaining elements. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// An that contains the elements starting at the first element that does not satisfy the condition. + /// Thrown when or is . + public static IEnumerable SkipWhile (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.SkipWhile ((IEnumerable) source, predicate); + } + + /// Returns a specified number of contiguous elements from the start of . + /// The element type of the collection. + /// The source collection. + /// The number of elements to return. + /// An that contains the specified number of elements from the start of . + /// Thrown when is . + public static IEnumerable Take (this Foundation.NSMutableOrderedSet source, int count) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Take ((IEnumerable) source, count); + } + + /// Returns elements from as long as a specified condition is true. + /// The element type of the collection. + /// The source collection. + /// A function to test each element for a condition. + /// An that contains elements from as long as the condition is true. + /// Thrown when or is . + public static IEnumerable TakeWhile (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (predicate); + return Enumerable.TakeWhile ((IEnumerable) source, predicate); + } + + /// Returns distinct elements from . + /// The element type of the collection. + /// The source collection. + /// An that contains distinct elements from . + /// Thrown when is . + public static IEnumerable Distinct (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Distinct ((IEnumerable) source); + } + + /// Inverts the order of the elements in . + /// The element type of the collection. + /// The source collection. + /// An whose elements correspond to those of in reverse order. + /// Thrown when is . + public static IEnumerable Reverse (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.Reverse ((IEnumerable) source); + } + + /// Concatenates with another sequence. + /// The element type of the collection. + /// The source collection. + /// The sequence to concatenate to . + /// An that contains the concatenated elements of the two sequences. + /// Thrown when or is . + public static IEnumerable Concat (this Foundation.NSMutableOrderedSet source, IEnumerable second) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (second); + return Enumerable.Concat ((IEnumerable) source, second); + } + + /// Creates a from . + /// The element type of the collection. + /// The source collection. + /// A that contains elements from . + /// Thrown when is . + public static List ToList (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ToList ((IEnumerable) source); + } + + /// Creates an array from . + /// The element type of the collection. + /// The source collection. + /// An array that contains elements from . + /// Thrown when is . + public static TKey [] ToArray (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + return Enumerable.ToArray ((IEnumerable) source); + } + + /// Applies an accumulator function over . + /// The element type of the collection. + /// The source collection. + /// An accumulator function to be invoked on each element. + /// The final accumulator value. + /// Thrown when or is . + /// Thrown when is empty. + public static TKey Aggregate (this Foundation.NSMutableOrderedSet source, Func func) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (func); + return Enumerable.Aggregate ((IEnumerable) source, func); + } + + /// Applies an accumulator function over with a seed value. + /// The element type of the collection. + /// The type of the accumulator value. + /// The source collection. + /// The initial accumulator value. + /// An accumulator function to be invoked on each element. + /// The final accumulator value. + /// Thrown when or is . + public static TAccumulate Aggregate (this Foundation.NSMutableOrderedSet source, TAccumulate seed, Func func) where TKey : class, Foundation.INativeObject + { + ArgumentNullException.ThrowIfNull (source); + ArgumentNullException.ThrowIfNull (func); + return Enumerable.Aggregate ((IEnumerable) source, seed, func); } } } diff --git a/tests/monotouch-test/Foundation/NSCollectionLinqTest.cs b/tests/monotouch-test/Foundation/NSCollectionLinqTest.cs new file mode 100644 index 000000000000..23ae501d5075 --- /dev/null +++ b/tests/monotouch-test/Foundation/NSCollectionLinqTest.cs @@ -0,0 +1,1521 @@ +using System.Collections.Generic; +using System.Linq; + +using Foundation; + +using NUnit.Framework; + +namespace MonoTouchFixtures.Foundation { + +[TestFixture] +[Preserve (AllMembers = true)] +public class NSCollectionLinqTest { + +// ----- helpers ----- + +static NSString S (string s) => (NSString) s; + +static NSSet MakeSet (params string [] items) +{ +return new NSSet (items.Select (S).ToArray ()); +} + +static NSMutableSet MakeMutableSet (params string [] items) +{ +return new NSMutableSet (items.Select (S).ToArray ()); +} + +static NSArray MakeArray (params string [] items) +{ +return NSArray.FromNSObjects (items.Select (S).ToArray ()); +} + +static NSMutableArray MakeMutableArray (params string [] items) +{ +var arr = new NSMutableArray (); +foreach (var s in items) +arr.Add (S (s)); +return arr; +} + +static NSOrderedSet MakeOrderedSet (params string [] items) +{ +return new NSOrderedSet (items.Select (S).ToArray ()); +} + +static NSMutableOrderedSet MakeMutableOrderedSet (params string [] items) +{ +var set = new NSMutableOrderedSet (); +foreach (var s in items) +set.Add (S (s)); +return set; +} + +// ===== NSSet ===== + +[Test] +public void NSSet_First () +{ +using var set = MakeSet ("a"); +var first = set.First (); +Assert.That (first.ToString (), Is.EqualTo ("a"), "First"); +} + +[Test] +public void NSSet_First_Predicate () +{ +using var set = MakeSet ("a", "b", "c"); +var found = set.First (s => s.ToString () == "b"); +Assert.That (found.ToString (), Is.EqualTo ("b"), "First predicate"); +} + +[Test] +public void NSSet_First_Empty_Throws () +{ +using var set = MakeSet (); +Assert.Throws (() => set.First ()); +} + +[Test] +public void NSSet_FirstOrDefault_Empty () +{ +using var set = MakeSet (); +Assert.That (set.FirstOrDefault (), Is.Null, "FirstOrDefault empty"); +} + +[Test] +public void NSSet_FirstOrDefault () +{ +using var set = MakeSet ("x"); +Assert.That (set.FirstOrDefault (), Is.Not.Null, "FirstOrDefault"); +} + +[Test] +public void NSSet_FirstOrDefault_Predicate_NoMatch () +{ +using var set = MakeSet ("a", "b"); +Assert.That (set.FirstOrDefault (s => s.ToString () == "z"), Is.Null, "no match"); +} + +[Test] +public void NSSet_Last () +{ +using var set = MakeSet ("a"); +var last = set.Last (); +Assert.That (last.ToString (), Is.EqualTo ("a"), "Last"); +} + +[Test] +public void NSSet_Last_Predicate () +{ +using var set = MakeSet ("a", "b", "c"); +var found = set.Last (s => s.ToString () != "c"); +Assert.That (found, Is.Not.Null, "Last predicate not null"); +} + +[Test] +public void NSSet_Last_Empty_Throws () +{ +using var set = MakeSet (); +Assert.Throws (() => set.Last ()); +} + +[Test] +public void NSSet_LastOrDefault_Empty () +{ +using var set = MakeSet (); +Assert.That (set.LastOrDefault (), Is.Null, "LastOrDefault empty"); +} + +[Test] +public void NSSet_LastOrDefault_Predicate_NoMatch () +{ +using var set = MakeSet ("a"); +Assert.That (set.LastOrDefault (s => s.ToString () == "z"), Is.Null, "LastOrDefault no match"); +} + +[Test] +public void NSSet_Single () +{ +using var set = MakeSet ("only"); +Assert.That (set.Single ().ToString (), Is.EqualTo ("only"), "Single"); +} + +[Test] +public void NSSet_Single_Throws_OnMultiple () +{ +using var set = MakeSet ("a", "b"); +Assert.Throws (() => set.Single ()); +} + +[Test] +public void NSSet_SingleOrDefault_Empty () +{ +using var set = MakeSet (); +Assert.That (set.SingleOrDefault (), Is.Null, "SingleOrDefault empty"); +} + +[Test] +public void NSSet_SingleOrDefault_Predicate () +{ +using var set = MakeSet ("a", "b"); +Assert.That (set.SingleOrDefault (s => s.ToString () == "a")?.ToString (), Is.EqualTo ("a"), "SingleOrDefault predicate"); +} + +[Test] +public void NSSet_Any_Empty () +{ +using var set = MakeSet (); +Assert.That (set.Any (), Is.False, "Any empty"); +} + +[Test] +public void NSSet_Any_NonEmpty () +{ +using var set = MakeSet ("a"); +Assert.That (set.Any (), Is.True, "Any non-empty"); +} + +[Test] +public void NSSet_Any_Predicate () +{ +using var set = MakeSet ("a", "b"); +Assert.That (set.Any (s => s.ToString () == "b"), Is.True, "Any predicate true"); +Assert.That (set.Any (s => s.ToString () == "z"), Is.False, "Any predicate false"); +} + +[Test] +public void NSSet_All () +{ +using var set = MakeSet ("ab", "abc"); +Assert.That (set.All (s => s.Length > 1), Is.True, "All true"); +Assert.That (set.All (s => s.Length > 2), Is.False, "All false"); +} + +[Test] +public void NSSet_Count () +{ +using var set = MakeSet ("a", "b", "c"); +Assert.That (set.Count (), Is.EqualTo (3), "Count"); +Assert.That (set.Count (s => s.ToString () == "a"), Is.EqualTo (1), "Count predicate"); +} + +[Test] +public void NSSet_LongCount () +{ +using var set = MakeSet ("a", "b"); +Assert.That (set.LongCount (), Is.EqualTo (2L), "LongCount"); +Assert.That (set.LongCount (s => s.ToString () == "a"), Is.EqualTo (1L), "LongCount predicate"); +} + +[Test] +public void NSSet_Where () +{ +using var set = MakeSet ("a", "bb", "ccc"); +var result = set.Where (s => s.Length > 1).ToList (); +Assert.That (result.Count, Is.EqualTo (2), "Where count"); +} + +[Test] +public void NSSet_Where_Index () +{ +using var arr = MakeOrderedSet ("a", "b", "c"); +var result = arr.Where ((s, i) => i % 2 == 0).ToList (); +Assert.That (result.Count, Is.EqualTo (2), "Where index count"); +} + +[Test] +public void NSSet_Select () +{ +using var set = MakeSet ("hello"); +var lengths = set.Select (s => s.Length).ToList (); +Assert.That (lengths, Contains.Item (5), "Select length"); +} + +[Test] +public void NSSet_Select_Index () +{ +using var arr = MakeOrderedSet ("a", "b", "c"); +var indexed = arr.Select ((s, i) => $"{i}:{s}").ToList (); +Assert.That (indexed [0], Is.EqualTo ("0:a"), "Select index 0"); +Assert.That (indexed [1], Is.EqualTo ("1:b"), "Select index 1"); +} + +[Test] +public void NSSet_OrderBy () +{ +using var set = MakeSet ("banana", "apple", "cherry"); +var sorted = set.OrderBy (s => s.ToString ()).ToList (); +Assert.That (sorted [0].ToString (), Is.EqualTo ("apple"), "OrderBy first"); +Assert.That (sorted [2].ToString (), Is.EqualTo ("cherry"), "OrderBy last"); +} + +[Test] +public void NSSet_OrderByDescending () +{ +using var set = MakeSet ("banana", "apple", "cherry"); +var sorted = set.OrderByDescending (s => s.ToString ()).ToList (); +Assert.That (sorted [0].ToString (), Is.EqualTo ("cherry"), "OrderByDesc first"); +} + +[Test] +public void NSSet_Distinct () +{ +using var set = MakeSet ("a", "b", "b"); +// NSSet already ensures uniqueness, but verify Distinct works +var distinct = set.Distinct ().ToList (); +Assert.That (distinct.Count, Is.EqualTo (2), "Distinct count"); +} + +[Test] +public void NSSet_Reverse () +{ +using var arr = MakeOrderedSet ("a", "b", "c"); +var reversed = arr.Reverse ().ToList (); +Assert.That (reversed [0].ToString (), Is.EqualTo ("c"), "Reverse first"); +Assert.That (reversed [2].ToString (), Is.EqualTo ("a"), "Reverse last"); +} + +[Test] +public void NSSet_Concat () +{ +using var set = MakeSet ("a", "b"); +var extra = new [] { S ("c"), S ("d") }; +var all = set.Concat (extra).ToList (); +Assert.That (all.Count, Is.EqualTo (4), "Concat count"); +} + +[Test] +public void NSSet_Skip_Take () +{ +using var arr = MakeOrderedSet ("a", "b", "c", "d"); +var sliced = arr.Skip (1).Take (2).ToList (); +Assert.That (sliced.Count, Is.EqualTo (2), "Skip/Take count"); +Assert.That (sliced [0].ToString (), Is.EqualTo ("b"), "Skip/Take first"); +} + +[Test] +public void NSSet_SkipWhile_TakeWhile () +{ +using var arr = MakeOrderedSet ("a", "b", "c"); +var skipped = arr.SkipWhile (s => s.ToString () == "a").ToList (); +Assert.That (skipped.Count, Is.EqualTo (2), "SkipWhile count"); + +var taken = arr.TakeWhile (s => s.ToString () != "c").ToList (); +Assert.That (taken.Count, Is.EqualTo (2), "TakeWhile count"); +} + +[Test] +public void NSSet_ElementAt () +{ +using var arr = MakeOrderedSet ("a", "b", "c"); +Assert.That (arr.ElementAt (1).ToString (), Is.EqualTo ("b"), "ElementAt"); +} + +[Test] +public void NSSet_ElementAtOrDefault () +{ +using var arr = MakeOrderedSet ("a", "b"); +Assert.That (arr.ElementAtOrDefault (0), Is.Not.Null, "ElementAtOrDefault in range"); +Assert.That (arr.ElementAtOrDefault (99), Is.Null, "ElementAtOrDefault out of range"); +} + +[Test] +public void NSSet_ToList () +{ +using var set = MakeSet ("a", "b"); +var list = set.ToList (); +Assert.That (list, Is.TypeOf> (), "ToList type"); +Assert.That (list.Count, Is.EqualTo (2), "ToList count"); +} + +[Test] +public void NSSet_ToArray () +{ +using var set = MakeSet ("a", "b"); +var arr = set.ToArray (); +Assert.That (arr, Is.TypeOf (), "ToArray type"); +Assert.That (arr.Length, Is.EqualTo (2), "ToArray length"); +} + +[Test] +public void NSSet_Aggregate () +{ +using var arr = MakeOrderedSet ("a", "b", "c"); +var result = arr.Aggregate ((acc, s) => (NSString) (acc.ToString () + s.ToString ())); +Assert.That (result.ToString (), Is.EqualTo ("abc"), "Aggregate"); +} + +[Test] +public void NSSet_Aggregate_Seed () +{ +using var arr = MakeOrderedSet ("a", "b", "c"); +var result = arr.Aggregate ("", (acc, s) => acc + s.ToString ()); +Assert.That (result, Is.EqualTo ("abc"), "Aggregate seed"); +} + +// ===== NSMutableSet ===== + +[Test] +public void NSMutableSet_First () +{ +using var set = MakeMutableSet ("a"); +Assert.That (set.First ().ToString (), Is.EqualTo ("a"), "First"); +} + +[Test] +public void NSMutableSet_FirstOrDefault_Empty () +{ +using var set = MakeMutableSet (); +Assert.That (set.FirstOrDefault (), Is.Null, "FirstOrDefault empty"); +} + +[Test] +public void NSMutableSet_Last () +{ +using var set = MakeMutableSet ("a"); +Assert.That (set.Last ().ToString (), Is.EqualTo ("a"), "Last"); +} + +[Test] +public void NSMutableSet_LastOrDefault_Empty () +{ +using var set = MakeMutableSet (); +Assert.That (set.LastOrDefault (), Is.Null, "LastOrDefault empty"); +} + +[Test] +public void NSMutableSet_Single () +{ +using var set = MakeMutableSet ("only"); +Assert.That (set.Single ().ToString (), Is.EqualTo ("only"), "Single"); +} + +[Test] +public void NSMutableSet_SingleOrDefault_Empty () +{ +using var set = MakeMutableSet (); +Assert.That (set.SingleOrDefault (), Is.Null, "SingleOrDefault empty"); +} + +[Test] +public void NSMutableSet_Any () +{ +using var set = MakeMutableSet (); +Assert.That (set.Any (), Is.False, "Any empty"); +using var set2 = MakeMutableSet ("a"); +Assert.That (set2.Any (), Is.True, "Any non-empty"); +} + +[Test] +public void NSMutableSet_All () +{ +using var set = MakeMutableSet ("ab", "abc"); +Assert.That (set.All (s => s.Length > 1), Is.True, "All true"); +} + +[Test] +public void NSMutableSet_Count () +{ +using var set = MakeMutableSet ("a", "b", "c"); +Assert.That (set.Count (), Is.EqualTo (3), "Count"); +} + +[Test] +public void NSMutableSet_LongCount () +{ +using var set = MakeMutableSet ("a", "b"); +Assert.That (set.LongCount (), Is.EqualTo (2L), "LongCount"); +} + +[Test] +public void NSMutableSet_Where () +{ +using var set = MakeMutableSet ("a", "bb", "ccc"); +var result = set.Where (s => s.Length > 1).ToList (); +Assert.That (result.Count, Is.EqualTo (2), "Where count"); +} + +[Test] +public void NSMutableSet_Select () +{ +using var set = MakeMutableSet ("hello"); +var lengths = set.Select (s => s.Length).ToList (); +Assert.That (lengths, Contains.Item (5), "Select length"); +} + +[Test] +public void NSMutableSet_OrderBy () +{ +using var set = MakeMutableSet ("banana", "apple", "cherry"); +var sorted = set.OrderBy (s => s.ToString ()).ToList (); +Assert.That (sorted [0].ToString (), Is.EqualTo ("apple"), "OrderBy first"); +} + +[Test] +public void NSMutableSet_Skip_Take () +{ +using var arr = MakeOrderedSet ("a", "b", "c", "d"); +var sliced = arr.Skip (1).Take (2).ToList (); +Assert.That (sliced.Count, Is.EqualTo (2), "Skip/Take count"); +} + +[Test] +public void NSMutableSet_ToList () +{ +using var set = MakeMutableSet ("a", "b"); +var list = set.ToList (); +Assert.That (list.Count, Is.EqualTo (2), "ToList count"); +} + +[Test] +public void NSMutableSet_ToArray () +{ +using var set = MakeMutableSet ("a", "b"); +var arr = set.ToArray (); +Assert.That (arr.Length, Is.EqualTo (2), "ToArray length"); +} + +[Test] +public void NSMutableSet_Aggregate () +{ +using var set = MakeMutableSet ("a"); +var result = set.Aggregate ((acc, s) => (NSString) (acc.ToString () + s.ToString ())); +Assert.That (result.ToString (), Is.EqualTo ("a"), "Aggregate"); +} + +// ===== NSArray ===== + +[Test] +public void NSArray_First () +{ +using var arr = MakeArray ("a", "b", "c"); +Assert.That (arr.First ().ToString (), Is.EqualTo ("a"), "First"); +} + +[Test] +public void NSArray_First_Predicate () +{ +using var arr = MakeArray ("a", "b", "c"); +Assert.That (arr.First (s => s.ToString () == "b").ToString (), Is.EqualTo ("b"), "First predicate"); +} + +[Test] +public void NSArray_First_Empty_Throws () +{ +using var arr = MakeArray (); +Assert.Throws (() => arr.First ()); +} + +[Test] +public void NSArray_FirstOrDefault_Empty () +{ +using var arr = MakeArray (); +Assert.That (arr.FirstOrDefault (), Is.Null, "FirstOrDefault empty"); +} + +[Test] +public void NSArray_FirstOrDefault () +{ +using var arr = MakeArray ("x", "y"); +Assert.That (arr.FirstOrDefault ()?.ToString (), Is.EqualTo ("x"), "FirstOrDefault"); +} + +[Test] +public void NSArray_FirstOrDefault_Predicate () +{ +using var arr = MakeArray ("a", "b", "c"); +Assert.That (arr.FirstOrDefault (s => s.ToString () == "b")?.ToString (), Is.EqualTo ("b"), "FirstOrDefault predicate match"); +Assert.That (arr.FirstOrDefault (s => s.ToString () == "z"), Is.Null, "FirstOrDefault predicate no match"); +} + +[Test] +public void NSArray_Last () +{ +using var arr = MakeArray ("a", "b", "c"); +Assert.That (arr.Last ().ToString (), Is.EqualTo ("c"), "Last"); +} + +[Test] +public void NSArray_Last_Predicate () +{ +using var arr = MakeArray ("a", "b", "c"); +Assert.That (arr.Last (s => s.ToString () != "c").ToString (), Is.EqualTo ("b"), "Last predicate"); +} + +[Test] +public void NSArray_Last_Empty_Throws () +{ +using var arr = MakeArray (); +Assert.Throws (() => arr.Last ()); +} + +[Test] +public void NSArray_LastOrDefault_Empty () +{ +using var arr = MakeArray (); +Assert.That (arr.LastOrDefault (), Is.Null, "LastOrDefault empty"); +} + +[Test] +public void NSArray_LastOrDefault_Predicate_NoMatch () +{ +using var arr = MakeArray ("a", "b"); +Assert.That (arr.LastOrDefault (s => s.ToString () == "z"), Is.Null, "LastOrDefault no match"); +} + +[Test] +public void NSArray_Single () +{ +using var arr = MakeArray ("only"); +Assert.That (arr.Single ().ToString (), Is.EqualTo ("only"), "Single"); +} + +[Test] +public void NSArray_Single_Throws_OnEmpty () +{ +using var arr = MakeArray (); +Assert.Throws (() => arr.Single ()); +} + +[Test] +public void NSArray_Single_Throws_OnMultiple () +{ +using var arr = MakeArray ("a", "b"); +Assert.Throws (() => arr.Single ()); +} + +[Test] +public void NSArray_SingleOrDefault_Empty () +{ +using var arr = MakeArray (); +Assert.That (arr.SingleOrDefault (), Is.Null, "SingleOrDefault empty"); +} + +[Test] +public void NSArray_SingleOrDefault_Predicate () +{ +using var arr = MakeArray ("a", "b"); +Assert.That (arr.SingleOrDefault (s => s.ToString () == "a")?.ToString (), Is.EqualTo ("a"), "SingleOrDefault predicate match"); +Assert.That (arr.SingleOrDefault (s => s.ToString () == "z"), Is.Null, "SingleOrDefault predicate no match"); +} + +[Test] +public void NSArray_ElementAt () +{ +using var arr = MakeArray ("a", "b", "c"); +Assert.That (arr.ElementAt (0).ToString (), Is.EqualTo ("a"), "ElementAt 0"); +Assert.That (arr.ElementAt (2).ToString (), Is.EqualTo ("c"), "ElementAt 2"); +} + +[Test] +public void NSArray_ElementAt_OutOfRange_Throws () +{ +using var arr = MakeArray ("a"); +Assert.Throws (() => arr.ElementAt (5)); +} + +[Test] +public void NSArray_ElementAtOrDefault () +{ +using var arr = MakeArray ("a", "b"); +Assert.That (arr.ElementAtOrDefault (1)?.ToString (), Is.EqualTo ("b"), "ElementAtOrDefault in range"); +Assert.That (arr.ElementAtOrDefault (99), Is.Null, "ElementAtOrDefault out of range"); +} + +[Test] +public void NSArray_Any () +{ +using var empty = MakeArray (); +Assert.That (empty.Any (), Is.False, "Any empty"); +using var arr = MakeArray ("a"); +Assert.That (arr.Any (), Is.True, "Any non-empty"); +Assert.That (arr.Any (s => s.ToString () == "a"), Is.True, "Any predicate true"); +Assert.That (arr.Any (s => s.ToString () == "z"), Is.False, "Any predicate false"); +} + +[Test] +public void NSArray_All () +{ +using var arr = MakeArray ("ab", "abc"); +Assert.That (arr.All (s => s.Length > 1), Is.True, "All true"); +Assert.That (arr.All (s => s.Length > 2), Is.False, "All false"); +} + +[Test] +public void NSArray_Count () +{ +using var arr = MakeArray ("a", "b", "c"); +Assert.That (arr.Count (), Is.EqualTo (3), "Count"); +Assert.That (arr.Count (s => s.ToString () == "a"), Is.EqualTo (1), "Count predicate"); +} + +[Test] +public void NSArray_LongCount () +{ +using var arr = MakeArray ("a", "b"); +Assert.That (arr.LongCount (), Is.EqualTo (2L), "LongCount"); +Assert.That (arr.LongCount (s => s.ToString () == "a"), Is.EqualTo (1L), "LongCount predicate"); +} + +[Test] +public void NSArray_Where () +{ +using var arr = MakeArray ("a", "bb", "ccc"); +var result = arr.Where (s => s.Length > 1).ToList (); +Assert.That (result.Count, Is.EqualTo (2), "Where count"); +} + +[Test] +public void NSArray_Where_Index () +{ +using var arr = MakeArray ("a", "b", "c"); +var result = arr.Where ((s, i) => i % 2 == 0).ToList (); +Assert.That (result.Count, Is.EqualTo (2), "Where index count"); +Assert.That (result [0].ToString (), Is.EqualTo ("a"), "Where index [0]"); +Assert.That (result [1].ToString (), Is.EqualTo ("c"), "Where index [1]"); +} + +[Test] +public void NSArray_Select () +{ +using var arr = MakeArray ("hello", "world"); +var lengths = arr.Select (s => s.Length).ToList (); +Assert.That (lengths [0], Is.EqualTo (5), "Select length [0]"); +Assert.That (lengths [1], Is.EqualTo (5), "Select length [1]"); +} + +[Test] +public void NSArray_Select_Index () +{ +using var arr = MakeArray ("a", "b", "c"); +var indexed = arr.Select ((s, i) => $"{i}:{s}").ToList (); +Assert.That (indexed [0], Is.EqualTo ("0:a"), "Select index 0"); +Assert.That (indexed [2], Is.EqualTo ("2:c"), "Select index 2"); +} + +[Test] +public void NSArray_OrderBy () +{ +using var arr = MakeArray ("banana", "apple", "cherry"); +var sorted = arr.OrderBy (s => s.ToString ()).ToList (); +Assert.That (sorted [0].ToString (), Is.EqualTo ("apple"), "OrderBy first"); +Assert.That (sorted [1].ToString (), Is.EqualTo ("banana"), "OrderBy second"); +Assert.That (sorted [2].ToString (), Is.EqualTo ("cherry"), "OrderBy third"); +} + +[Test] +public void NSArray_OrderByDescending () +{ +using var arr = MakeArray ("banana", "apple", "cherry"); +var sorted = arr.OrderByDescending (s => s.ToString ()).ToList (); +Assert.That (sorted [0].ToString (), Is.EqualTo ("cherry"), "OrderByDesc first"); +Assert.That (sorted [2].ToString (), Is.EqualTo ("apple"), "OrderByDesc last"); +} + +[Test] +public void NSArray_Skip () +{ +using var arr = MakeArray ("a", "b", "c", "d"); +var skipped = arr.Skip (2).ToList (); +Assert.That (skipped.Count, Is.EqualTo (2), "Skip count"); +Assert.That (skipped [0].ToString (), Is.EqualTo ("c"), "Skip [0]"); +} + +[Test] +public void NSArray_SkipWhile () +{ +using var arr = MakeArray ("a", "b", "c"); +var result = arr.SkipWhile (s => s.ToString () != "b").ToList (); +Assert.That (result.Count, Is.EqualTo (2), "SkipWhile count"); +Assert.That (result [0].ToString (), Is.EqualTo ("b"), "SkipWhile first"); +} + +[Test] +public void NSArray_Take () +{ +using var arr = MakeArray ("a", "b", "c"); +var taken = arr.Take (2).ToList (); +Assert.That (taken.Count, Is.EqualTo (2), "Take count"); +Assert.That (taken [1].ToString (), Is.EqualTo ("b"), "Take [1]"); +} + +[Test] +public void NSArray_TakeWhile () +{ +using var arr = MakeArray ("a", "b", "c"); +var taken = arr.TakeWhile (s => s.ToString () != "c").ToList (); +Assert.That (taken.Count, Is.EqualTo (2), "TakeWhile count"); +} + +[Test] +public void NSArray_Distinct () +{ +using var arr = MakeArray ("a", "a", "b"); +var distinct = arr.Distinct ().ToList (); +Assert.That (distinct.Count, Is.EqualTo (2), "Distinct count"); +} + +[Test] +public void NSArray_Reverse () +{ +using var arr = MakeArray ("a", "b", "c"); +var reversed = arr.Reverse ().ToList (); +Assert.That (reversed [0].ToString (), Is.EqualTo ("c"), "Reverse [0]"); +Assert.That (reversed [2].ToString (), Is.EqualTo ("a"), "Reverse [2]"); +} + +[Test] +public void NSArray_Concat () +{ +using var arr = MakeArray ("a", "b"); +var extra = new [] { S ("c") }; +var all = arr.Concat (extra).ToList (); +Assert.That (all.Count, Is.EqualTo (3), "Concat count"); +Assert.That (all [2].ToString (), Is.EqualTo ("c"), "Concat last"); +} + +[Test] +public void NSArray_ToList () +{ +using var arr = MakeArray ("a", "b", "c"); +var list = arr.ToList (); +Assert.That (list, Is.TypeOf> (), "ToList type"); +Assert.That (list.Count, Is.EqualTo (3), "ToList count"); +} + +[Test] +public void NSArray_ToArray () +{ +using var arr = MakeArray ("a", "b"); +var result = arr.ToArray (); +Assert.That (result, Is.TypeOf (), "ToArray type"); +Assert.That (result.Length, Is.EqualTo (2), "ToArray length"); +} + +[Test] +public void NSArray_Aggregate () +{ +using var arr = MakeArray ("a", "b", "c"); +var result = arr.Aggregate ((acc, s) => (NSString) (acc.ToString () + s.ToString ())); +Assert.That (result.ToString (), Is.EqualTo ("abc"), "Aggregate"); +} + +[Test] +public void NSArray_Aggregate_Seed () +{ +using var arr = MakeArray ("a", "b", "c"); +var result = arr.Aggregate ("", (acc, s) => acc + s.ToString ()); +Assert.That (result, Is.EqualTo ("abc"), "Aggregate seed"); +} + +// ===== NSMutableArray ===== + +[Test] +public void NSMutableArray_First () +{ +using var arr = MakeMutableArray ("a", "b"); +Assert.That (arr.First ().ToString (), Is.EqualTo ("a"), "First"); +} + +[Test] +public void NSMutableArray_First_Empty_Throws () +{ +using var arr = MakeMutableArray (); +Assert.Throws (() => arr.First ()); +} + +[Test] +public void NSMutableArray_FirstOrDefault_Empty () +{ +using var arr = MakeMutableArray (); +Assert.That (arr.FirstOrDefault (), Is.Null, "FirstOrDefault empty"); +} + +[Test] +public void NSMutableArray_FirstOrDefault () +{ +using var arr = MakeMutableArray ("x", "y"); +Assert.That (arr.FirstOrDefault ()?.ToString (), Is.EqualTo ("x"), "FirstOrDefault"); +} + +[Test] +public void NSMutableArray_Last () +{ +using var arr = MakeMutableArray ("a", "b", "c"); +Assert.That (arr.Last ().ToString (), Is.EqualTo ("c"), "Last"); +} + +[Test] +public void NSMutableArray_LastOrDefault_Empty () +{ +using var arr = MakeMutableArray (); +Assert.That (arr.LastOrDefault (), Is.Null, "LastOrDefault empty"); +} + +[Test] +public void NSMutableArray_Single () +{ +using var arr = MakeMutableArray ("only"); +Assert.That (arr.Single ().ToString (), Is.EqualTo ("only"), "Single"); +} + +[Test] +public void NSMutableArray_Single_Throws_OnMultiple () +{ +using var arr = MakeMutableArray ("a", "b"); +Assert.Throws (() => arr.Single ()); +} + +[Test] +public void NSMutableArray_SingleOrDefault_Empty () +{ +using var arr = MakeMutableArray (); +Assert.That (arr.SingleOrDefault (), Is.Null, "SingleOrDefault empty"); +} + +[Test] +public void NSMutableArray_ElementAt () +{ +using var arr = MakeMutableArray ("a", "b", "c"); +Assert.That (arr.ElementAt (1).ToString (), Is.EqualTo ("b"), "ElementAt 1"); +} + +[Test] +public void NSMutableArray_ElementAtOrDefault () +{ +using var arr = MakeMutableArray ("a"); +Assert.That (arr.ElementAtOrDefault (0)?.ToString (), Is.EqualTo ("a"), "ElementAtOrDefault in range"); +Assert.That (arr.ElementAtOrDefault (10), Is.Null, "ElementAtOrDefault out of range"); +} + +[Test] +public void NSMutableArray_Any () +{ +using var empty = MakeMutableArray (); +Assert.That (empty.Any (), Is.False, "Any empty"); +using var arr = MakeMutableArray ("a"); +Assert.That (arr.Any (), Is.True, "Any non-empty"); +} + +[Test] +public void NSMutableArray_All () +{ +using var arr = MakeMutableArray ("ab", "abc"); +Assert.That (arr.All (s => s.Length > 1), Is.True, "All true"); +} + +[Test] +public void NSMutableArray_Count () +{ +using var arr = MakeMutableArray ("a", "b", "c"); +Assert.That (arr.Count (), Is.EqualTo (3), "Count"); +} + +[Test] +public void NSMutableArray_LongCount () +{ +using var arr = MakeMutableArray ("a", "b"); +Assert.That (arr.LongCount (), Is.EqualTo (2L), "LongCount"); +} + +[Test] +public void NSMutableArray_Where () +{ +using var arr = MakeMutableArray ("a", "bb", "ccc"); +var result = arr.Where (s => s.Length > 1).ToList (); +Assert.That (result.Count, Is.EqualTo (2), "Where count"); +} + +[Test] +public void NSMutableArray_Select () +{ +using var arr = MakeMutableArray ("hello", "world"); +var lengths = arr.Select (s => s.Length).ToList (); +Assert.That (lengths [0], Is.EqualTo (5), "Select [0]"); +} + +[Test] +public void NSMutableArray_OrderBy () +{ +using var arr = MakeMutableArray ("banana", "apple", "cherry"); +var sorted = arr.OrderBy (s => s.ToString ()).ToList (); +Assert.That (sorted [0].ToString (), Is.EqualTo ("apple"), "OrderBy first"); +} + +[Test] +public void NSMutableArray_OrderByDescending () +{ +using var arr = MakeMutableArray ("banana", "apple", "cherry"); +var sorted = arr.OrderByDescending (s => s.ToString ()).ToList (); +Assert.That (sorted [0].ToString (), Is.EqualTo ("cherry"), "OrderByDesc first"); +} + +[Test] +public void NSMutableArray_Skip_Take () +{ +using var arr = MakeMutableArray ("a", "b", "c", "d"); +var sliced = arr.Skip (1).Take (2).ToList (); +Assert.That (sliced.Count, Is.EqualTo (2), "Skip/Take count"); +} + +[Test] +public void NSMutableArray_SkipWhile_TakeWhile () +{ +using var arr = MakeMutableArray ("a", "b", "c"); +var skipped = arr.SkipWhile (s => s.ToString () == "a").ToList (); +Assert.That (skipped.Count, Is.EqualTo (2), "SkipWhile count"); +var taken = arr.TakeWhile (s => s.ToString () != "c").ToList (); +Assert.That (taken.Count, Is.EqualTo (2), "TakeWhile count"); +} + +[Test] +public void NSMutableArray_Distinct () +{ +using var arr = MakeMutableArray ("a", "a", "b"); +var distinct = arr.Distinct ().ToList (); +Assert.That (distinct.Count, Is.EqualTo (2), "Distinct count"); +} + +[Test] +public void NSMutableArray_Reverse () +{ +using var arr = MakeMutableArray ("a", "b", "c"); +var reversed = arr.Reverse ().ToList (); +Assert.That (reversed [0].ToString (), Is.EqualTo ("c"), "Reverse [0]"); +} + +[Test] +public void NSMutableArray_Concat () +{ +using var arr = MakeMutableArray ("a"); +var all = arr.Concat (new [] { S ("b") }).ToList (); +Assert.That (all.Count, Is.EqualTo (2), "Concat count"); +} + +[Test] +public void NSMutableArray_ToList () +{ +using var arr = MakeMutableArray ("a", "b"); +var list = arr.ToList (); +Assert.That (list.Count, Is.EqualTo (2), "ToList count"); +} + +[Test] +public void NSMutableArray_ToArray () +{ +using var arr = MakeMutableArray ("a", "b"); +var result = arr.ToArray (); +Assert.That (result.Length, Is.EqualTo (2), "ToArray length"); +} + +[Test] +public void NSMutableArray_Aggregate () +{ +using var arr = MakeMutableArray ("a", "b", "c"); +var result = arr.Aggregate ((acc, s) => (NSString) (acc.ToString () + s.ToString ())); +Assert.That (result.ToString (), Is.EqualTo ("abc"), "Aggregate"); +} + +[Test] +public void NSMutableArray_Aggregate_Seed () +{ +using var arr = MakeMutableArray ("a", "b", "c"); +var result = arr.Aggregate (0, (acc, s) => acc + s.Length); +Assert.That (result, Is.EqualTo (3), "Aggregate seed"); +} + +// ===== NSOrderedSet ===== + +[Test] +public void NSOrderedSet_First () +{ +using var set = MakeOrderedSet ("a", "b", "c"); +Assert.That (set.First ().ToString (), Is.EqualTo ("a"), "First"); +} + +[Test] +public void NSOrderedSet_First_Predicate () +{ +using var set = MakeOrderedSet ("a", "b", "c"); +Assert.That (set.First (s => s.ToString () == "c").ToString (), Is.EqualTo ("c"), "First predicate"); +} + +[Test] +public void NSOrderedSet_First_Empty_Throws () +{ +using var set = MakeOrderedSet (); +Assert.Throws (() => set.First ()); +} + +[Test] +public void NSOrderedSet_FirstOrDefault_Empty () +{ +using var set = MakeOrderedSet (); +Assert.That (set.FirstOrDefault (), Is.Null, "FirstOrDefault empty"); +} + +[Test] +public void NSOrderedSet_FirstOrDefault () +{ +using var set = MakeOrderedSet ("x", "y"); +Assert.That (set.FirstOrDefault ()?.ToString (), Is.EqualTo ("x"), "FirstOrDefault"); +} + +[Test] +public void NSOrderedSet_Last () +{ +using var set = MakeOrderedSet ("a", "b", "c"); +Assert.That (set.Last ().ToString (), Is.EqualTo ("c"), "Last"); +} + +[Test] +public void NSOrderedSet_Last_Predicate () +{ +using var set = MakeOrderedSet ("a", "b", "c"); +Assert.That (set.Last (s => s.ToString () != "c").ToString (), Is.EqualTo ("b"), "Last predicate"); +} + +[Test] +public void NSOrderedSet_Last_Empty_Throws () +{ +using var set = MakeOrderedSet (); +Assert.Throws (() => set.Last ()); +} + +[Test] +public void NSOrderedSet_LastOrDefault_Empty () +{ +using var set = MakeOrderedSet (); +Assert.That (set.LastOrDefault (), Is.Null, "LastOrDefault empty"); +} + +[Test] +public void NSOrderedSet_Single () +{ +using var set = MakeOrderedSet ("only"); +Assert.That (set.Single ().ToString (), Is.EqualTo ("only"), "Single"); +} + +[Test] +public void NSOrderedSet_Single_Throws_OnMultiple () +{ +using var set = MakeOrderedSet ("a", "b"); +Assert.Throws (() => set.Single ()); +} + +[Test] +public void NSOrderedSet_SingleOrDefault_Empty () +{ +using var set = MakeOrderedSet (); +Assert.That (set.SingleOrDefault (), Is.Null, "SingleOrDefault empty"); +} + +[Test] +public void NSOrderedSet_SingleOrDefault_Predicate () +{ +using var set = MakeOrderedSet ("a", "b"); +Assert.That (set.SingleOrDefault (s => s.ToString () == "a")?.ToString (), Is.EqualTo ("a"), "SingleOrDefault predicate match"); +} + +[Test] +public void NSOrderedSet_ElementAt () +{ +using var set = MakeOrderedSet ("a", "b", "c"); +Assert.That (set.ElementAt (1).ToString (), Is.EqualTo ("b"), "ElementAt 1"); +} + +[Test] +public void NSOrderedSet_ElementAtOrDefault () +{ +using var set = MakeOrderedSet ("a"); +Assert.That (set.ElementAtOrDefault (0)?.ToString (), Is.EqualTo ("a"), "in range"); +Assert.That (set.ElementAtOrDefault (5), Is.Null, "out of range"); +} + +[Test] +public void NSOrderedSet_Any () +{ +using var empty = MakeOrderedSet (); +Assert.That (empty.Any (), Is.False, "Any empty"); +using var set = MakeOrderedSet ("a"); +Assert.That (set.Any (), Is.True, "Any non-empty"); +Assert.That (set.Any (s => s.ToString () == "a"), Is.True, "Any predicate true"); +Assert.That (set.Any (s => s.ToString () == "z"), Is.False, "Any predicate false"); +} + +[Test] +public void NSOrderedSet_All () +{ +using var set = MakeOrderedSet ("ab", "abc"); +Assert.That (set.All (s => s.Length > 1), Is.True, "All true"); +Assert.That (set.All (s => s.Length > 2), Is.False, "All false"); +} + +[Test] +public void NSOrderedSet_Count () +{ +using var set = MakeOrderedSet ("a", "b", "c"); +Assert.That (set.Count (), Is.EqualTo (3), "Count"); +Assert.That (set.Count (s => s.ToString () == "a"), Is.EqualTo (1), "Count predicate"); +} + +[Test] +public void NSOrderedSet_LongCount () +{ +using var set = MakeOrderedSet ("a", "b"); +Assert.That (set.LongCount (), Is.EqualTo (2L), "LongCount"); +} + +[Test] +public void NSOrderedSet_Where () +{ +using var set = MakeOrderedSet ("a", "bb", "ccc"); +var result = set.Where (s => s.Length > 1).ToList (); +Assert.That (result.Count, Is.EqualTo (2), "Where count"); +} + +[Test] +public void NSOrderedSet_Where_Index () +{ +using var set = MakeOrderedSet ("a", "b", "c"); +var result = set.Where ((s, i) => i % 2 == 0).ToList (); +Assert.That (result.Count, Is.EqualTo (2), "Where index count"); +} + +[Test] +public void NSOrderedSet_Select () +{ +using var set = MakeOrderedSet ("hello", "world"); +var lengths = set.Select (s => s.Length).ToList (); +Assert.That (lengths [0], Is.EqualTo (5), "Select [0]"); +} + +[Test] +public void NSOrderedSet_Select_Index () +{ +using var set = MakeOrderedSet ("a", "b"); +var indexed = set.Select ((s, i) => $"{i}:{s}").ToList (); +Assert.That (indexed [0], Is.EqualTo ("0:a"), "Select index 0"); +} + +[Test] +public void NSOrderedSet_OrderBy () +{ +using var set = MakeOrderedSet ("banana", "apple", "cherry"); +var sorted = set.OrderBy (s => s.ToString ()).ToList (); +Assert.That (sorted [0].ToString (), Is.EqualTo ("apple"), "OrderBy first"); +} + +[Test] +public void NSOrderedSet_OrderByDescending () +{ +using var set = MakeOrderedSet ("banana", "apple", "cherry"); +var sorted = set.OrderByDescending (s => s.ToString ()).ToList (); +Assert.That (sorted [0].ToString (), Is.EqualTo ("cherry"), "OrderByDesc first"); +} + +[Test] +public void NSOrderedSet_Skip_Take () +{ +using var set = MakeOrderedSet ("a", "b", "c", "d"); +var sliced = set.Skip (1).Take (2).ToList (); +Assert.That (sliced.Count, Is.EqualTo (2), "Skip/Take count"); +Assert.That (sliced [0].ToString (), Is.EqualTo ("b"), "Skip/Take [0]"); +} + +[Test] +public void NSOrderedSet_SkipWhile_TakeWhile () +{ +using var set = MakeOrderedSet ("a", "b", "c"); +var skipped = set.SkipWhile (s => s.ToString () == "a").ToList (); +Assert.That (skipped.Count, Is.EqualTo (2), "SkipWhile count"); +var taken = set.TakeWhile (s => s.ToString () != "c").ToList (); +Assert.That (taken.Count, Is.EqualTo (2), "TakeWhile count"); +} + +[Test] +public void NSOrderedSet_Distinct () +{ +using var set = MakeOrderedSet ("a", "b"); +var distinct = set.Distinct ().ToList (); +Assert.That (distinct.Count, Is.EqualTo (2), "Distinct count"); +} + +[Test] +public void NSOrderedSet_Reverse () +{ +using var set = MakeOrderedSet ("a", "b", "c"); +var reversed = set.Reverse ().ToList (); +Assert.That (reversed [0].ToString (), Is.EqualTo ("c"), "Reverse [0]"); +Assert.That (reversed [2].ToString (), Is.EqualTo ("a"), "Reverse [2]"); +} + +[Test] +public void NSOrderedSet_Concat () +{ +using var set = MakeOrderedSet ("a", "b"); +var all = set.Concat (new [] { S ("c") }).ToList (); +Assert.That (all.Count, Is.EqualTo (3), "Concat count"); +} + +[Test] +public void NSOrderedSet_ToList () +{ +using var set = MakeOrderedSet ("a", "b"); +var list = set.ToList (); +Assert.That (list.Count, Is.EqualTo (2), "ToList count"); +} + +[Test] +public void NSOrderedSet_ToArray () +{ +using var set = MakeOrderedSet ("a", "b"); +var arr = set.ToArray (); +Assert.That (arr.Length, Is.EqualTo (2), "ToArray length"); +} + +[Test] +public void NSOrderedSet_Aggregate () +{ +using var set = MakeOrderedSet ("a", "b", "c"); +var result = set.Aggregate ((acc, s) => (NSString) (acc.ToString () + s.ToString ())); +Assert.That (result.ToString (), Is.EqualTo ("abc"), "Aggregate"); +} + +[Test] +public void NSOrderedSet_Aggregate_Seed () +{ +using var set = MakeOrderedSet ("a", "b", "c"); +var result = set.Aggregate ("", (acc, s) => acc + s.ToString ()); +Assert.That (result, Is.EqualTo ("abc"), "Aggregate seed"); +} + +// ===== NSMutableOrderedSet ===== + +[Test] +public void NSMutableOrderedSet_First () +{ +using var set = MakeMutableOrderedSet ("a", "b", "c"); +Assert.That (set.First ().ToString (), Is.EqualTo ("a"), "First"); +} + +[Test] +public void NSMutableOrderedSet_First_Empty_Throws () +{ +using var set = MakeMutableOrderedSet (); +Assert.Throws (() => set.First ()); +} + +[Test] +public void NSMutableOrderedSet_FirstOrDefault_Empty () +{ +using var set = MakeMutableOrderedSet (); +Assert.That (set.FirstOrDefault (), Is.Null, "FirstOrDefault empty"); +} + +[Test] +public void NSMutableOrderedSet_FirstOrDefault () +{ +using var set = MakeMutableOrderedSet ("x", "y"); +Assert.That (set.FirstOrDefault ()?.ToString (), Is.EqualTo ("x"), "FirstOrDefault"); +} + +[Test] +public void NSMutableOrderedSet_FirstOrDefault_Predicate () +{ +using var set = MakeMutableOrderedSet ("a", "b", "c"); +Assert.That (set.FirstOrDefault (s => s.ToString () == "b")?.ToString (), Is.EqualTo ("b"), "FirstOrDefault predicate match"); +Assert.That (set.FirstOrDefault (s => s.ToString () == "z"), Is.Null, "FirstOrDefault predicate no match"); +} + +[Test] +public void NSMutableOrderedSet_Last () +{ +using var set = MakeMutableOrderedSet ("a", "b", "c"); +Assert.That (set.Last ().ToString (), Is.EqualTo ("c"), "Last"); +} + +[Test] +public void NSMutableOrderedSet_LastOrDefault_Empty () +{ +using var set = MakeMutableOrderedSet (); +Assert.That (set.LastOrDefault (), Is.Null, "LastOrDefault empty"); +} + +[Test] +public void NSMutableOrderedSet_Single () +{ +using var set = MakeMutableOrderedSet ("only"); +Assert.That (set.Single ().ToString (), Is.EqualTo ("only"), "Single"); +} + +[Test] +public void NSMutableOrderedSet_Single_Throws_OnMultiple () +{ +using var set = MakeMutableOrderedSet ("a", "b"); +Assert.Throws (() => set.Single ()); +} + +[Test] +public void NSMutableOrderedSet_SingleOrDefault_Empty () +{ +using var set = MakeMutableOrderedSet (); +Assert.That (set.SingleOrDefault (), Is.Null, "SingleOrDefault empty"); +} + +[Test] +public void NSMutableOrderedSet_ElementAt () +{ +using var set = MakeMutableOrderedSet ("a", "b", "c"); +Assert.That (set.ElementAt (2).ToString (), Is.EqualTo ("c"), "ElementAt 2"); +} + +[Test] +public void NSMutableOrderedSet_ElementAtOrDefault () +{ +using var set = MakeMutableOrderedSet ("a"); +Assert.That (set.ElementAtOrDefault (0)?.ToString (), Is.EqualTo ("a"), "in range"); +Assert.That (set.ElementAtOrDefault (5), Is.Null, "out of range"); +} + +[Test] +public void NSMutableOrderedSet_Any () +{ +using var empty = MakeMutableOrderedSet (); +Assert.That (empty.Any (), Is.False, "Any empty"); +using var set = MakeMutableOrderedSet ("a"); +Assert.That (set.Any (), Is.True, "Any non-empty"); +} + +[Test] +public void NSMutableOrderedSet_All () +{ +using var set = MakeMutableOrderedSet ("ab", "abc"); +Assert.That (set.All (s => s.Length > 1), Is.True, "All true"); +} + +[Test] +public void NSMutableOrderedSet_Count () +{ +using var set = MakeMutableOrderedSet ("a", "b", "c"); +Assert.That (set.Count (), Is.EqualTo (3), "Count"); +Assert.That (set.Count (s => s.ToString () == "a"), Is.EqualTo (1), "Count predicate"); +} + +[Test] +public void NSMutableOrderedSet_LongCount () +{ +using var set = MakeMutableOrderedSet ("a", "b"); +Assert.That (set.LongCount (), Is.EqualTo (2L), "LongCount"); +} + +[Test] +public void NSMutableOrderedSet_Where () +{ +using var set = MakeMutableOrderedSet ("a", "bb", "ccc"); +var result = set.Where (s => s.Length > 1).ToList (); +Assert.That (result.Count, Is.EqualTo (2), "Where count"); +} + +[Test] +public void NSMutableOrderedSet_Select () +{ +using var set = MakeMutableOrderedSet ("hello", "world"); +var lengths = set.Select (s => s.Length).ToList (); +Assert.That (lengths [0], Is.EqualTo (5), "Select [0]"); +} + +[Test] +public void NSMutableOrderedSet_OrderBy () +{ +using var set = MakeMutableOrderedSet ("banana", "apple", "cherry"); +var sorted = set.OrderBy (s => s.ToString ()).ToList (); +Assert.That (sorted [0].ToString (), Is.EqualTo ("apple"), "OrderBy first"); +} + +[Test] +public void NSMutableOrderedSet_OrderByDescending () +{ +using var set = MakeMutableOrderedSet ("banana", "apple", "cherry"); +var sorted = set.OrderByDescending (s => s.ToString ()).ToList (); +Assert.That (sorted [0].ToString (), Is.EqualTo ("cherry"), "OrderByDesc first"); +} + +[Test] +public void NSMutableOrderedSet_Skip_Take () +{ +using var set = MakeMutableOrderedSet ("a", "b", "c", "d"); +var sliced = set.Skip (1).Take (2).ToList (); +Assert.That (sliced.Count, Is.EqualTo (2), "Skip/Take count"); +Assert.That (sliced [0].ToString (), Is.EqualTo ("b"), "Skip/Take [0]"); +} + +[Test] +public void NSMutableOrderedSet_SkipWhile_TakeWhile () +{ +using var set = MakeMutableOrderedSet ("a", "b", "c"); +var skipped = set.SkipWhile (s => s.ToString () == "a").ToList (); +Assert.That (skipped.Count, Is.EqualTo (2), "SkipWhile count"); +var taken = set.TakeWhile (s => s.ToString () != "c").ToList (); +Assert.That (taken.Count, Is.EqualTo (2), "TakeWhile count"); +} + +[Test] +public void NSMutableOrderedSet_Distinct () +{ +using var set = MakeMutableOrderedSet ("a", "b"); +var distinct = set.Distinct ().ToList (); +Assert.That (distinct.Count, Is.EqualTo (2), "Distinct count"); +} + +[Test] +public void NSMutableOrderedSet_Reverse () +{ +using var set = MakeMutableOrderedSet ("a", "b", "c"); +var reversed = set.Reverse ().ToList (); +Assert.That (reversed [0].ToString (), Is.EqualTo ("c"), "Reverse [0]"); +Assert.That (reversed [2].ToString (), Is.EqualTo ("a"), "Reverse [2]"); +} + +[Test] +public void NSMutableOrderedSet_Concat () +{ +using var set = MakeMutableOrderedSet ("a", "b"); +var all = set.Concat (new [] { S ("c") }).ToList (); +Assert.That (all.Count, Is.EqualTo (3), "Concat count"); +} + +[Test] +public void NSMutableOrderedSet_ToList () +{ +using var set = MakeMutableOrderedSet ("a", "b"); +var list = set.ToList (); +Assert.That (list.Count, Is.EqualTo (2), "ToList count"); +} + +[Test] +public void NSMutableOrderedSet_ToArray () +{ +using var set = MakeMutableOrderedSet ("a", "b"); +var arr = set.ToArray (); +Assert.That (arr.Length, Is.EqualTo (2), "ToArray length"); +} + +[Test] +public void NSMutableOrderedSet_Aggregate () +{ +using var set = MakeMutableOrderedSet ("a", "b", "c"); +var result = set.Aggregate ((acc, s) => (NSString) (acc.ToString () + s.ToString ())); +Assert.That (result.ToString (), Is.EqualTo ("abc"), "Aggregate"); +} + +[Test] +public void NSMutableOrderedSet_Aggregate_Seed () +{ +using var set = MakeMutableOrderedSet ("a", "b", "c"); +var result = set.Aggregate ("", (acc, s) => acc + s.ToString ()); +Assert.That (result, Is.EqualTo ("abc"), "Aggregate seed"); +} +} +} From 14c2c6d8b2b805d373c55db8a758d350769442c9 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 27 May 2026 17:30:00 +0200 Subject: [PATCH 5/6] Fix build: use ObjCRuntime.INativeObject in LINQ extension constraints INativeObject is defined in the ObjCRuntime namespace, not Foundation. The generic type constraints on all 228 extension methods were referencing Foundation.INativeObject which doesn't exist, causing CS0234/CS0311 errors. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/Foundation/NSCollectionLinqExtensions.cs | 456 +++++++++---------- 1 file changed, 228 insertions(+), 228 deletions(-) diff --git a/src/Foundation/NSCollectionLinqExtensions.cs b/src/Foundation/NSCollectionLinqExtensions.cs index fa636d2ae0a0..b60d8920dd77 100644 --- a/src/Foundation/NSCollectionLinqExtensions.cs +++ b/src/Foundation/NSCollectionLinqExtensions.cs @@ -11,7 +11,7 @@ public static class NSCollectionLinqExtensions { /// The first element in . /// Thrown when is . /// Thrown when is empty. - public static TKey First (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + public static TKey First (this Foundation.NSSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.First ((IEnumerable) source); @@ -24,7 +24,7 @@ public static TKey First (this Foundation.NSSet source) where TKey : /// The first element in that passes the test in . /// Thrown when or is . /// Thrown when no element satisfies the condition in . - public static TKey First (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey First (this Foundation.NSSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -36,7 +36,7 @@ public static TKey First (this Foundation.NSSet source, FuncThe source collection. /// The first element in , or if the collection is empty. /// Thrown when is . - public static TKey? FirstOrDefault (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + public static TKey? FirstOrDefault (this Foundation.NSSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.FirstOrDefault ((IEnumerable) source); @@ -48,7 +48,7 @@ public static TKey First (this Foundation.NSSet source, FuncA function to test each element for a condition. /// The first element in that passes the test in , or if no such element is found. /// Thrown when or is . - public static TKey? FirstOrDefault (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey? FirstOrDefault (this Foundation.NSSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -61,7 +61,7 @@ public static TKey First (this Foundation.NSSet source, FuncThe last element in . /// Thrown when is . /// Thrown when is empty. - public static TKey Last (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + public static TKey Last (this Foundation.NSSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Last ((IEnumerable) source); @@ -74,7 +74,7 @@ public static TKey Last (this Foundation.NSSet source) where TKey : /// The last element in that passes the test in . /// Thrown when or is . /// Thrown when no element satisfies the condition in . - public static TKey Last (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey Last (this Foundation.NSSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -86,7 +86,7 @@ public static TKey Last (this Foundation.NSSet source, FuncThe source collection. /// The last element in , or if the collection is empty. /// Thrown when is . - public static TKey? LastOrDefault (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + public static TKey? LastOrDefault (this Foundation.NSSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.LastOrDefault ((IEnumerable) source); @@ -98,7 +98,7 @@ public static TKey Last (this Foundation.NSSet source, FuncA function to test each element for a condition. /// The last element in that passes the test in , or if no such element is found. /// Thrown when or is . - public static TKey? LastOrDefault (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey? LastOrDefault (this Foundation.NSSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -111,7 +111,7 @@ public static TKey Last (this Foundation.NSSet source, FuncThe single element of . /// Thrown when is . /// Thrown when is empty or contains more than one element. - public static TKey Single (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + public static TKey Single (this Foundation.NSSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Single ((IEnumerable) source); @@ -124,7 +124,7 @@ public static TKey Single (this Foundation.NSSet source) where TKey /// The single element in that passes the test in . /// Thrown when or is . /// Thrown when no element or more than one element satisfies the condition in . - public static TKey Single (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey Single (this Foundation.NSSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -137,7 +137,7 @@ public static TKey Single (this Foundation.NSSet source, FuncThe single element of , or if the collection is empty. /// Thrown when is . /// Thrown when contains more than one element. - public static TKey? SingleOrDefault (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + public static TKey? SingleOrDefault (this Foundation.NSSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.SingleOrDefault ((IEnumerable) source); @@ -150,7 +150,7 @@ public static TKey Single (this Foundation.NSSet source, FuncThe single element in that passes the test in , or if no such element is found. /// Thrown when or is . /// Thrown when more than one element satisfies the condition in . - public static TKey? SingleOrDefault (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey? SingleOrDefault (this Foundation.NSSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -164,7 +164,7 @@ public static TKey Single (this Foundation.NSSet source, FuncThe element at position in . /// Thrown when is . /// Thrown when is less than 0 or greater than or equal to the number of elements in . - public static TKey ElementAt (this Foundation.NSSet source, int index) where TKey : class, Foundation.INativeObject + public static TKey ElementAt (this Foundation.NSSet source, int index) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ElementAt ((IEnumerable) source, index); @@ -176,7 +176,7 @@ public static TKey ElementAt (this Foundation.NSSet source, int inde /// The zero-based index of the element to retrieve. /// The element at position in , or if the index is out of range. /// Thrown when is . - public static TKey? ElementAtOrDefault (this Foundation.NSSet source, int index) where TKey : class, Foundation.INativeObject + public static TKey? ElementAtOrDefault (this Foundation.NSSet source, int index) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ElementAtOrDefault ((IEnumerable) source, index); @@ -187,7 +187,7 @@ public static TKey ElementAt (this Foundation.NSSet source, int inde /// The source collection. /// if contains any elements; otherwise . /// Thrown when is . - public static bool Any (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + public static bool Any (this Foundation.NSSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Any ((IEnumerable) source); @@ -199,7 +199,7 @@ public static bool Any (this Foundation.NSSet source) where TKey : c /// A function to test each element for a condition. /// if any element in passes the test in ; otherwise . /// Thrown when or is . - public static bool Any (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static bool Any (this Foundation.NSSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -212,7 +212,7 @@ public static bool Any (this Foundation.NSSet source, FuncA function to test each element for a condition. /// if every element in passes the test in , or if the collection is empty; otherwise . /// Thrown when or is . - public static bool All (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static bool All (this Foundation.NSSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -224,7 +224,7 @@ public static bool All (this Foundation.NSSet source, FuncThe source collection. /// The number of elements in . /// Thrown when is . - public static int Count (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + public static int Count (this Foundation.NSSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Count ((IEnumerable) source); @@ -236,7 +236,7 @@ public static int Count (this Foundation.NSSet source) where TKey : /// A function to test each element for a condition. /// The number of elements in that pass the test in . /// Thrown when or is . - public static int Count (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static int Count (this Foundation.NSSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -248,7 +248,7 @@ public static int Count (this Foundation.NSSet source, FuncThe source collection. /// The number of elements in . /// Thrown when is . - public static long LongCount (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + public static long LongCount (this Foundation.NSSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.LongCount ((IEnumerable) source); @@ -260,7 +260,7 @@ public static long LongCount (this Foundation.NSSet source) where TK /// A function to test each element for a condition. /// The number of elements in that pass the test in . /// Thrown when or is . - public static long LongCount (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static long LongCount (this Foundation.NSSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -273,7 +273,7 @@ public static long LongCount (this Foundation.NSSet source, FuncA function to test each element for a condition. /// An that contains elements from that satisfy the condition. /// Thrown when or is . - public static IEnumerable Where (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable Where (this Foundation.NSSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -286,7 +286,7 @@ public static IEnumerable Where (this Foundation.NSSet source, /// A function to test each element; the second parameter represents the zero-based index of the element. /// An that contains elements from that satisfy the condition. /// Thrown when or is . - public static IEnumerable Where (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable Where (this Foundation.NSSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -300,7 +300,7 @@ public static IEnumerable Where (this Foundation.NSSet source, /// A transform function to apply to each element. /// An whose elements are the result of invoking the transform function on each element of . /// Thrown when or is . - public static IEnumerable Select (this Foundation.NSSet source, Func selector) where TKey : class, Foundation.INativeObject + public static IEnumerable Select (this Foundation.NSSet source, Func selector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (selector); @@ -314,7 +314,7 @@ public static IEnumerable Select (this Foundation.NSSet< /// A transform function to apply to each element; the second parameter represents the zero-based index of the element. /// An whose elements are the result of invoking the transform function on each element of . /// Thrown when or is . - public static IEnumerable Select (this Foundation.NSSet source, Func selector) where TKey : class, Foundation.INativeObject + public static IEnumerable Select (this Foundation.NSSet source, Func selector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (selector); @@ -328,7 +328,7 @@ public static IEnumerable Select (this Foundation.NSSet< /// A function to extract a key from an element. /// An whose elements are sorted according to a key. /// Thrown when or is . - public static IOrderedEnumerable OrderBy (this Foundation.NSSet source, Func keySelector) where TKey : class, Foundation.INativeObject + public static IOrderedEnumerable OrderBy (this Foundation.NSSet source, Func keySelector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (keySelector); @@ -342,7 +342,7 @@ public static IOrderedEnumerable OrderBy (this Foundation /// A function to extract a key from an element. /// An whose elements are sorted in descending order according to a key. /// Thrown when or is . - public static IOrderedEnumerable OrderByDescending (this Foundation.NSSet source, Func keySelector) where TKey : class, Foundation.INativeObject + public static IOrderedEnumerable OrderByDescending (this Foundation.NSSet source, Func keySelector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (keySelector); @@ -355,7 +355,7 @@ public static IOrderedEnumerable OrderByDescending (this /// The number of elements to skip before returning the remaining elements. /// An that contains elements after the skipped ones. /// Thrown when is . - public static IEnumerable Skip (this Foundation.NSSet source, int count) where TKey : class, Foundation.INativeObject + public static IEnumerable Skip (this Foundation.NSSet source, int count) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Skip ((IEnumerable) source, count); @@ -367,7 +367,7 @@ public static IEnumerable Skip (this Foundation.NSSet source, /// A function to test each element for a condition. /// An that contains the elements starting at the first element that does not satisfy the condition. /// Thrown when or is . - public static IEnumerable SkipWhile (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable SkipWhile (this Foundation.NSSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -380,7 +380,7 @@ public static IEnumerable SkipWhile (this Foundation.NSSet sou /// The number of elements to return. /// An that contains the specified number of elements from the start of . /// Thrown when is . - public static IEnumerable Take (this Foundation.NSSet source, int count) where TKey : class, Foundation.INativeObject + public static IEnumerable Take (this Foundation.NSSet source, int count) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Take ((IEnumerable) source, count); @@ -392,7 +392,7 @@ public static IEnumerable Take (this Foundation.NSSet source, /// A function to test each element for a condition. /// An that contains elements from as long as the condition is true. /// Thrown when or is . - public static IEnumerable TakeWhile (this Foundation.NSSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable TakeWhile (this Foundation.NSSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -404,7 +404,7 @@ public static IEnumerable TakeWhile (this Foundation.NSSet sou /// The source collection. /// An that contains distinct elements from . /// Thrown when is . - public static IEnumerable Distinct (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + public static IEnumerable Distinct (this Foundation.NSSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Distinct ((IEnumerable) source); @@ -415,7 +415,7 @@ public static IEnumerable Distinct (this Foundation.NSSet sour /// The source collection. /// An whose elements correspond to those of in reverse order. /// Thrown when is . - public static IEnumerable Reverse (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + public static IEnumerable Reverse (this Foundation.NSSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Reverse ((IEnumerable) source); @@ -427,7 +427,7 @@ public static IEnumerable Reverse (this Foundation.NSSet sourc /// The sequence to concatenate to . /// An that contains the concatenated elements of the two sequences. /// Thrown when or is . - public static IEnumerable Concat (this Foundation.NSSet source, IEnumerable second) where TKey : class, Foundation.INativeObject + public static IEnumerable Concat (this Foundation.NSSet source, IEnumerable second) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (second); @@ -439,7 +439,7 @@ public static IEnumerable Concat (this Foundation.NSSet source /// The source collection. /// A that contains elements from . /// Thrown when is . - public static List ToList (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + public static List ToList (this Foundation.NSSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ToList ((IEnumerable) source); @@ -450,7 +450,7 @@ public static List ToList (this Foundation.NSSet source) where /// The source collection. /// An array that contains elements from . /// Thrown when is . - public static TKey [] ToArray (this Foundation.NSSet source) where TKey : class, Foundation.INativeObject + public static TKey [] ToArray (this Foundation.NSSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ToArray ((IEnumerable) source); @@ -463,7 +463,7 @@ public static TKey [] ToArray (this Foundation.NSSet source) where T /// The final accumulator value. /// Thrown when or is . /// Thrown when is empty. - public static TKey Aggregate (this Foundation.NSSet source, Func func) where TKey : class, Foundation.INativeObject + public static TKey Aggregate (this Foundation.NSSet source, Func func) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (func); @@ -478,7 +478,7 @@ public static TKey Aggregate (this Foundation.NSSet source, FuncAn accumulator function to be invoked on each element. /// The final accumulator value. /// Thrown when or is . - public static TAccumulate Aggregate (this Foundation.NSSet source, TAccumulate seed, Func func) where TKey : class, Foundation.INativeObject + public static TAccumulate Aggregate (this Foundation.NSSet source, TAccumulate seed, Func func) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (func); @@ -492,7 +492,7 @@ public static TAccumulate Aggregate (this Foundation.NSSetThe first element in . /// Thrown when is . /// Thrown when is empty. - public static TKey First (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + public static TKey First (this Foundation.NSMutableSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.First ((IEnumerable) source); @@ -505,7 +505,7 @@ public static TKey First (this Foundation.NSMutableSet source) where /// The first element in that passes the test in . /// Thrown when or is . /// Thrown when no element satisfies the condition in . - public static TKey First (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey First (this Foundation.NSMutableSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -517,7 +517,7 @@ public static TKey First (this Foundation.NSMutableSet source, Func< /// The source collection. /// The first element in , or if the collection is empty. /// Thrown when is . - public static TKey? FirstOrDefault (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + public static TKey? FirstOrDefault (this Foundation.NSMutableSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.FirstOrDefault ((IEnumerable) source); @@ -529,7 +529,7 @@ public static TKey First (this Foundation.NSMutableSet source, Func< /// A function to test each element for a condition. /// The first element in that passes the test in , or if no such element is found. /// Thrown when or is . - public static TKey? FirstOrDefault (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey? FirstOrDefault (this Foundation.NSMutableSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -542,7 +542,7 @@ public static TKey First (this Foundation.NSMutableSet source, Func< /// The last element in . /// Thrown when is . /// Thrown when is empty. - public static TKey Last (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + public static TKey Last (this Foundation.NSMutableSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Last ((IEnumerable) source); @@ -555,7 +555,7 @@ public static TKey Last (this Foundation.NSMutableSet source) where /// The last element in that passes the test in . /// Thrown when or is . /// Thrown when no element satisfies the condition in . - public static TKey Last (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey Last (this Foundation.NSMutableSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -567,7 +567,7 @@ public static TKey Last (this Foundation.NSMutableSet source, FuncThe source collection. /// The last element in , or if the collection is empty. /// Thrown when is . - public static TKey? LastOrDefault (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + public static TKey? LastOrDefault (this Foundation.NSMutableSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.LastOrDefault ((IEnumerable) source); @@ -579,7 +579,7 @@ public static TKey Last (this Foundation.NSMutableSet source, FuncA function to test each element for a condition. /// The last element in that passes the test in , or if no such element is found. /// Thrown when or is . - public static TKey? LastOrDefault (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey? LastOrDefault (this Foundation.NSMutableSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -592,7 +592,7 @@ public static TKey Last (this Foundation.NSMutableSet source, FuncThe single element of . /// Thrown when is . /// Thrown when is empty or contains more than one element. - public static TKey Single (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + public static TKey Single (this Foundation.NSMutableSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Single ((IEnumerable) source); @@ -605,7 +605,7 @@ public static TKey Single (this Foundation.NSMutableSet source) wher /// The single element in that passes the test in . /// Thrown when or is . /// Thrown when no element or more than one element satisfies the condition in . - public static TKey Single (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey Single (this Foundation.NSMutableSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -618,7 +618,7 @@ public static TKey Single (this Foundation.NSMutableSet source, Func /// The single element of , or if the collection is empty. /// Thrown when is . /// Thrown when contains more than one element. - public static TKey? SingleOrDefault (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + public static TKey? SingleOrDefault (this Foundation.NSMutableSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.SingleOrDefault ((IEnumerable) source); @@ -631,7 +631,7 @@ public static TKey Single (this Foundation.NSMutableSet source, Func /// The single element in that passes the test in , or if no such element is found. /// Thrown when or is . /// Thrown when more than one element satisfies the condition in . - public static TKey? SingleOrDefault (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey? SingleOrDefault (this Foundation.NSMutableSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -645,7 +645,7 @@ public static TKey Single (this Foundation.NSMutableSet source, Func /// The element at position in . /// Thrown when is . /// Thrown when is less than 0 or greater than or equal to the number of elements in . - public static TKey ElementAt (this Foundation.NSMutableSet source, int index) where TKey : class, Foundation.INativeObject + public static TKey ElementAt (this Foundation.NSMutableSet source, int index) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ElementAt ((IEnumerable) source, index); @@ -657,7 +657,7 @@ public static TKey ElementAt (this Foundation.NSMutableSet source, i /// The zero-based index of the element to retrieve. /// The element at position in , or if the index is out of range. /// Thrown when is . - public static TKey? ElementAtOrDefault (this Foundation.NSMutableSet source, int index) where TKey : class, Foundation.INativeObject + public static TKey? ElementAtOrDefault (this Foundation.NSMutableSet source, int index) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ElementAtOrDefault ((IEnumerable) source, index); @@ -668,7 +668,7 @@ public static TKey ElementAt (this Foundation.NSMutableSet source, i /// The source collection. /// if contains any elements; otherwise . /// Thrown when is . - public static bool Any (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + public static bool Any (this Foundation.NSMutableSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Any ((IEnumerable) source); @@ -680,7 +680,7 @@ public static bool Any (this Foundation.NSMutableSet source) where T /// A function to test each element for a condition. /// if any element in passes the test in ; otherwise . /// Thrown when or is . - public static bool Any (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static bool Any (this Foundation.NSMutableSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -693,7 +693,7 @@ public static bool Any (this Foundation.NSMutableSet source, FuncA function to test each element for a condition. /// if every element in passes the test in , or if the collection is empty; otherwise . /// Thrown when or is . - public static bool All (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static bool All (this Foundation.NSMutableSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -705,7 +705,7 @@ public static bool All (this Foundation.NSMutableSet source, FuncThe source collection. /// The number of elements in . /// Thrown when is . - public static int Count (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + public static int Count (this Foundation.NSMutableSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Count ((IEnumerable) source); @@ -717,7 +717,7 @@ public static int Count (this Foundation.NSMutableSet source) where /// A function to test each element for a condition. /// The number of elements in that pass the test in . /// Thrown when or is . - public static int Count (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static int Count (this Foundation.NSMutableSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -729,7 +729,7 @@ public static int Count (this Foundation.NSMutableSet source, FuncThe source collection. /// The number of elements in . /// Thrown when is . - public static long LongCount (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + public static long LongCount (this Foundation.NSMutableSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.LongCount ((IEnumerable) source); @@ -741,7 +741,7 @@ public static long LongCount (this Foundation.NSMutableSet source) w /// A function to test each element for a condition. /// The number of elements in that pass the test in . /// Thrown when or is . - public static long LongCount (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static long LongCount (this Foundation.NSMutableSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -754,7 +754,7 @@ public static long LongCount (this Foundation.NSMutableSet source, F /// A function to test each element for a condition. /// An that contains elements from that satisfy the condition. /// Thrown when or is . - public static IEnumerable Where (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable Where (this Foundation.NSMutableSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -767,7 +767,7 @@ public static IEnumerable Where (this Foundation.NSMutableSet /// A function to test each element; the second parameter represents the zero-based index of the element. /// An that contains elements from that satisfy the condition. /// Thrown when or is . - public static IEnumerable Where (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable Where (this Foundation.NSMutableSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -781,7 +781,7 @@ public static IEnumerable Where (this Foundation.NSMutableSet /// A transform function to apply to each element. /// An whose elements are the result of invoking the transform function on each element of . /// Thrown when or is . - public static IEnumerable Select (this Foundation.NSMutableSet source, Func selector) where TKey : class, Foundation.INativeObject + public static IEnumerable Select (this Foundation.NSMutableSet source, Func selector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (selector); @@ -795,7 +795,7 @@ public static IEnumerable Select (this Foundation.NSMuta /// A transform function to apply to each element; the second parameter represents the zero-based index of the element. /// An whose elements are the result of invoking the transform function on each element of . /// Thrown when or is . - public static IEnumerable Select (this Foundation.NSMutableSet source, Func selector) where TKey : class, Foundation.INativeObject + public static IEnumerable Select (this Foundation.NSMutableSet source, Func selector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (selector); @@ -809,7 +809,7 @@ public static IEnumerable Select (this Foundation.NSMuta /// A function to extract a key from an element. /// An whose elements are sorted according to a key. /// Thrown when or is . - public static IOrderedEnumerable OrderBy (this Foundation.NSMutableSet source, Func keySelector) where TKey : class, Foundation.INativeObject + public static IOrderedEnumerable OrderBy (this Foundation.NSMutableSet source, Func keySelector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (keySelector); @@ -823,7 +823,7 @@ public static IOrderedEnumerable OrderBy (this Foundation /// A function to extract a key from an element. /// An whose elements are sorted in descending order according to a key. /// Thrown when or is . - public static IOrderedEnumerable OrderByDescending (this Foundation.NSMutableSet source, Func keySelector) where TKey : class, Foundation.INativeObject + public static IOrderedEnumerable OrderByDescending (this Foundation.NSMutableSet source, Func keySelector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (keySelector); @@ -836,7 +836,7 @@ public static IOrderedEnumerable OrderByDescending (this /// The number of elements to skip before returning the remaining elements. /// An that contains elements after the skipped ones. /// Thrown when is . - public static IEnumerable Skip (this Foundation.NSMutableSet source, int count) where TKey : class, Foundation.INativeObject + public static IEnumerable Skip (this Foundation.NSMutableSet source, int count) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Skip ((IEnumerable) source, count); @@ -848,7 +848,7 @@ public static IEnumerable Skip (this Foundation.NSMutableSet s /// A function to test each element for a condition. /// An that contains the elements starting at the first element that does not satisfy the condition. /// Thrown when or is . - public static IEnumerable SkipWhile (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable SkipWhile (this Foundation.NSMutableSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -861,7 +861,7 @@ public static IEnumerable SkipWhile (this Foundation.NSMutableSetThe number of elements to return. /// An that contains the specified number of elements from the start of . /// Thrown when is . - public static IEnumerable Take (this Foundation.NSMutableSet source, int count) where TKey : class, Foundation.INativeObject + public static IEnumerable Take (this Foundation.NSMutableSet source, int count) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Take ((IEnumerable) source, count); @@ -873,7 +873,7 @@ public static IEnumerable Take (this Foundation.NSMutableSet s /// A function to test each element for a condition. /// An that contains elements from as long as the condition is true. /// Thrown when or is . - public static IEnumerable TakeWhile (this Foundation.NSMutableSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable TakeWhile (this Foundation.NSMutableSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -885,7 +885,7 @@ public static IEnumerable TakeWhile (this Foundation.NSMutableSetThe source collection. /// An that contains distinct elements from . /// Thrown when is . - public static IEnumerable Distinct (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + public static IEnumerable Distinct (this Foundation.NSMutableSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Distinct ((IEnumerable) source); @@ -896,7 +896,7 @@ public static IEnumerable Distinct (this Foundation.NSMutableSetThe source collection. /// An whose elements correspond to those of in reverse order. /// Thrown when is . - public static IEnumerable Reverse (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + public static IEnumerable Reverse (this Foundation.NSMutableSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Reverse ((IEnumerable) source); @@ -908,7 +908,7 @@ public static IEnumerable Reverse (this Foundation.NSMutableSetThe sequence to concatenate to . /// An that contains the concatenated elements of the two sequences. /// Thrown when or is . - public static IEnumerable Concat (this Foundation.NSMutableSet source, IEnumerable second) where TKey : class, Foundation.INativeObject + public static IEnumerable Concat (this Foundation.NSMutableSet source, IEnumerable second) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (second); @@ -920,7 +920,7 @@ public static IEnumerable Concat (this Foundation.NSMutableSet /// The source collection. /// A that contains elements from . /// Thrown when is . - public static List ToList (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + public static List ToList (this Foundation.NSMutableSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ToList ((IEnumerable) source); @@ -931,7 +931,7 @@ public static List ToList (this Foundation.NSMutableSet source /// The source collection. /// An array that contains elements from . /// Thrown when is . - public static TKey [] ToArray (this Foundation.NSMutableSet source) where TKey : class, Foundation.INativeObject + public static TKey [] ToArray (this Foundation.NSMutableSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ToArray ((IEnumerable) source); @@ -944,7 +944,7 @@ public static TKey [] ToArray (this Foundation.NSMutableSet source) /// The final accumulator value. /// Thrown when or is . /// Thrown when is empty. - public static TKey Aggregate (this Foundation.NSMutableSet source, Func func) where TKey : class, Foundation.INativeObject + public static TKey Aggregate (this Foundation.NSMutableSet source, Func func) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (func); @@ -959,7 +959,7 @@ public static TKey Aggregate (this Foundation.NSMutableSet source, F /// An accumulator function to be invoked on each element. /// The final accumulator value. /// Thrown when or is . - public static TAccumulate Aggregate (this Foundation.NSMutableSet source, TAccumulate seed, Func func) where TKey : class, Foundation.INativeObject + public static TAccumulate Aggregate (this Foundation.NSMutableSet source, TAccumulate seed, Func func) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (func); @@ -973,7 +973,7 @@ public static TAccumulate Aggregate (this Foundation.NSMutabl /// The first element in . /// Thrown when is . /// Thrown when is empty. - public static TKey First (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + public static TKey First (this Foundation.NSArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.First ((IEnumerable) source); @@ -986,7 +986,7 @@ public static TKey First (this Foundation.NSArray source) where TKey /// The first element in that passes the test in . /// Thrown when or is . /// Thrown when no element satisfies the condition in . - public static TKey First (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey First (this Foundation.NSArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -998,7 +998,7 @@ public static TKey First (this Foundation.NSArray source, FuncThe source collection. /// The first element in , or if the collection is empty. /// Thrown when is . - public static TKey? FirstOrDefault (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + public static TKey? FirstOrDefault (this Foundation.NSArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.FirstOrDefault ((IEnumerable) source); @@ -1010,7 +1010,7 @@ public static TKey First (this Foundation.NSArray source, FuncA function to test each element for a condition. /// The first element in that passes the test in , or if no such element is found. /// Thrown when or is . - public static TKey? FirstOrDefault (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey? FirstOrDefault (this Foundation.NSArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1023,7 +1023,7 @@ public static TKey First (this Foundation.NSArray source, FuncThe last element in . /// Thrown when is . /// Thrown when is empty. - public static TKey Last (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + public static TKey Last (this Foundation.NSArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Last ((IEnumerable) source); @@ -1036,7 +1036,7 @@ public static TKey Last (this Foundation.NSArray source) where TKey /// The last element in that passes the test in . /// Thrown when or is . /// Thrown when no element satisfies the condition in . - public static TKey Last (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey Last (this Foundation.NSArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1048,7 +1048,7 @@ public static TKey Last (this Foundation.NSArray source, FuncThe source collection. /// The last element in , or if the collection is empty. /// Thrown when is . - public static TKey? LastOrDefault (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + public static TKey? LastOrDefault (this Foundation.NSArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.LastOrDefault ((IEnumerable) source); @@ -1060,7 +1060,7 @@ public static TKey Last (this Foundation.NSArray source, FuncA function to test each element for a condition. /// The last element in that passes the test in , or if no such element is found. /// Thrown when or is . - public static TKey? LastOrDefault (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey? LastOrDefault (this Foundation.NSArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1073,7 +1073,7 @@ public static TKey Last (this Foundation.NSArray source, FuncThe single element of . /// Thrown when is . /// Thrown when is empty or contains more than one element. - public static TKey Single (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + public static TKey Single (this Foundation.NSArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Single ((IEnumerable) source); @@ -1086,7 +1086,7 @@ public static TKey Single (this Foundation.NSArray source) where TKe /// The single element in that passes the test in . /// Thrown when or is . /// Thrown when no element or more than one element satisfies the condition in . - public static TKey Single (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey Single (this Foundation.NSArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1099,7 +1099,7 @@ public static TKey Single (this Foundation.NSArray source, FuncThe single element of , or if the collection is empty. /// Thrown when is . /// Thrown when contains more than one element. - public static TKey? SingleOrDefault (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + public static TKey? SingleOrDefault (this Foundation.NSArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.SingleOrDefault ((IEnumerable) source); @@ -1112,7 +1112,7 @@ public static TKey Single (this Foundation.NSArray source, FuncThe single element in that passes the test in , or if no such element is found. /// Thrown when or is . /// Thrown when more than one element satisfies the condition in . - public static TKey? SingleOrDefault (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey? SingleOrDefault (this Foundation.NSArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1126,7 +1126,7 @@ public static TKey Single (this Foundation.NSArray source, FuncThe element at position in . /// Thrown when is . /// Thrown when is less than 0 or greater than or equal to the number of elements in . - public static TKey ElementAt (this Foundation.NSArray source, int index) where TKey : class, Foundation.INativeObject + public static TKey ElementAt (this Foundation.NSArray source, int index) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ElementAt ((IEnumerable) source, index); @@ -1138,7 +1138,7 @@ public static TKey ElementAt (this Foundation.NSArray source, int in /// The zero-based index of the element to retrieve. /// The element at position in , or if the index is out of range. /// Thrown when is . - public static TKey? ElementAtOrDefault (this Foundation.NSArray source, int index) where TKey : class, Foundation.INativeObject + public static TKey? ElementAtOrDefault (this Foundation.NSArray source, int index) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ElementAtOrDefault ((IEnumerable) source, index); @@ -1149,7 +1149,7 @@ public static TKey ElementAt (this Foundation.NSArray source, int in /// The source collection. /// if contains any elements; otherwise . /// Thrown when is . - public static bool Any (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + public static bool Any (this Foundation.NSArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Any ((IEnumerable) source); @@ -1161,7 +1161,7 @@ public static bool Any (this Foundation.NSArray source) where TKey : /// A function to test each element for a condition. /// if any element in passes the test in ; otherwise . /// Thrown when or is . - public static bool Any (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static bool Any (this Foundation.NSArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1174,7 +1174,7 @@ public static bool Any (this Foundation.NSArray source, FuncA function to test each element for a condition. /// if every element in passes the test in , or if the collection is empty; otherwise . /// Thrown when or is . - public static bool All (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static bool All (this Foundation.NSArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1186,7 +1186,7 @@ public static bool All (this Foundation.NSArray source, FuncThe source collection. /// The number of elements in . /// Thrown when is . - public static int Count (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + public static int Count (this Foundation.NSArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Count ((IEnumerable) source); @@ -1198,7 +1198,7 @@ public static int Count (this Foundation.NSArray source) where TKey /// A function to test each element for a condition. /// The number of elements in that pass the test in . /// Thrown when or is . - public static int Count (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static int Count (this Foundation.NSArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1210,7 +1210,7 @@ public static int Count (this Foundation.NSArray source, FuncThe source collection. /// The number of elements in . /// Thrown when is . - public static long LongCount (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + public static long LongCount (this Foundation.NSArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.LongCount ((IEnumerable) source); @@ -1222,7 +1222,7 @@ public static long LongCount (this Foundation.NSArray source) where /// A function to test each element for a condition. /// The number of elements in that pass the test in . /// Thrown when or is . - public static long LongCount (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static long LongCount (this Foundation.NSArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1235,7 +1235,7 @@ public static long LongCount (this Foundation.NSArray source, FuncA function to test each element for a condition. /// An that contains elements from that satisfy the condition. /// Thrown when or is . - public static IEnumerable Where (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable Where (this Foundation.NSArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1248,7 +1248,7 @@ public static IEnumerable Where (this Foundation.NSArray sourc /// A function to test each element; the second parameter represents the zero-based index of the element. /// An that contains elements from that satisfy the condition. /// Thrown when or is . - public static IEnumerable Where (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable Where (this Foundation.NSArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1262,7 +1262,7 @@ public static IEnumerable Where (this Foundation.NSArray sourc /// A transform function to apply to each element. /// An whose elements are the result of invoking the transform function on each element of . /// Thrown when or is . - public static IEnumerable Select (this Foundation.NSArray source, Func selector) where TKey : class, Foundation.INativeObject + public static IEnumerable Select (this Foundation.NSArray source, Func selector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (selector); @@ -1276,7 +1276,7 @@ public static IEnumerable Select (this Foundation.NSArra /// A transform function to apply to each element; the second parameter represents the zero-based index of the element. /// An whose elements are the result of invoking the transform function on each element of . /// Thrown when or is . - public static IEnumerable Select (this Foundation.NSArray source, Func selector) where TKey : class, Foundation.INativeObject + public static IEnumerable Select (this Foundation.NSArray source, Func selector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (selector); @@ -1290,7 +1290,7 @@ public static IEnumerable Select (this Foundation.NSArra /// A function to extract a key from an element. /// An whose elements are sorted according to a key. /// Thrown when or is . - public static IOrderedEnumerable OrderBy (this Foundation.NSArray source, Func keySelector) where TKey : class, Foundation.INativeObject + public static IOrderedEnumerable OrderBy (this Foundation.NSArray source, Func keySelector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (keySelector); @@ -1304,7 +1304,7 @@ public static IOrderedEnumerable OrderBy (this Foundation /// A function to extract a key from an element. /// An whose elements are sorted in descending order according to a key. /// Thrown when or is . - public static IOrderedEnumerable OrderByDescending (this Foundation.NSArray source, Func keySelector) where TKey : class, Foundation.INativeObject + public static IOrderedEnumerable OrderByDescending (this Foundation.NSArray source, Func keySelector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (keySelector); @@ -1317,7 +1317,7 @@ public static IOrderedEnumerable OrderByDescending (this /// The number of elements to skip before returning the remaining elements. /// An that contains elements after the skipped ones. /// Thrown when is . - public static IEnumerable Skip (this Foundation.NSArray source, int count) where TKey : class, Foundation.INativeObject + public static IEnumerable Skip (this Foundation.NSArray source, int count) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Skip ((IEnumerable) source, count); @@ -1329,7 +1329,7 @@ public static IEnumerable Skip (this Foundation.NSArray source /// A function to test each element for a condition. /// An that contains the elements starting at the first element that does not satisfy the condition. /// Thrown when or is . - public static IEnumerable SkipWhile (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable SkipWhile (this Foundation.NSArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1342,7 +1342,7 @@ public static IEnumerable SkipWhile (this Foundation.NSArray s /// The number of elements to return. /// An that contains the specified number of elements from the start of . /// Thrown when is . - public static IEnumerable Take (this Foundation.NSArray source, int count) where TKey : class, Foundation.INativeObject + public static IEnumerable Take (this Foundation.NSArray source, int count) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Take ((IEnumerable) source, count); @@ -1354,7 +1354,7 @@ public static IEnumerable Take (this Foundation.NSArray source /// A function to test each element for a condition. /// An that contains elements from as long as the condition is true. /// Thrown when or is . - public static IEnumerable TakeWhile (this Foundation.NSArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable TakeWhile (this Foundation.NSArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1366,7 +1366,7 @@ public static IEnumerable TakeWhile (this Foundation.NSArray s /// The source collection. /// An that contains distinct elements from . /// Thrown when is . - public static IEnumerable Distinct (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + public static IEnumerable Distinct (this Foundation.NSArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Distinct ((IEnumerable) source); @@ -1377,7 +1377,7 @@ public static IEnumerable Distinct (this Foundation.NSArray so /// The source collection. /// An whose elements correspond to those of in reverse order. /// Thrown when is . - public static IEnumerable Reverse (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + public static IEnumerable Reverse (this Foundation.NSArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Reverse ((IEnumerable) source); @@ -1389,7 +1389,7 @@ public static IEnumerable Reverse (this Foundation.NSArray sou /// The sequence to concatenate to . /// An that contains the concatenated elements of the two sequences. /// Thrown when or is . - public static IEnumerable Concat (this Foundation.NSArray source, IEnumerable second) where TKey : class, Foundation.INativeObject + public static IEnumerable Concat (this Foundation.NSArray source, IEnumerable second) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (second); @@ -1401,7 +1401,7 @@ public static IEnumerable Concat (this Foundation.NSArray sour /// The source collection. /// A that contains elements from . /// Thrown when is . - public static List ToList (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + public static List ToList (this Foundation.NSArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ToList ((IEnumerable) source); @@ -1412,7 +1412,7 @@ public static List ToList (this Foundation.NSArray source) whe /// The source collection. /// An array that contains elements from . /// Thrown when is . - public static TKey [] ToArray (this Foundation.NSArray source) where TKey : class, Foundation.INativeObject + public static TKey [] ToArray (this Foundation.NSArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ToArray ((IEnumerable) source); @@ -1425,7 +1425,7 @@ public static TKey [] ToArray (this Foundation.NSArray source) where /// The final accumulator value. /// Thrown when or is . /// Thrown when is empty. - public static TKey Aggregate (this Foundation.NSArray source, Func func) where TKey : class, Foundation.INativeObject + public static TKey Aggregate (this Foundation.NSArray source, Func func) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (func); @@ -1440,7 +1440,7 @@ public static TKey Aggregate (this Foundation.NSArray source, FuncAn accumulator function to be invoked on each element. /// The final accumulator value. /// Thrown when or is . - public static TAccumulate Aggregate (this Foundation.NSArray source, TAccumulate seed, Func func) where TKey : class, Foundation.INativeObject + public static TAccumulate Aggregate (this Foundation.NSArray source, TAccumulate seed, Func func) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (func); @@ -1454,7 +1454,7 @@ public static TAccumulate Aggregate (this Foundation.NSArray< /// The first element in . /// Thrown when is . /// Thrown when is empty. - public static TKey First (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + public static TKey First (this Foundation.NSMutableArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.First ((IEnumerable) source); @@ -1467,7 +1467,7 @@ public static TKey First (this Foundation.NSMutableArray source) whe /// The first element in that passes the test in . /// Thrown when or is . /// Thrown when no element satisfies the condition in . - public static TKey First (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey First (this Foundation.NSMutableArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1479,7 +1479,7 @@ public static TKey First (this Foundation.NSMutableArray source, Fun /// The source collection. /// The first element in , or if the collection is empty. /// Thrown when is . - public static TKey? FirstOrDefault (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + public static TKey? FirstOrDefault (this Foundation.NSMutableArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.FirstOrDefault ((IEnumerable) source); @@ -1491,7 +1491,7 @@ public static TKey First (this Foundation.NSMutableArray source, Fun /// A function to test each element for a condition. /// The first element in that passes the test in , or if no such element is found. /// Thrown when or is . - public static TKey? FirstOrDefault (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey? FirstOrDefault (this Foundation.NSMutableArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1504,7 +1504,7 @@ public static TKey First (this Foundation.NSMutableArray source, Fun /// The last element in . /// Thrown when is . /// Thrown when is empty. - public static TKey Last (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + public static TKey Last (this Foundation.NSMutableArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Last ((IEnumerable) source); @@ -1517,7 +1517,7 @@ public static TKey Last (this Foundation.NSMutableArray source) wher /// The last element in that passes the test in . /// Thrown when or is . /// Thrown when no element satisfies the condition in . - public static TKey Last (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey Last (this Foundation.NSMutableArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1529,7 +1529,7 @@ public static TKey Last (this Foundation.NSMutableArray source, Func /// The source collection. /// The last element in , or if the collection is empty. /// Thrown when is . - public static TKey? LastOrDefault (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + public static TKey? LastOrDefault (this Foundation.NSMutableArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.LastOrDefault ((IEnumerable) source); @@ -1541,7 +1541,7 @@ public static TKey Last (this Foundation.NSMutableArray source, Func /// A function to test each element for a condition. /// The last element in that passes the test in , or if no such element is found. /// Thrown when or is . - public static TKey? LastOrDefault (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey? LastOrDefault (this Foundation.NSMutableArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1554,7 +1554,7 @@ public static TKey Last (this Foundation.NSMutableArray source, Func /// The single element of . /// Thrown when is . /// Thrown when is empty or contains more than one element. - public static TKey Single (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + public static TKey Single (this Foundation.NSMutableArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Single ((IEnumerable) source); @@ -1567,7 +1567,7 @@ public static TKey Single (this Foundation.NSMutableArray source) wh /// The single element in that passes the test in . /// Thrown when or is . /// Thrown when no element or more than one element satisfies the condition in . - public static TKey Single (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey Single (this Foundation.NSMutableArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1580,7 +1580,7 @@ public static TKey Single (this Foundation.NSMutableArray source, Fu /// The single element of , or if the collection is empty. /// Thrown when is . /// Thrown when contains more than one element. - public static TKey? SingleOrDefault (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + public static TKey? SingleOrDefault (this Foundation.NSMutableArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.SingleOrDefault ((IEnumerable) source); @@ -1593,7 +1593,7 @@ public static TKey Single (this Foundation.NSMutableArray source, Fu /// The single element in that passes the test in , or if no such element is found. /// Thrown when or is . /// Thrown when more than one element satisfies the condition in . - public static TKey? SingleOrDefault (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey? SingleOrDefault (this Foundation.NSMutableArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1607,7 +1607,7 @@ public static TKey Single (this Foundation.NSMutableArray source, Fu /// The element at position in . /// Thrown when is . /// Thrown when is less than 0 or greater than or equal to the number of elements in . - public static TKey ElementAt (this Foundation.NSMutableArray source, int index) where TKey : class, Foundation.INativeObject + public static TKey ElementAt (this Foundation.NSMutableArray source, int index) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ElementAt ((IEnumerable) source, index); @@ -1619,7 +1619,7 @@ public static TKey ElementAt (this Foundation.NSMutableArray source, /// The zero-based index of the element to retrieve. /// The element at position in , or if the index is out of range. /// Thrown when is . - public static TKey? ElementAtOrDefault (this Foundation.NSMutableArray source, int index) where TKey : class, Foundation.INativeObject + public static TKey? ElementAtOrDefault (this Foundation.NSMutableArray source, int index) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ElementAtOrDefault ((IEnumerable) source, index); @@ -1630,7 +1630,7 @@ public static TKey ElementAt (this Foundation.NSMutableArray source, /// The source collection. /// if contains any elements; otherwise . /// Thrown when is . - public static bool Any (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + public static bool Any (this Foundation.NSMutableArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Any ((IEnumerable) source); @@ -1642,7 +1642,7 @@ public static bool Any (this Foundation.NSMutableArray source) where /// A function to test each element for a condition. /// if any element in passes the test in ; otherwise . /// Thrown when or is . - public static bool Any (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static bool Any (this Foundation.NSMutableArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1655,7 +1655,7 @@ public static bool Any (this Foundation.NSMutableArray source, Func< /// A function to test each element for a condition. /// if every element in passes the test in , or if the collection is empty; otherwise . /// Thrown when or is . - public static bool All (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static bool All (this Foundation.NSMutableArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1667,7 +1667,7 @@ public static bool All (this Foundation.NSMutableArray source, Func< /// The source collection. /// The number of elements in . /// Thrown when is . - public static int Count (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + public static int Count (this Foundation.NSMutableArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Count ((IEnumerable) source); @@ -1679,7 +1679,7 @@ public static int Count (this Foundation.NSMutableArray source) wher /// A function to test each element for a condition. /// The number of elements in that pass the test in . /// Thrown when or is . - public static int Count (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static int Count (this Foundation.NSMutableArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1691,7 +1691,7 @@ public static int Count (this Foundation.NSMutableArray source, Func /// The source collection. /// The number of elements in . /// Thrown when is . - public static long LongCount (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + public static long LongCount (this Foundation.NSMutableArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.LongCount ((IEnumerable) source); @@ -1703,7 +1703,7 @@ public static long LongCount (this Foundation.NSMutableArray source) /// A function to test each element for a condition. /// The number of elements in that pass the test in . /// Thrown when or is . - public static long LongCount (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static long LongCount (this Foundation.NSMutableArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1716,7 +1716,7 @@ public static long LongCount (this Foundation.NSMutableArray source, /// A function to test each element for a condition. /// An that contains elements from that satisfy the condition. /// Thrown when or is . - public static IEnumerable Where (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable Where (this Foundation.NSMutableArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1729,7 +1729,7 @@ public static IEnumerable Where (this Foundation.NSMutableArrayA function to test each element; the second parameter represents the zero-based index of the element. /// An that contains elements from that satisfy the condition. /// Thrown when or is . - public static IEnumerable Where (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable Where (this Foundation.NSMutableArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1743,7 +1743,7 @@ public static IEnumerable Where (this Foundation.NSMutableArrayA transform function to apply to each element. /// An whose elements are the result of invoking the transform function on each element of . /// Thrown when or is . - public static IEnumerable Select (this Foundation.NSMutableArray source, Func selector) where TKey : class, Foundation.INativeObject + public static IEnumerable Select (this Foundation.NSMutableArray source, Func selector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (selector); @@ -1757,7 +1757,7 @@ public static IEnumerable Select (this Foundation.NSMuta /// A transform function to apply to each element; the second parameter represents the zero-based index of the element. /// An whose elements are the result of invoking the transform function on each element of . /// Thrown when or is . - public static IEnumerable Select (this Foundation.NSMutableArray source, Func selector) where TKey : class, Foundation.INativeObject + public static IEnumerable Select (this Foundation.NSMutableArray source, Func selector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (selector); @@ -1771,7 +1771,7 @@ public static IEnumerable Select (this Foundation.NSMuta /// A function to extract a key from an element. /// An whose elements are sorted according to a key. /// Thrown when or is . - public static IOrderedEnumerable OrderBy (this Foundation.NSMutableArray source, Func keySelector) where TKey : class, Foundation.INativeObject + public static IOrderedEnumerable OrderBy (this Foundation.NSMutableArray source, Func keySelector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (keySelector); @@ -1785,7 +1785,7 @@ public static IOrderedEnumerable OrderBy (this Foundation /// A function to extract a key from an element. /// An whose elements are sorted in descending order according to a key. /// Thrown when or is . - public static IOrderedEnumerable OrderByDescending (this Foundation.NSMutableArray source, Func keySelector) where TKey : class, Foundation.INativeObject + public static IOrderedEnumerable OrderByDescending (this Foundation.NSMutableArray source, Func keySelector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (keySelector); @@ -1798,7 +1798,7 @@ public static IOrderedEnumerable OrderByDescending (this /// The number of elements to skip before returning the remaining elements. /// An that contains elements after the skipped ones. /// Thrown when is . - public static IEnumerable Skip (this Foundation.NSMutableArray source, int count) where TKey : class, Foundation.INativeObject + public static IEnumerable Skip (this Foundation.NSMutableArray source, int count) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Skip ((IEnumerable) source, count); @@ -1810,7 +1810,7 @@ public static IEnumerable Skip (this Foundation.NSMutableArray /// A function to test each element for a condition. /// An that contains the elements starting at the first element that does not satisfy the condition. /// Thrown when or is . - public static IEnumerable SkipWhile (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable SkipWhile (this Foundation.NSMutableArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1823,7 +1823,7 @@ public static IEnumerable SkipWhile (this Foundation.NSMutableArray< /// The number of elements to return. /// An that contains the specified number of elements from the start of . /// Thrown when is . - public static IEnumerable Take (this Foundation.NSMutableArray source, int count) where TKey : class, Foundation.INativeObject + public static IEnumerable Take (this Foundation.NSMutableArray source, int count) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Take ((IEnumerable) source, count); @@ -1835,7 +1835,7 @@ public static IEnumerable Take (this Foundation.NSMutableArray /// A function to test each element for a condition. /// An that contains elements from as long as the condition is true. /// Thrown when or is . - public static IEnumerable TakeWhile (this Foundation.NSMutableArray source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable TakeWhile (this Foundation.NSMutableArray source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1847,7 +1847,7 @@ public static IEnumerable TakeWhile (this Foundation.NSMutableArray< /// The source collection. /// An that contains distinct elements from . /// Thrown when is . - public static IEnumerable Distinct (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + public static IEnumerable Distinct (this Foundation.NSMutableArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Distinct ((IEnumerable) source); @@ -1858,7 +1858,7 @@ public static IEnumerable Distinct (this Foundation.NSMutableArrayThe source collection. /// An whose elements correspond to those of in reverse order. /// Thrown when is . - public static IEnumerable Reverse (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + public static IEnumerable Reverse (this Foundation.NSMutableArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Reverse ((IEnumerable) source); @@ -1870,7 +1870,7 @@ public static IEnumerable Reverse (this Foundation.NSMutableArrayThe sequence to concatenate to . /// An that contains the concatenated elements of the two sequences. /// Thrown when or is . - public static IEnumerable Concat (this Foundation.NSMutableArray source, IEnumerable second) where TKey : class, Foundation.INativeObject + public static IEnumerable Concat (this Foundation.NSMutableArray source, IEnumerable second) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (second); @@ -1882,7 +1882,7 @@ public static IEnumerable Concat (this Foundation.NSMutableArrayThe source collection. /// A that contains elements from . /// Thrown when is . - public static List ToList (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + public static List ToList (this Foundation.NSMutableArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ToList ((IEnumerable) source); @@ -1893,7 +1893,7 @@ public static List ToList (this Foundation.NSMutableArray sour /// The source collection. /// An array that contains elements from . /// Thrown when is . - public static TKey [] ToArray (this Foundation.NSMutableArray source) where TKey : class, Foundation.INativeObject + public static TKey [] ToArray (this Foundation.NSMutableArray source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ToArray ((IEnumerable) source); @@ -1906,7 +1906,7 @@ public static TKey [] ToArray (this Foundation.NSMutableArray source /// The final accumulator value. /// Thrown when or is . /// Thrown when is empty. - public static TKey Aggregate (this Foundation.NSMutableArray source, Func func) where TKey : class, Foundation.INativeObject + public static TKey Aggregate (this Foundation.NSMutableArray source, Func func) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (func); @@ -1921,7 +1921,7 @@ public static TKey Aggregate (this Foundation.NSMutableArray source, /// An accumulator function to be invoked on each element. /// The final accumulator value. /// Thrown when or is . - public static TAccumulate Aggregate (this Foundation.NSMutableArray source, TAccumulate seed, Func func) where TKey : class, Foundation.INativeObject + public static TAccumulate Aggregate (this Foundation.NSMutableArray source, TAccumulate seed, Func func) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (func); @@ -1935,7 +1935,7 @@ public static TAccumulate Aggregate (this Foundation.NSMutabl /// The first element in . /// Thrown when is . /// Thrown when is empty. - public static TKey First (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + public static TKey First (this Foundation.NSOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.First ((IEnumerable) source); @@ -1948,7 +1948,7 @@ public static TKey First (this Foundation.NSOrderedSet source) where /// The first element in that passes the test in . /// Thrown when or is . /// Thrown when no element satisfies the condition in . - public static TKey First (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey First (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1960,7 +1960,7 @@ public static TKey First (this Foundation.NSOrderedSet source, Func< /// The source collection. /// The first element in , or if the collection is empty. /// Thrown when is . - public static TKey? FirstOrDefault (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + public static TKey? FirstOrDefault (this Foundation.NSOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.FirstOrDefault ((IEnumerable) source); @@ -1972,7 +1972,7 @@ public static TKey First (this Foundation.NSOrderedSet source, Func< /// A function to test each element for a condition. /// The first element in that passes the test in , or if no such element is found. /// Thrown when or is . - public static TKey? FirstOrDefault (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey? FirstOrDefault (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -1985,7 +1985,7 @@ public static TKey First (this Foundation.NSOrderedSet source, Func< /// The last element in . /// Thrown when is . /// Thrown when is empty. - public static TKey Last (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + public static TKey Last (this Foundation.NSOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Last ((IEnumerable) source); @@ -1998,7 +1998,7 @@ public static TKey Last (this Foundation.NSOrderedSet source) where /// The last element in that passes the test in . /// Thrown when or is . /// Thrown when no element satisfies the condition in . - public static TKey Last (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey Last (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2010,7 +2010,7 @@ public static TKey Last (this Foundation.NSOrderedSet source, FuncThe source collection. /// The last element in , or if the collection is empty. /// Thrown when is . - public static TKey? LastOrDefault (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + public static TKey? LastOrDefault (this Foundation.NSOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.LastOrDefault ((IEnumerable) source); @@ -2022,7 +2022,7 @@ public static TKey Last (this Foundation.NSOrderedSet source, FuncA function to test each element for a condition. /// The last element in that passes the test in , or if no such element is found. /// Thrown when or is . - public static TKey? LastOrDefault (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey? LastOrDefault (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2035,7 +2035,7 @@ public static TKey Last (this Foundation.NSOrderedSet source, FuncThe single element of . /// Thrown when is . /// Thrown when is empty or contains more than one element. - public static TKey Single (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + public static TKey Single (this Foundation.NSOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Single ((IEnumerable) source); @@ -2048,7 +2048,7 @@ public static TKey Single (this Foundation.NSOrderedSet source) wher /// The single element in that passes the test in . /// Thrown when or is . /// Thrown when no element or more than one element satisfies the condition in . - public static TKey Single (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey Single (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2061,7 +2061,7 @@ public static TKey Single (this Foundation.NSOrderedSet source, Func /// The single element of , or if the collection is empty. /// Thrown when is . /// Thrown when contains more than one element. - public static TKey? SingleOrDefault (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + public static TKey? SingleOrDefault (this Foundation.NSOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.SingleOrDefault ((IEnumerable) source); @@ -2074,7 +2074,7 @@ public static TKey Single (this Foundation.NSOrderedSet source, Func /// The single element in that passes the test in , or if no such element is found. /// Thrown when or is . /// Thrown when more than one element satisfies the condition in . - public static TKey? SingleOrDefault (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey? SingleOrDefault (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2088,7 +2088,7 @@ public static TKey Single (this Foundation.NSOrderedSet source, Func /// The element at position in . /// Thrown when is . /// Thrown when is less than 0 or greater than or equal to the number of elements in . - public static TKey ElementAt (this Foundation.NSOrderedSet source, int index) where TKey : class, Foundation.INativeObject + public static TKey ElementAt (this Foundation.NSOrderedSet source, int index) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ElementAt ((IEnumerable) source, index); @@ -2100,7 +2100,7 @@ public static TKey ElementAt (this Foundation.NSOrderedSet source, i /// The zero-based index of the element to retrieve. /// The element at position in , or if the index is out of range. /// Thrown when is . - public static TKey? ElementAtOrDefault (this Foundation.NSOrderedSet source, int index) where TKey : class, Foundation.INativeObject + public static TKey? ElementAtOrDefault (this Foundation.NSOrderedSet source, int index) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ElementAtOrDefault ((IEnumerable) source, index); @@ -2111,7 +2111,7 @@ public static TKey ElementAt (this Foundation.NSOrderedSet source, i /// The source collection. /// if contains any elements; otherwise . /// Thrown when is . - public static bool Any (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + public static bool Any (this Foundation.NSOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Any ((IEnumerable) source); @@ -2123,7 +2123,7 @@ public static bool Any (this Foundation.NSOrderedSet source) where T /// A function to test each element for a condition. /// if any element in passes the test in ; otherwise . /// Thrown when or is . - public static bool Any (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static bool Any (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2136,7 +2136,7 @@ public static bool Any (this Foundation.NSOrderedSet source, FuncA function to test each element for a condition. /// if every element in passes the test in , or if the collection is empty; otherwise . /// Thrown when or is . - public static bool All (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static bool All (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2148,7 +2148,7 @@ public static bool All (this Foundation.NSOrderedSet source, FuncThe source collection. /// The number of elements in . /// Thrown when is . - public static int Count (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + public static int Count (this Foundation.NSOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Count ((IEnumerable) source); @@ -2160,7 +2160,7 @@ public static int Count (this Foundation.NSOrderedSet source) where /// A function to test each element for a condition. /// The number of elements in that pass the test in . /// Thrown when or is . - public static int Count (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static int Count (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2172,7 +2172,7 @@ public static int Count (this Foundation.NSOrderedSet source, FuncThe source collection. /// The number of elements in . /// Thrown when is . - public static long LongCount (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + public static long LongCount (this Foundation.NSOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.LongCount ((IEnumerable) source); @@ -2184,7 +2184,7 @@ public static long LongCount (this Foundation.NSOrderedSet source) w /// A function to test each element for a condition. /// The number of elements in that pass the test in . /// Thrown when or is . - public static long LongCount (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static long LongCount (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2197,7 +2197,7 @@ public static long LongCount (this Foundation.NSOrderedSet source, F /// A function to test each element for a condition. /// An that contains elements from that satisfy the condition. /// Thrown when or is . - public static IEnumerable Where (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable Where (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2210,7 +2210,7 @@ public static IEnumerable Where (this Foundation.NSOrderedSet /// A function to test each element; the second parameter represents the zero-based index of the element. /// An that contains elements from that satisfy the condition. /// Thrown when or is . - public static IEnumerable Where (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable Where (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2224,7 +2224,7 @@ public static IEnumerable Where (this Foundation.NSOrderedSet /// A transform function to apply to each element. /// An whose elements are the result of invoking the transform function on each element of . /// Thrown when or is . - public static IEnumerable Select (this Foundation.NSOrderedSet source, Func selector) where TKey : class, Foundation.INativeObject + public static IEnumerable Select (this Foundation.NSOrderedSet source, Func selector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (selector); @@ -2238,7 +2238,7 @@ public static IEnumerable Select (this Foundation.NSOrde /// A transform function to apply to each element; the second parameter represents the zero-based index of the element. /// An whose elements are the result of invoking the transform function on each element of . /// Thrown when or is . - public static IEnumerable Select (this Foundation.NSOrderedSet source, Func selector) where TKey : class, Foundation.INativeObject + public static IEnumerable Select (this Foundation.NSOrderedSet source, Func selector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (selector); @@ -2252,7 +2252,7 @@ public static IEnumerable Select (this Foundation.NSOrde /// A function to extract a key from an element. /// An whose elements are sorted according to a key. /// Thrown when or is . - public static IOrderedEnumerable OrderBy (this Foundation.NSOrderedSet source, Func keySelector) where TKey : class, Foundation.INativeObject + public static IOrderedEnumerable OrderBy (this Foundation.NSOrderedSet source, Func keySelector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (keySelector); @@ -2266,7 +2266,7 @@ public static IOrderedEnumerable OrderBy (this Foundation /// A function to extract a key from an element. /// An whose elements are sorted in descending order according to a key. /// Thrown when or is . - public static IOrderedEnumerable OrderByDescending (this Foundation.NSOrderedSet source, Func keySelector) where TKey : class, Foundation.INativeObject + public static IOrderedEnumerable OrderByDescending (this Foundation.NSOrderedSet source, Func keySelector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (keySelector); @@ -2279,7 +2279,7 @@ public static IOrderedEnumerable OrderByDescending (this /// The number of elements to skip before returning the remaining elements. /// An that contains elements after the skipped ones. /// Thrown when is . - public static IEnumerable Skip (this Foundation.NSOrderedSet source, int count) where TKey : class, Foundation.INativeObject + public static IEnumerable Skip (this Foundation.NSOrderedSet source, int count) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Skip ((IEnumerable) source, count); @@ -2291,7 +2291,7 @@ public static IEnumerable Skip (this Foundation.NSOrderedSet s /// A function to test each element for a condition. /// An that contains the elements starting at the first element that does not satisfy the condition. /// Thrown when or is . - public static IEnumerable SkipWhile (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable SkipWhile (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2304,7 +2304,7 @@ public static IEnumerable SkipWhile (this Foundation.NSOrderedSetThe number of elements to return. /// An that contains the specified number of elements from the start of . /// Thrown when is . - public static IEnumerable Take (this Foundation.NSOrderedSet source, int count) where TKey : class, Foundation.INativeObject + public static IEnumerable Take (this Foundation.NSOrderedSet source, int count) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Take ((IEnumerable) source, count); @@ -2316,7 +2316,7 @@ public static IEnumerable Take (this Foundation.NSOrderedSet s /// A function to test each element for a condition. /// An that contains elements from as long as the condition is true. /// Thrown when or is . - public static IEnumerable TakeWhile (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable TakeWhile (this Foundation.NSOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2328,7 +2328,7 @@ public static IEnumerable TakeWhile (this Foundation.NSOrderedSetThe source collection. /// An that contains distinct elements from . /// Thrown when is . - public static IEnumerable Distinct (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + public static IEnumerable Distinct (this Foundation.NSOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Distinct ((IEnumerable) source); @@ -2339,7 +2339,7 @@ public static IEnumerable Distinct (this Foundation.NSOrderedSetThe source collection. /// An whose elements correspond to those of in reverse order. /// Thrown when is . - public static IEnumerable Reverse (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + public static IEnumerable Reverse (this Foundation.NSOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Reverse ((IEnumerable) source); @@ -2351,7 +2351,7 @@ public static IEnumerable Reverse (this Foundation.NSOrderedSetThe sequence to concatenate to . /// An that contains the concatenated elements of the two sequences. /// Thrown when or is . - public static IEnumerable Concat (this Foundation.NSOrderedSet source, IEnumerable second) where TKey : class, Foundation.INativeObject + public static IEnumerable Concat (this Foundation.NSOrderedSet source, IEnumerable second) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (second); @@ -2363,7 +2363,7 @@ public static IEnumerable Concat (this Foundation.NSOrderedSet /// The source collection. /// A that contains elements from . /// Thrown when is . - public static List ToList (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + public static List ToList (this Foundation.NSOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ToList ((IEnumerable) source); @@ -2374,7 +2374,7 @@ public static List ToList (this Foundation.NSOrderedSet source /// The source collection. /// An array that contains elements from . /// Thrown when is . - public static TKey [] ToArray (this Foundation.NSOrderedSet source) where TKey : class, Foundation.INativeObject + public static TKey [] ToArray (this Foundation.NSOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ToArray ((IEnumerable) source); @@ -2387,7 +2387,7 @@ public static TKey [] ToArray (this Foundation.NSOrderedSet source) /// The final accumulator value. /// Thrown when or is . /// Thrown when is empty. - public static TKey Aggregate (this Foundation.NSOrderedSet source, Func func) where TKey : class, Foundation.INativeObject + public static TKey Aggregate (this Foundation.NSOrderedSet source, Func func) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (func); @@ -2402,7 +2402,7 @@ public static TKey Aggregate (this Foundation.NSOrderedSet source, F /// An accumulator function to be invoked on each element. /// The final accumulator value. /// Thrown when or is . - public static TAccumulate Aggregate (this Foundation.NSOrderedSet source, TAccumulate seed, Func func) where TKey : class, Foundation.INativeObject + public static TAccumulate Aggregate (this Foundation.NSOrderedSet source, TAccumulate seed, Func func) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (func); @@ -2416,7 +2416,7 @@ public static TAccumulate Aggregate (this Foundation.NSOrdere /// The first element in . /// Thrown when is . /// Thrown when is empty. - public static TKey First (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + public static TKey First (this Foundation.NSMutableOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.First ((IEnumerable) source); @@ -2429,7 +2429,7 @@ public static TKey First (this Foundation.NSMutableOrderedSet source /// The first element in that passes the test in . /// Thrown when or is . /// Thrown when no element satisfies the condition in . - public static TKey First (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey First (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2441,7 +2441,7 @@ public static TKey First (this Foundation.NSMutableOrderedSet source /// The source collection. /// The first element in , or if the collection is empty. /// Thrown when is . - public static TKey? FirstOrDefault (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + public static TKey? FirstOrDefault (this Foundation.NSMutableOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.FirstOrDefault ((IEnumerable) source); @@ -2453,7 +2453,7 @@ public static TKey First (this Foundation.NSMutableOrderedSet source /// A function to test each element for a condition. /// The first element in that passes the test in , or if no such element is found. /// Thrown when or is . - public static TKey? FirstOrDefault (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey? FirstOrDefault (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2466,7 +2466,7 @@ public static TKey First (this Foundation.NSMutableOrderedSet source /// The last element in . /// Thrown when is . /// Thrown when is empty. - public static TKey Last (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + public static TKey Last (this Foundation.NSMutableOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Last ((IEnumerable) source); @@ -2479,7 +2479,7 @@ public static TKey Last (this Foundation.NSMutableOrderedSet source) /// The last element in that passes the test in . /// Thrown when or is . /// Thrown when no element satisfies the condition in . - public static TKey Last (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey Last (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2491,7 +2491,7 @@ public static TKey Last (this Foundation.NSMutableOrderedSet source, /// The source collection. /// The last element in , or if the collection is empty. /// Thrown when is . - public static TKey? LastOrDefault (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + public static TKey? LastOrDefault (this Foundation.NSMutableOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.LastOrDefault ((IEnumerable) source); @@ -2503,7 +2503,7 @@ public static TKey Last (this Foundation.NSMutableOrderedSet source, /// A function to test each element for a condition. /// The last element in that passes the test in , or if no such element is found. /// Thrown when or is . - public static TKey? LastOrDefault (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey? LastOrDefault (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2516,7 +2516,7 @@ public static TKey Last (this Foundation.NSMutableOrderedSet source, /// The single element of . /// Thrown when is . /// Thrown when is empty or contains more than one element. - public static TKey Single (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + public static TKey Single (this Foundation.NSMutableOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Single ((IEnumerable) source); @@ -2529,7 +2529,7 @@ public static TKey Single (this Foundation.NSMutableOrderedSet sourc /// The single element in that passes the test in . /// Thrown when or is . /// Thrown when no element or more than one element satisfies the condition in . - public static TKey Single (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey Single (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2542,7 +2542,7 @@ public static TKey Single (this Foundation.NSMutableOrderedSet sourc /// The single element of , or if the collection is empty. /// Thrown when is . /// Thrown when contains more than one element. - public static TKey? SingleOrDefault (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + public static TKey? SingleOrDefault (this Foundation.NSMutableOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.SingleOrDefault ((IEnumerable) source); @@ -2555,7 +2555,7 @@ public static TKey Single (this Foundation.NSMutableOrderedSet sourc /// The single element in that passes the test in , or if no such element is found. /// Thrown when or is . /// Thrown when more than one element satisfies the condition in . - public static TKey? SingleOrDefault (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static TKey? SingleOrDefault (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2569,7 +2569,7 @@ public static TKey Single (this Foundation.NSMutableOrderedSet sourc /// The element at position in . /// Thrown when is . /// Thrown when is less than 0 or greater than or equal to the number of elements in . - public static TKey ElementAt (this Foundation.NSMutableOrderedSet source, int index) where TKey : class, Foundation.INativeObject + public static TKey ElementAt (this Foundation.NSMutableOrderedSet source, int index) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ElementAt ((IEnumerable) source, index); @@ -2581,7 +2581,7 @@ public static TKey ElementAt (this Foundation.NSMutableOrderedSet so /// The zero-based index of the element to retrieve. /// The element at position in , or if the index is out of range. /// Thrown when is . - public static TKey? ElementAtOrDefault (this Foundation.NSMutableOrderedSet source, int index) where TKey : class, Foundation.INativeObject + public static TKey? ElementAtOrDefault (this Foundation.NSMutableOrderedSet source, int index) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ElementAtOrDefault ((IEnumerable) source, index); @@ -2592,7 +2592,7 @@ public static TKey ElementAt (this Foundation.NSMutableOrderedSet so /// The source collection. /// if contains any elements; otherwise . /// Thrown when is . - public static bool Any (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + public static bool Any (this Foundation.NSMutableOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Any ((IEnumerable) source); @@ -2604,7 +2604,7 @@ public static bool Any (this Foundation.NSMutableOrderedSet source) /// A function to test each element for a condition. /// if any element in passes the test in ; otherwise . /// Thrown when or is . - public static bool Any (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static bool Any (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2617,7 +2617,7 @@ public static bool Any (this Foundation.NSMutableOrderedSet source, /// A function to test each element for a condition. /// if every element in passes the test in , or if the collection is empty; otherwise . /// Thrown when or is . - public static bool All (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static bool All (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2629,7 +2629,7 @@ public static bool All (this Foundation.NSMutableOrderedSet source, /// The source collection. /// The number of elements in . /// Thrown when is . - public static int Count (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + public static int Count (this Foundation.NSMutableOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Count ((IEnumerable) source); @@ -2641,7 +2641,7 @@ public static int Count (this Foundation.NSMutableOrderedSet source) /// A function to test each element for a condition. /// The number of elements in that pass the test in . /// Thrown when or is . - public static int Count (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static int Count (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2653,7 +2653,7 @@ public static int Count (this Foundation.NSMutableOrderedSet source, /// The source collection. /// The number of elements in . /// Thrown when is . - public static long LongCount (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + public static long LongCount (this Foundation.NSMutableOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.LongCount ((IEnumerable) source); @@ -2665,7 +2665,7 @@ public static long LongCount (this Foundation.NSMutableOrderedSet so /// A function to test each element for a condition. /// The number of elements in that pass the test in . /// Thrown when or is . - public static long LongCount (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static long LongCount (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2678,7 +2678,7 @@ public static long LongCount (this Foundation.NSMutableOrderedSet so /// A function to test each element for a condition. /// An that contains elements from that satisfy the condition. /// Thrown when or is . - public static IEnumerable Where (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable Where (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2691,7 +2691,7 @@ public static IEnumerable Where (this Foundation.NSMutableOrderedSet /// A function to test each element; the second parameter represents the zero-based index of the element. /// An that contains elements from that satisfy the condition. /// Thrown when or is . - public static IEnumerable Where (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable Where (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2705,7 +2705,7 @@ public static IEnumerable Where (this Foundation.NSMutableOrderedSet /// A transform function to apply to each element. /// An whose elements are the result of invoking the transform function on each element of . /// Thrown when or is . - public static IEnumerable Select (this Foundation.NSMutableOrderedSet source, Func selector) where TKey : class, Foundation.INativeObject + public static IEnumerable Select (this Foundation.NSMutableOrderedSet source, Func selector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (selector); @@ -2719,7 +2719,7 @@ public static IEnumerable Select (this Foundation.NSMuta /// A transform function to apply to each element; the second parameter represents the zero-based index of the element. /// An whose elements are the result of invoking the transform function on each element of . /// Thrown when or is . - public static IEnumerable Select (this Foundation.NSMutableOrderedSet source, Func selector) where TKey : class, Foundation.INativeObject + public static IEnumerable Select (this Foundation.NSMutableOrderedSet source, Func selector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (selector); @@ -2733,7 +2733,7 @@ public static IEnumerable Select (this Foundation.NSMuta /// A function to extract a key from an element. /// An whose elements are sorted according to a key. /// Thrown when or is . - public static IOrderedEnumerable OrderBy (this Foundation.NSMutableOrderedSet source, Func keySelector) where TKey : class, Foundation.INativeObject + public static IOrderedEnumerable OrderBy (this Foundation.NSMutableOrderedSet source, Func keySelector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (keySelector); @@ -2747,7 +2747,7 @@ public static IOrderedEnumerable OrderBy (this Foundation /// A function to extract a key from an element. /// An whose elements are sorted in descending order according to a key. /// Thrown when or is . - public static IOrderedEnumerable OrderByDescending (this Foundation.NSMutableOrderedSet source, Func keySelector) where TKey : class, Foundation.INativeObject + public static IOrderedEnumerable OrderByDescending (this Foundation.NSMutableOrderedSet source, Func keySelector) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (keySelector); @@ -2760,7 +2760,7 @@ public static IOrderedEnumerable OrderByDescending (this /// The number of elements to skip before returning the remaining elements. /// An that contains elements after the skipped ones. /// Thrown when is . - public static IEnumerable Skip (this Foundation.NSMutableOrderedSet source, int count) where TKey : class, Foundation.INativeObject + public static IEnumerable Skip (this Foundation.NSMutableOrderedSet source, int count) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Skip ((IEnumerable) source, count); @@ -2772,7 +2772,7 @@ public static IEnumerable Skip (this Foundation.NSMutableOrderedSet< /// A function to test each element for a condition. /// An that contains the elements starting at the first element that does not satisfy the condition. /// Thrown when or is . - public static IEnumerable SkipWhile (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable SkipWhile (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2785,7 +2785,7 @@ public static IEnumerable SkipWhile (this Foundation.NSMutableOrdere /// The number of elements to return. /// An that contains the specified number of elements from the start of . /// Thrown when is . - public static IEnumerable Take (this Foundation.NSMutableOrderedSet source, int count) where TKey : class, Foundation.INativeObject + public static IEnumerable Take (this Foundation.NSMutableOrderedSet source, int count) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Take ((IEnumerable) source, count); @@ -2797,7 +2797,7 @@ public static IEnumerable Take (this Foundation.NSMutableOrderedSet< /// A function to test each element for a condition. /// An that contains elements from as long as the condition is true. /// Thrown when or is . - public static IEnumerable TakeWhile (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, Foundation.INativeObject + public static IEnumerable TakeWhile (this Foundation.NSMutableOrderedSet source, Func predicate) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (predicate); @@ -2809,7 +2809,7 @@ public static IEnumerable TakeWhile (this Foundation.NSMutableOrdere /// The source collection. /// An that contains distinct elements from . /// Thrown when is . - public static IEnumerable Distinct (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + public static IEnumerable Distinct (this Foundation.NSMutableOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Distinct ((IEnumerable) source); @@ -2820,7 +2820,7 @@ public static IEnumerable Distinct (this Foundation.NSMutableOrdered /// The source collection. /// An whose elements correspond to those of in reverse order. /// Thrown when is . - public static IEnumerable Reverse (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + public static IEnumerable Reverse (this Foundation.NSMutableOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.Reverse ((IEnumerable) source); @@ -2832,7 +2832,7 @@ public static IEnumerable Reverse (this Foundation.NSMutableOrderedS /// The sequence to concatenate to . /// An that contains the concatenated elements of the two sequences. /// Thrown when or is . - public static IEnumerable Concat (this Foundation.NSMutableOrderedSet source, IEnumerable second) where TKey : class, Foundation.INativeObject + public static IEnumerable Concat (this Foundation.NSMutableOrderedSet source, IEnumerable second) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (second); @@ -2844,7 +2844,7 @@ public static IEnumerable Concat (this Foundation.NSMutableOrderedSe /// The source collection. /// A that contains elements from . /// Thrown when is . - public static List ToList (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + public static List ToList (this Foundation.NSMutableOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ToList ((IEnumerable) source); @@ -2855,7 +2855,7 @@ public static List ToList (this Foundation.NSMutableOrderedSet /// The source collection. /// An array that contains elements from . /// Thrown when is . - public static TKey [] ToArray (this Foundation.NSMutableOrderedSet source) where TKey : class, Foundation.INativeObject + public static TKey [] ToArray (this Foundation.NSMutableOrderedSet source) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); return Enumerable.ToArray ((IEnumerable) source); @@ -2868,7 +2868,7 @@ public static TKey [] ToArray (this Foundation.NSMutableOrderedSet s /// The final accumulator value. /// Thrown when or is . /// Thrown when is empty. - public static TKey Aggregate (this Foundation.NSMutableOrderedSet source, Func func) where TKey : class, Foundation.INativeObject + public static TKey Aggregate (this Foundation.NSMutableOrderedSet source, Func func) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (func); @@ -2883,7 +2883,7 @@ public static TKey Aggregate (this Foundation.NSMutableOrderedSet so /// An accumulator function to be invoked on each element. /// The final accumulator value. /// Thrown when or is . - public static TAccumulate Aggregate (this Foundation.NSMutableOrderedSet source, TAccumulate seed, Func func) where TKey : class, Foundation.INativeObject + public static TAccumulate Aggregate (this Foundation.NSMutableOrderedSet source, TAccumulate seed, Func func) where TKey : class, ObjCRuntime.INativeObject { ArgumentNullException.ThrowIfNull (source); ArgumentNullException.ThrowIfNull (func); From 56709b2e806746948448b35df01ab10a3e65d98b Mon Sep 17 00:00:00 2001 From: GitHub Actions Autoformatter Date: Wed, 27 May 2026 15:59:35 +0000 Subject: [PATCH 6/6] Auto-format source code --- .../Foundation/NSCollectionLinqTest.cs | 3022 ++++++++--------- 1 file changed, 1511 insertions(+), 1511 deletions(-) diff --git a/tests/monotouch-test/Foundation/NSCollectionLinqTest.cs b/tests/monotouch-test/Foundation/NSCollectionLinqTest.cs index 23ae501d5075..03ab33120969 100644 --- a/tests/monotouch-test/Foundation/NSCollectionLinqTest.cs +++ b/tests/monotouch-test/Foundation/NSCollectionLinqTest.cs @@ -7,1515 +7,1515 @@ namespace MonoTouchFixtures.Foundation { -[TestFixture] -[Preserve (AllMembers = true)] -public class NSCollectionLinqTest { - -// ----- helpers ----- - -static NSString S (string s) => (NSString) s; - -static NSSet MakeSet (params string [] items) -{ -return new NSSet (items.Select (S).ToArray ()); -} - -static NSMutableSet MakeMutableSet (params string [] items) -{ -return new NSMutableSet (items.Select (S).ToArray ()); -} - -static NSArray MakeArray (params string [] items) -{ -return NSArray.FromNSObjects (items.Select (S).ToArray ()); -} - -static NSMutableArray MakeMutableArray (params string [] items) -{ -var arr = new NSMutableArray (); -foreach (var s in items) -arr.Add (S (s)); -return arr; -} - -static NSOrderedSet MakeOrderedSet (params string [] items) -{ -return new NSOrderedSet (items.Select (S).ToArray ()); -} - -static NSMutableOrderedSet MakeMutableOrderedSet (params string [] items) -{ -var set = new NSMutableOrderedSet (); -foreach (var s in items) -set.Add (S (s)); -return set; -} - -// ===== NSSet ===== - -[Test] -public void NSSet_First () -{ -using var set = MakeSet ("a"); -var first = set.First (); -Assert.That (first.ToString (), Is.EqualTo ("a"), "First"); -} - -[Test] -public void NSSet_First_Predicate () -{ -using var set = MakeSet ("a", "b", "c"); -var found = set.First (s => s.ToString () == "b"); -Assert.That (found.ToString (), Is.EqualTo ("b"), "First predicate"); -} - -[Test] -public void NSSet_First_Empty_Throws () -{ -using var set = MakeSet (); -Assert.Throws (() => set.First ()); -} - -[Test] -public void NSSet_FirstOrDefault_Empty () -{ -using var set = MakeSet (); -Assert.That (set.FirstOrDefault (), Is.Null, "FirstOrDefault empty"); -} - -[Test] -public void NSSet_FirstOrDefault () -{ -using var set = MakeSet ("x"); -Assert.That (set.FirstOrDefault (), Is.Not.Null, "FirstOrDefault"); -} - -[Test] -public void NSSet_FirstOrDefault_Predicate_NoMatch () -{ -using var set = MakeSet ("a", "b"); -Assert.That (set.FirstOrDefault (s => s.ToString () == "z"), Is.Null, "no match"); -} - -[Test] -public void NSSet_Last () -{ -using var set = MakeSet ("a"); -var last = set.Last (); -Assert.That (last.ToString (), Is.EqualTo ("a"), "Last"); -} - -[Test] -public void NSSet_Last_Predicate () -{ -using var set = MakeSet ("a", "b", "c"); -var found = set.Last (s => s.ToString () != "c"); -Assert.That (found, Is.Not.Null, "Last predicate not null"); -} - -[Test] -public void NSSet_Last_Empty_Throws () -{ -using var set = MakeSet (); -Assert.Throws (() => set.Last ()); -} - -[Test] -public void NSSet_LastOrDefault_Empty () -{ -using var set = MakeSet (); -Assert.That (set.LastOrDefault (), Is.Null, "LastOrDefault empty"); -} - -[Test] -public void NSSet_LastOrDefault_Predicate_NoMatch () -{ -using var set = MakeSet ("a"); -Assert.That (set.LastOrDefault (s => s.ToString () == "z"), Is.Null, "LastOrDefault no match"); -} - -[Test] -public void NSSet_Single () -{ -using var set = MakeSet ("only"); -Assert.That (set.Single ().ToString (), Is.EqualTo ("only"), "Single"); -} - -[Test] -public void NSSet_Single_Throws_OnMultiple () -{ -using var set = MakeSet ("a", "b"); -Assert.Throws (() => set.Single ()); -} - -[Test] -public void NSSet_SingleOrDefault_Empty () -{ -using var set = MakeSet (); -Assert.That (set.SingleOrDefault (), Is.Null, "SingleOrDefault empty"); -} - -[Test] -public void NSSet_SingleOrDefault_Predicate () -{ -using var set = MakeSet ("a", "b"); -Assert.That (set.SingleOrDefault (s => s.ToString () == "a")?.ToString (), Is.EqualTo ("a"), "SingleOrDefault predicate"); -} - -[Test] -public void NSSet_Any_Empty () -{ -using var set = MakeSet (); -Assert.That (set.Any (), Is.False, "Any empty"); -} - -[Test] -public void NSSet_Any_NonEmpty () -{ -using var set = MakeSet ("a"); -Assert.That (set.Any (), Is.True, "Any non-empty"); -} - -[Test] -public void NSSet_Any_Predicate () -{ -using var set = MakeSet ("a", "b"); -Assert.That (set.Any (s => s.ToString () == "b"), Is.True, "Any predicate true"); -Assert.That (set.Any (s => s.ToString () == "z"), Is.False, "Any predicate false"); -} - -[Test] -public void NSSet_All () -{ -using var set = MakeSet ("ab", "abc"); -Assert.That (set.All (s => s.Length > 1), Is.True, "All true"); -Assert.That (set.All (s => s.Length > 2), Is.False, "All false"); -} - -[Test] -public void NSSet_Count () -{ -using var set = MakeSet ("a", "b", "c"); -Assert.That (set.Count (), Is.EqualTo (3), "Count"); -Assert.That (set.Count (s => s.ToString () == "a"), Is.EqualTo (1), "Count predicate"); -} - -[Test] -public void NSSet_LongCount () -{ -using var set = MakeSet ("a", "b"); -Assert.That (set.LongCount (), Is.EqualTo (2L), "LongCount"); -Assert.That (set.LongCount (s => s.ToString () == "a"), Is.EqualTo (1L), "LongCount predicate"); -} - -[Test] -public void NSSet_Where () -{ -using var set = MakeSet ("a", "bb", "ccc"); -var result = set.Where (s => s.Length > 1).ToList (); -Assert.That (result.Count, Is.EqualTo (2), "Where count"); -} - -[Test] -public void NSSet_Where_Index () -{ -using var arr = MakeOrderedSet ("a", "b", "c"); -var result = arr.Where ((s, i) => i % 2 == 0).ToList (); -Assert.That (result.Count, Is.EqualTo (2), "Where index count"); -} - -[Test] -public void NSSet_Select () -{ -using var set = MakeSet ("hello"); -var lengths = set.Select (s => s.Length).ToList (); -Assert.That (lengths, Contains.Item (5), "Select length"); -} - -[Test] -public void NSSet_Select_Index () -{ -using var arr = MakeOrderedSet ("a", "b", "c"); -var indexed = arr.Select ((s, i) => $"{i}:{s}").ToList (); -Assert.That (indexed [0], Is.EqualTo ("0:a"), "Select index 0"); -Assert.That (indexed [1], Is.EqualTo ("1:b"), "Select index 1"); -} - -[Test] -public void NSSet_OrderBy () -{ -using var set = MakeSet ("banana", "apple", "cherry"); -var sorted = set.OrderBy (s => s.ToString ()).ToList (); -Assert.That (sorted [0].ToString (), Is.EqualTo ("apple"), "OrderBy first"); -Assert.That (sorted [2].ToString (), Is.EqualTo ("cherry"), "OrderBy last"); -} - -[Test] -public void NSSet_OrderByDescending () -{ -using var set = MakeSet ("banana", "apple", "cherry"); -var sorted = set.OrderByDescending (s => s.ToString ()).ToList (); -Assert.That (sorted [0].ToString (), Is.EqualTo ("cherry"), "OrderByDesc first"); -} - -[Test] -public void NSSet_Distinct () -{ -using var set = MakeSet ("a", "b", "b"); -// NSSet already ensures uniqueness, but verify Distinct works -var distinct = set.Distinct ().ToList (); -Assert.That (distinct.Count, Is.EqualTo (2), "Distinct count"); -} - -[Test] -public void NSSet_Reverse () -{ -using var arr = MakeOrderedSet ("a", "b", "c"); -var reversed = arr.Reverse ().ToList (); -Assert.That (reversed [0].ToString (), Is.EqualTo ("c"), "Reverse first"); -Assert.That (reversed [2].ToString (), Is.EqualTo ("a"), "Reverse last"); -} - -[Test] -public void NSSet_Concat () -{ -using var set = MakeSet ("a", "b"); -var extra = new [] { S ("c"), S ("d") }; -var all = set.Concat (extra).ToList (); -Assert.That (all.Count, Is.EqualTo (4), "Concat count"); -} - -[Test] -public void NSSet_Skip_Take () -{ -using var arr = MakeOrderedSet ("a", "b", "c", "d"); -var sliced = arr.Skip (1).Take (2).ToList (); -Assert.That (sliced.Count, Is.EqualTo (2), "Skip/Take count"); -Assert.That (sliced [0].ToString (), Is.EqualTo ("b"), "Skip/Take first"); -} - -[Test] -public void NSSet_SkipWhile_TakeWhile () -{ -using var arr = MakeOrderedSet ("a", "b", "c"); -var skipped = arr.SkipWhile (s => s.ToString () == "a").ToList (); -Assert.That (skipped.Count, Is.EqualTo (2), "SkipWhile count"); - -var taken = arr.TakeWhile (s => s.ToString () != "c").ToList (); -Assert.That (taken.Count, Is.EqualTo (2), "TakeWhile count"); -} - -[Test] -public void NSSet_ElementAt () -{ -using var arr = MakeOrderedSet ("a", "b", "c"); -Assert.That (arr.ElementAt (1).ToString (), Is.EqualTo ("b"), "ElementAt"); -} - -[Test] -public void NSSet_ElementAtOrDefault () -{ -using var arr = MakeOrderedSet ("a", "b"); -Assert.That (arr.ElementAtOrDefault (0), Is.Not.Null, "ElementAtOrDefault in range"); -Assert.That (arr.ElementAtOrDefault (99), Is.Null, "ElementAtOrDefault out of range"); -} - -[Test] -public void NSSet_ToList () -{ -using var set = MakeSet ("a", "b"); -var list = set.ToList (); -Assert.That (list, Is.TypeOf> (), "ToList type"); -Assert.That (list.Count, Is.EqualTo (2), "ToList count"); -} - -[Test] -public void NSSet_ToArray () -{ -using var set = MakeSet ("a", "b"); -var arr = set.ToArray (); -Assert.That (arr, Is.TypeOf (), "ToArray type"); -Assert.That (arr.Length, Is.EqualTo (2), "ToArray length"); -} - -[Test] -public void NSSet_Aggregate () -{ -using var arr = MakeOrderedSet ("a", "b", "c"); -var result = arr.Aggregate ((acc, s) => (NSString) (acc.ToString () + s.ToString ())); -Assert.That (result.ToString (), Is.EqualTo ("abc"), "Aggregate"); -} - -[Test] -public void NSSet_Aggregate_Seed () -{ -using var arr = MakeOrderedSet ("a", "b", "c"); -var result = arr.Aggregate ("", (acc, s) => acc + s.ToString ()); -Assert.That (result, Is.EqualTo ("abc"), "Aggregate seed"); -} - -// ===== NSMutableSet ===== - -[Test] -public void NSMutableSet_First () -{ -using var set = MakeMutableSet ("a"); -Assert.That (set.First ().ToString (), Is.EqualTo ("a"), "First"); -} - -[Test] -public void NSMutableSet_FirstOrDefault_Empty () -{ -using var set = MakeMutableSet (); -Assert.That (set.FirstOrDefault (), Is.Null, "FirstOrDefault empty"); -} - -[Test] -public void NSMutableSet_Last () -{ -using var set = MakeMutableSet ("a"); -Assert.That (set.Last ().ToString (), Is.EqualTo ("a"), "Last"); -} - -[Test] -public void NSMutableSet_LastOrDefault_Empty () -{ -using var set = MakeMutableSet (); -Assert.That (set.LastOrDefault (), Is.Null, "LastOrDefault empty"); -} - -[Test] -public void NSMutableSet_Single () -{ -using var set = MakeMutableSet ("only"); -Assert.That (set.Single ().ToString (), Is.EqualTo ("only"), "Single"); -} - -[Test] -public void NSMutableSet_SingleOrDefault_Empty () -{ -using var set = MakeMutableSet (); -Assert.That (set.SingleOrDefault (), Is.Null, "SingleOrDefault empty"); -} - -[Test] -public void NSMutableSet_Any () -{ -using var set = MakeMutableSet (); -Assert.That (set.Any (), Is.False, "Any empty"); -using var set2 = MakeMutableSet ("a"); -Assert.That (set2.Any (), Is.True, "Any non-empty"); -} - -[Test] -public void NSMutableSet_All () -{ -using var set = MakeMutableSet ("ab", "abc"); -Assert.That (set.All (s => s.Length > 1), Is.True, "All true"); -} - -[Test] -public void NSMutableSet_Count () -{ -using var set = MakeMutableSet ("a", "b", "c"); -Assert.That (set.Count (), Is.EqualTo (3), "Count"); -} - -[Test] -public void NSMutableSet_LongCount () -{ -using var set = MakeMutableSet ("a", "b"); -Assert.That (set.LongCount (), Is.EqualTo (2L), "LongCount"); -} - -[Test] -public void NSMutableSet_Where () -{ -using var set = MakeMutableSet ("a", "bb", "ccc"); -var result = set.Where (s => s.Length > 1).ToList (); -Assert.That (result.Count, Is.EqualTo (2), "Where count"); -} - -[Test] -public void NSMutableSet_Select () -{ -using var set = MakeMutableSet ("hello"); -var lengths = set.Select (s => s.Length).ToList (); -Assert.That (lengths, Contains.Item (5), "Select length"); -} - -[Test] -public void NSMutableSet_OrderBy () -{ -using var set = MakeMutableSet ("banana", "apple", "cherry"); -var sorted = set.OrderBy (s => s.ToString ()).ToList (); -Assert.That (sorted [0].ToString (), Is.EqualTo ("apple"), "OrderBy first"); -} - -[Test] -public void NSMutableSet_Skip_Take () -{ -using var arr = MakeOrderedSet ("a", "b", "c", "d"); -var sliced = arr.Skip (1).Take (2).ToList (); -Assert.That (sliced.Count, Is.EqualTo (2), "Skip/Take count"); -} - -[Test] -public void NSMutableSet_ToList () -{ -using var set = MakeMutableSet ("a", "b"); -var list = set.ToList (); -Assert.That (list.Count, Is.EqualTo (2), "ToList count"); -} - -[Test] -public void NSMutableSet_ToArray () -{ -using var set = MakeMutableSet ("a", "b"); -var arr = set.ToArray (); -Assert.That (arr.Length, Is.EqualTo (2), "ToArray length"); -} - -[Test] -public void NSMutableSet_Aggregate () -{ -using var set = MakeMutableSet ("a"); -var result = set.Aggregate ((acc, s) => (NSString) (acc.ToString () + s.ToString ())); -Assert.That (result.ToString (), Is.EqualTo ("a"), "Aggregate"); -} - -// ===== NSArray ===== - -[Test] -public void NSArray_First () -{ -using var arr = MakeArray ("a", "b", "c"); -Assert.That (arr.First ().ToString (), Is.EqualTo ("a"), "First"); -} - -[Test] -public void NSArray_First_Predicate () -{ -using var arr = MakeArray ("a", "b", "c"); -Assert.That (arr.First (s => s.ToString () == "b").ToString (), Is.EqualTo ("b"), "First predicate"); -} - -[Test] -public void NSArray_First_Empty_Throws () -{ -using var arr = MakeArray (); -Assert.Throws (() => arr.First ()); -} - -[Test] -public void NSArray_FirstOrDefault_Empty () -{ -using var arr = MakeArray (); -Assert.That (arr.FirstOrDefault (), Is.Null, "FirstOrDefault empty"); -} - -[Test] -public void NSArray_FirstOrDefault () -{ -using var arr = MakeArray ("x", "y"); -Assert.That (arr.FirstOrDefault ()?.ToString (), Is.EqualTo ("x"), "FirstOrDefault"); -} - -[Test] -public void NSArray_FirstOrDefault_Predicate () -{ -using var arr = MakeArray ("a", "b", "c"); -Assert.That (arr.FirstOrDefault (s => s.ToString () == "b")?.ToString (), Is.EqualTo ("b"), "FirstOrDefault predicate match"); -Assert.That (arr.FirstOrDefault (s => s.ToString () == "z"), Is.Null, "FirstOrDefault predicate no match"); -} - -[Test] -public void NSArray_Last () -{ -using var arr = MakeArray ("a", "b", "c"); -Assert.That (arr.Last ().ToString (), Is.EqualTo ("c"), "Last"); -} - -[Test] -public void NSArray_Last_Predicate () -{ -using var arr = MakeArray ("a", "b", "c"); -Assert.That (arr.Last (s => s.ToString () != "c").ToString (), Is.EqualTo ("b"), "Last predicate"); -} - -[Test] -public void NSArray_Last_Empty_Throws () -{ -using var arr = MakeArray (); -Assert.Throws (() => arr.Last ()); -} - -[Test] -public void NSArray_LastOrDefault_Empty () -{ -using var arr = MakeArray (); -Assert.That (arr.LastOrDefault (), Is.Null, "LastOrDefault empty"); -} - -[Test] -public void NSArray_LastOrDefault_Predicate_NoMatch () -{ -using var arr = MakeArray ("a", "b"); -Assert.That (arr.LastOrDefault (s => s.ToString () == "z"), Is.Null, "LastOrDefault no match"); -} - -[Test] -public void NSArray_Single () -{ -using var arr = MakeArray ("only"); -Assert.That (arr.Single ().ToString (), Is.EqualTo ("only"), "Single"); -} - -[Test] -public void NSArray_Single_Throws_OnEmpty () -{ -using var arr = MakeArray (); -Assert.Throws (() => arr.Single ()); -} - -[Test] -public void NSArray_Single_Throws_OnMultiple () -{ -using var arr = MakeArray ("a", "b"); -Assert.Throws (() => arr.Single ()); -} - -[Test] -public void NSArray_SingleOrDefault_Empty () -{ -using var arr = MakeArray (); -Assert.That (arr.SingleOrDefault (), Is.Null, "SingleOrDefault empty"); -} - -[Test] -public void NSArray_SingleOrDefault_Predicate () -{ -using var arr = MakeArray ("a", "b"); -Assert.That (arr.SingleOrDefault (s => s.ToString () == "a")?.ToString (), Is.EqualTo ("a"), "SingleOrDefault predicate match"); -Assert.That (arr.SingleOrDefault (s => s.ToString () == "z"), Is.Null, "SingleOrDefault predicate no match"); -} - -[Test] -public void NSArray_ElementAt () -{ -using var arr = MakeArray ("a", "b", "c"); -Assert.That (arr.ElementAt (0).ToString (), Is.EqualTo ("a"), "ElementAt 0"); -Assert.That (arr.ElementAt (2).ToString (), Is.EqualTo ("c"), "ElementAt 2"); -} - -[Test] -public void NSArray_ElementAt_OutOfRange_Throws () -{ -using var arr = MakeArray ("a"); -Assert.Throws (() => arr.ElementAt (5)); -} - -[Test] -public void NSArray_ElementAtOrDefault () -{ -using var arr = MakeArray ("a", "b"); -Assert.That (arr.ElementAtOrDefault (1)?.ToString (), Is.EqualTo ("b"), "ElementAtOrDefault in range"); -Assert.That (arr.ElementAtOrDefault (99), Is.Null, "ElementAtOrDefault out of range"); -} - -[Test] -public void NSArray_Any () -{ -using var empty = MakeArray (); -Assert.That (empty.Any (), Is.False, "Any empty"); -using var arr = MakeArray ("a"); -Assert.That (arr.Any (), Is.True, "Any non-empty"); -Assert.That (arr.Any (s => s.ToString () == "a"), Is.True, "Any predicate true"); -Assert.That (arr.Any (s => s.ToString () == "z"), Is.False, "Any predicate false"); -} - -[Test] -public void NSArray_All () -{ -using var arr = MakeArray ("ab", "abc"); -Assert.That (arr.All (s => s.Length > 1), Is.True, "All true"); -Assert.That (arr.All (s => s.Length > 2), Is.False, "All false"); -} - -[Test] -public void NSArray_Count () -{ -using var arr = MakeArray ("a", "b", "c"); -Assert.That (arr.Count (), Is.EqualTo (3), "Count"); -Assert.That (arr.Count (s => s.ToString () == "a"), Is.EqualTo (1), "Count predicate"); -} - -[Test] -public void NSArray_LongCount () -{ -using var arr = MakeArray ("a", "b"); -Assert.That (arr.LongCount (), Is.EqualTo (2L), "LongCount"); -Assert.That (arr.LongCount (s => s.ToString () == "a"), Is.EqualTo (1L), "LongCount predicate"); -} - -[Test] -public void NSArray_Where () -{ -using var arr = MakeArray ("a", "bb", "ccc"); -var result = arr.Where (s => s.Length > 1).ToList (); -Assert.That (result.Count, Is.EqualTo (2), "Where count"); -} - -[Test] -public void NSArray_Where_Index () -{ -using var arr = MakeArray ("a", "b", "c"); -var result = arr.Where ((s, i) => i % 2 == 0).ToList (); -Assert.That (result.Count, Is.EqualTo (2), "Where index count"); -Assert.That (result [0].ToString (), Is.EqualTo ("a"), "Where index [0]"); -Assert.That (result [1].ToString (), Is.EqualTo ("c"), "Where index [1]"); -} - -[Test] -public void NSArray_Select () -{ -using var arr = MakeArray ("hello", "world"); -var lengths = arr.Select (s => s.Length).ToList (); -Assert.That (lengths [0], Is.EqualTo (5), "Select length [0]"); -Assert.That (lengths [1], Is.EqualTo (5), "Select length [1]"); -} - -[Test] -public void NSArray_Select_Index () -{ -using var arr = MakeArray ("a", "b", "c"); -var indexed = arr.Select ((s, i) => $"{i}:{s}").ToList (); -Assert.That (indexed [0], Is.EqualTo ("0:a"), "Select index 0"); -Assert.That (indexed [2], Is.EqualTo ("2:c"), "Select index 2"); -} - -[Test] -public void NSArray_OrderBy () -{ -using var arr = MakeArray ("banana", "apple", "cherry"); -var sorted = arr.OrderBy (s => s.ToString ()).ToList (); -Assert.That (sorted [0].ToString (), Is.EqualTo ("apple"), "OrderBy first"); -Assert.That (sorted [1].ToString (), Is.EqualTo ("banana"), "OrderBy second"); -Assert.That (sorted [2].ToString (), Is.EqualTo ("cherry"), "OrderBy third"); -} - -[Test] -public void NSArray_OrderByDescending () -{ -using var arr = MakeArray ("banana", "apple", "cherry"); -var sorted = arr.OrderByDescending (s => s.ToString ()).ToList (); -Assert.That (sorted [0].ToString (), Is.EqualTo ("cherry"), "OrderByDesc first"); -Assert.That (sorted [2].ToString (), Is.EqualTo ("apple"), "OrderByDesc last"); -} - -[Test] -public void NSArray_Skip () -{ -using var arr = MakeArray ("a", "b", "c", "d"); -var skipped = arr.Skip (2).ToList (); -Assert.That (skipped.Count, Is.EqualTo (2), "Skip count"); -Assert.That (skipped [0].ToString (), Is.EqualTo ("c"), "Skip [0]"); -} - -[Test] -public void NSArray_SkipWhile () -{ -using var arr = MakeArray ("a", "b", "c"); -var result = arr.SkipWhile (s => s.ToString () != "b").ToList (); -Assert.That (result.Count, Is.EqualTo (2), "SkipWhile count"); -Assert.That (result [0].ToString (), Is.EqualTo ("b"), "SkipWhile first"); -} - -[Test] -public void NSArray_Take () -{ -using var arr = MakeArray ("a", "b", "c"); -var taken = arr.Take (2).ToList (); -Assert.That (taken.Count, Is.EqualTo (2), "Take count"); -Assert.That (taken [1].ToString (), Is.EqualTo ("b"), "Take [1]"); -} - -[Test] -public void NSArray_TakeWhile () -{ -using var arr = MakeArray ("a", "b", "c"); -var taken = arr.TakeWhile (s => s.ToString () != "c").ToList (); -Assert.That (taken.Count, Is.EqualTo (2), "TakeWhile count"); -} - -[Test] -public void NSArray_Distinct () -{ -using var arr = MakeArray ("a", "a", "b"); -var distinct = arr.Distinct ().ToList (); -Assert.That (distinct.Count, Is.EqualTo (2), "Distinct count"); -} - -[Test] -public void NSArray_Reverse () -{ -using var arr = MakeArray ("a", "b", "c"); -var reversed = arr.Reverse ().ToList (); -Assert.That (reversed [0].ToString (), Is.EqualTo ("c"), "Reverse [0]"); -Assert.That (reversed [2].ToString (), Is.EqualTo ("a"), "Reverse [2]"); -} - -[Test] -public void NSArray_Concat () -{ -using var arr = MakeArray ("a", "b"); -var extra = new [] { S ("c") }; -var all = arr.Concat (extra).ToList (); -Assert.That (all.Count, Is.EqualTo (3), "Concat count"); -Assert.That (all [2].ToString (), Is.EqualTo ("c"), "Concat last"); -} - -[Test] -public void NSArray_ToList () -{ -using var arr = MakeArray ("a", "b", "c"); -var list = arr.ToList (); -Assert.That (list, Is.TypeOf> (), "ToList type"); -Assert.That (list.Count, Is.EqualTo (3), "ToList count"); -} - -[Test] -public void NSArray_ToArray () -{ -using var arr = MakeArray ("a", "b"); -var result = arr.ToArray (); -Assert.That (result, Is.TypeOf (), "ToArray type"); -Assert.That (result.Length, Is.EqualTo (2), "ToArray length"); -} - -[Test] -public void NSArray_Aggregate () -{ -using var arr = MakeArray ("a", "b", "c"); -var result = arr.Aggregate ((acc, s) => (NSString) (acc.ToString () + s.ToString ())); -Assert.That (result.ToString (), Is.EqualTo ("abc"), "Aggregate"); -} - -[Test] -public void NSArray_Aggregate_Seed () -{ -using var arr = MakeArray ("a", "b", "c"); -var result = arr.Aggregate ("", (acc, s) => acc + s.ToString ()); -Assert.That (result, Is.EqualTo ("abc"), "Aggregate seed"); -} - -// ===== NSMutableArray ===== - -[Test] -public void NSMutableArray_First () -{ -using var arr = MakeMutableArray ("a", "b"); -Assert.That (arr.First ().ToString (), Is.EqualTo ("a"), "First"); -} - -[Test] -public void NSMutableArray_First_Empty_Throws () -{ -using var arr = MakeMutableArray (); -Assert.Throws (() => arr.First ()); -} - -[Test] -public void NSMutableArray_FirstOrDefault_Empty () -{ -using var arr = MakeMutableArray (); -Assert.That (arr.FirstOrDefault (), Is.Null, "FirstOrDefault empty"); -} - -[Test] -public void NSMutableArray_FirstOrDefault () -{ -using var arr = MakeMutableArray ("x", "y"); -Assert.That (arr.FirstOrDefault ()?.ToString (), Is.EqualTo ("x"), "FirstOrDefault"); -} - -[Test] -public void NSMutableArray_Last () -{ -using var arr = MakeMutableArray ("a", "b", "c"); -Assert.That (arr.Last ().ToString (), Is.EqualTo ("c"), "Last"); -} - -[Test] -public void NSMutableArray_LastOrDefault_Empty () -{ -using var arr = MakeMutableArray (); -Assert.That (arr.LastOrDefault (), Is.Null, "LastOrDefault empty"); -} - -[Test] -public void NSMutableArray_Single () -{ -using var arr = MakeMutableArray ("only"); -Assert.That (arr.Single ().ToString (), Is.EqualTo ("only"), "Single"); -} - -[Test] -public void NSMutableArray_Single_Throws_OnMultiple () -{ -using var arr = MakeMutableArray ("a", "b"); -Assert.Throws (() => arr.Single ()); -} - -[Test] -public void NSMutableArray_SingleOrDefault_Empty () -{ -using var arr = MakeMutableArray (); -Assert.That (arr.SingleOrDefault (), Is.Null, "SingleOrDefault empty"); -} - -[Test] -public void NSMutableArray_ElementAt () -{ -using var arr = MakeMutableArray ("a", "b", "c"); -Assert.That (arr.ElementAt (1).ToString (), Is.EqualTo ("b"), "ElementAt 1"); -} - -[Test] -public void NSMutableArray_ElementAtOrDefault () -{ -using var arr = MakeMutableArray ("a"); -Assert.That (arr.ElementAtOrDefault (0)?.ToString (), Is.EqualTo ("a"), "ElementAtOrDefault in range"); -Assert.That (arr.ElementAtOrDefault (10), Is.Null, "ElementAtOrDefault out of range"); -} - -[Test] -public void NSMutableArray_Any () -{ -using var empty = MakeMutableArray (); -Assert.That (empty.Any (), Is.False, "Any empty"); -using var arr = MakeMutableArray ("a"); -Assert.That (arr.Any (), Is.True, "Any non-empty"); -} - -[Test] -public void NSMutableArray_All () -{ -using var arr = MakeMutableArray ("ab", "abc"); -Assert.That (arr.All (s => s.Length > 1), Is.True, "All true"); -} - -[Test] -public void NSMutableArray_Count () -{ -using var arr = MakeMutableArray ("a", "b", "c"); -Assert.That (arr.Count (), Is.EqualTo (3), "Count"); -} - -[Test] -public void NSMutableArray_LongCount () -{ -using var arr = MakeMutableArray ("a", "b"); -Assert.That (arr.LongCount (), Is.EqualTo (2L), "LongCount"); -} - -[Test] -public void NSMutableArray_Where () -{ -using var arr = MakeMutableArray ("a", "bb", "ccc"); -var result = arr.Where (s => s.Length > 1).ToList (); -Assert.That (result.Count, Is.EqualTo (2), "Where count"); -} - -[Test] -public void NSMutableArray_Select () -{ -using var arr = MakeMutableArray ("hello", "world"); -var lengths = arr.Select (s => s.Length).ToList (); -Assert.That (lengths [0], Is.EqualTo (5), "Select [0]"); -} - -[Test] -public void NSMutableArray_OrderBy () -{ -using var arr = MakeMutableArray ("banana", "apple", "cherry"); -var sorted = arr.OrderBy (s => s.ToString ()).ToList (); -Assert.That (sorted [0].ToString (), Is.EqualTo ("apple"), "OrderBy first"); -} - -[Test] -public void NSMutableArray_OrderByDescending () -{ -using var arr = MakeMutableArray ("banana", "apple", "cherry"); -var sorted = arr.OrderByDescending (s => s.ToString ()).ToList (); -Assert.That (sorted [0].ToString (), Is.EqualTo ("cherry"), "OrderByDesc first"); -} - -[Test] -public void NSMutableArray_Skip_Take () -{ -using var arr = MakeMutableArray ("a", "b", "c", "d"); -var sliced = arr.Skip (1).Take (2).ToList (); -Assert.That (sliced.Count, Is.EqualTo (2), "Skip/Take count"); -} - -[Test] -public void NSMutableArray_SkipWhile_TakeWhile () -{ -using var arr = MakeMutableArray ("a", "b", "c"); -var skipped = arr.SkipWhile (s => s.ToString () == "a").ToList (); -Assert.That (skipped.Count, Is.EqualTo (2), "SkipWhile count"); -var taken = arr.TakeWhile (s => s.ToString () != "c").ToList (); -Assert.That (taken.Count, Is.EqualTo (2), "TakeWhile count"); -} - -[Test] -public void NSMutableArray_Distinct () -{ -using var arr = MakeMutableArray ("a", "a", "b"); -var distinct = arr.Distinct ().ToList (); -Assert.That (distinct.Count, Is.EqualTo (2), "Distinct count"); -} - -[Test] -public void NSMutableArray_Reverse () -{ -using var arr = MakeMutableArray ("a", "b", "c"); -var reversed = arr.Reverse ().ToList (); -Assert.That (reversed [0].ToString (), Is.EqualTo ("c"), "Reverse [0]"); -} - -[Test] -public void NSMutableArray_Concat () -{ -using var arr = MakeMutableArray ("a"); -var all = arr.Concat (new [] { S ("b") }).ToList (); -Assert.That (all.Count, Is.EqualTo (2), "Concat count"); -} - -[Test] -public void NSMutableArray_ToList () -{ -using var arr = MakeMutableArray ("a", "b"); -var list = arr.ToList (); -Assert.That (list.Count, Is.EqualTo (2), "ToList count"); -} - -[Test] -public void NSMutableArray_ToArray () -{ -using var arr = MakeMutableArray ("a", "b"); -var result = arr.ToArray (); -Assert.That (result.Length, Is.EqualTo (2), "ToArray length"); -} - -[Test] -public void NSMutableArray_Aggregate () -{ -using var arr = MakeMutableArray ("a", "b", "c"); -var result = arr.Aggregate ((acc, s) => (NSString) (acc.ToString () + s.ToString ())); -Assert.That (result.ToString (), Is.EqualTo ("abc"), "Aggregate"); -} - -[Test] -public void NSMutableArray_Aggregate_Seed () -{ -using var arr = MakeMutableArray ("a", "b", "c"); -var result = arr.Aggregate (0, (acc, s) => acc + s.Length); -Assert.That (result, Is.EqualTo (3), "Aggregate seed"); -} - -// ===== NSOrderedSet ===== - -[Test] -public void NSOrderedSet_First () -{ -using var set = MakeOrderedSet ("a", "b", "c"); -Assert.That (set.First ().ToString (), Is.EqualTo ("a"), "First"); -} - -[Test] -public void NSOrderedSet_First_Predicate () -{ -using var set = MakeOrderedSet ("a", "b", "c"); -Assert.That (set.First (s => s.ToString () == "c").ToString (), Is.EqualTo ("c"), "First predicate"); -} - -[Test] -public void NSOrderedSet_First_Empty_Throws () -{ -using var set = MakeOrderedSet (); -Assert.Throws (() => set.First ()); -} - -[Test] -public void NSOrderedSet_FirstOrDefault_Empty () -{ -using var set = MakeOrderedSet (); -Assert.That (set.FirstOrDefault (), Is.Null, "FirstOrDefault empty"); -} - -[Test] -public void NSOrderedSet_FirstOrDefault () -{ -using var set = MakeOrderedSet ("x", "y"); -Assert.That (set.FirstOrDefault ()?.ToString (), Is.EqualTo ("x"), "FirstOrDefault"); -} - -[Test] -public void NSOrderedSet_Last () -{ -using var set = MakeOrderedSet ("a", "b", "c"); -Assert.That (set.Last ().ToString (), Is.EqualTo ("c"), "Last"); -} - -[Test] -public void NSOrderedSet_Last_Predicate () -{ -using var set = MakeOrderedSet ("a", "b", "c"); -Assert.That (set.Last (s => s.ToString () != "c").ToString (), Is.EqualTo ("b"), "Last predicate"); -} - -[Test] -public void NSOrderedSet_Last_Empty_Throws () -{ -using var set = MakeOrderedSet (); -Assert.Throws (() => set.Last ()); -} - -[Test] -public void NSOrderedSet_LastOrDefault_Empty () -{ -using var set = MakeOrderedSet (); -Assert.That (set.LastOrDefault (), Is.Null, "LastOrDefault empty"); -} - -[Test] -public void NSOrderedSet_Single () -{ -using var set = MakeOrderedSet ("only"); -Assert.That (set.Single ().ToString (), Is.EqualTo ("only"), "Single"); -} - -[Test] -public void NSOrderedSet_Single_Throws_OnMultiple () -{ -using var set = MakeOrderedSet ("a", "b"); -Assert.Throws (() => set.Single ()); -} - -[Test] -public void NSOrderedSet_SingleOrDefault_Empty () -{ -using var set = MakeOrderedSet (); -Assert.That (set.SingleOrDefault (), Is.Null, "SingleOrDefault empty"); -} - -[Test] -public void NSOrderedSet_SingleOrDefault_Predicate () -{ -using var set = MakeOrderedSet ("a", "b"); -Assert.That (set.SingleOrDefault (s => s.ToString () == "a")?.ToString (), Is.EqualTo ("a"), "SingleOrDefault predicate match"); -} - -[Test] -public void NSOrderedSet_ElementAt () -{ -using var set = MakeOrderedSet ("a", "b", "c"); -Assert.That (set.ElementAt (1).ToString (), Is.EqualTo ("b"), "ElementAt 1"); -} - -[Test] -public void NSOrderedSet_ElementAtOrDefault () -{ -using var set = MakeOrderedSet ("a"); -Assert.That (set.ElementAtOrDefault (0)?.ToString (), Is.EqualTo ("a"), "in range"); -Assert.That (set.ElementAtOrDefault (5), Is.Null, "out of range"); -} - -[Test] -public void NSOrderedSet_Any () -{ -using var empty = MakeOrderedSet (); -Assert.That (empty.Any (), Is.False, "Any empty"); -using var set = MakeOrderedSet ("a"); -Assert.That (set.Any (), Is.True, "Any non-empty"); -Assert.That (set.Any (s => s.ToString () == "a"), Is.True, "Any predicate true"); -Assert.That (set.Any (s => s.ToString () == "z"), Is.False, "Any predicate false"); -} - -[Test] -public void NSOrderedSet_All () -{ -using var set = MakeOrderedSet ("ab", "abc"); -Assert.That (set.All (s => s.Length > 1), Is.True, "All true"); -Assert.That (set.All (s => s.Length > 2), Is.False, "All false"); -} - -[Test] -public void NSOrderedSet_Count () -{ -using var set = MakeOrderedSet ("a", "b", "c"); -Assert.That (set.Count (), Is.EqualTo (3), "Count"); -Assert.That (set.Count (s => s.ToString () == "a"), Is.EqualTo (1), "Count predicate"); -} - -[Test] -public void NSOrderedSet_LongCount () -{ -using var set = MakeOrderedSet ("a", "b"); -Assert.That (set.LongCount (), Is.EqualTo (2L), "LongCount"); -} - -[Test] -public void NSOrderedSet_Where () -{ -using var set = MakeOrderedSet ("a", "bb", "ccc"); -var result = set.Where (s => s.Length > 1).ToList (); -Assert.That (result.Count, Is.EqualTo (2), "Where count"); -} - -[Test] -public void NSOrderedSet_Where_Index () -{ -using var set = MakeOrderedSet ("a", "b", "c"); -var result = set.Where ((s, i) => i % 2 == 0).ToList (); -Assert.That (result.Count, Is.EqualTo (2), "Where index count"); -} - -[Test] -public void NSOrderedSet_Select () -{ -using var set = MakeOrderedSet ("hello", "world"); -var lengths = set.Select (s => s.Length).ToList (); -Assert.That (lengths [0], Is.EqualTo (5), "Select [0]"); -} - -[Test] -public void NSOrderedSet_Select_Index () -{ -using var set = MakeOrderedSet ("a", "b"); -var indexed = set.Select ((s, i) => $"{i}:{s}").ToList (); -Assert.That (indexed [0], Is.EqualTo ("0:a"), "Select index 0"); -} - -[Test] -public void NSOrderedSet_OrderBy () -{ -using var set = MakeOrderedSet ("banana", "apple", "cherry"); -var sorted = set.OrderBy (s => s.ToString ()).ToList (); -Assert.That (sorted [0].ToString (), Is.EqualTo ("apple"), "OrderBy first"); -} - -[Test] -public void NSOrderedSet_OrderByDescending () -{ -using var set = MakeOrderedSet ("banana", "apple", "cherry"); -var sorted = set.OrderByDescending (s => s.ToString ()).ToList (); -Assert.That (sorted [0].ToString (), Is.EqualTo ("cherry"), "OrderByDesc first"); -} - -[Test] -public void NSOrderedSet_Skip_Take () -{ -using var set = MakeOrderedSet ("a", "b", "c", "d"); -var sliced = set.Skip (1).Take (2).ToList (); -Assert.That (sliced.Count, Is.EqualTo (2), "Skip/Take count"); -Assert.That (sliced [0].ToString (), Is.EqualTo ("b"), "Skip/Take [0]"); -} - -[Test] -public void NSOrderedSet_SkipWhile_TakeWhile () -{ -using var set = MakeOrderedSet ("a", "b", "c"); -var skipped = set.SkipWhile (s => s.ToString () == "a").ToList (); -Assert.That (skipped.Count, Is.EqualTo (2), "SkipWhile count"); -var taken = set.TakeWhile (s => s.ToString () != "c").ToList (); -Assert.That (taken.Count, Is.EqualTo (2), "TakeWhile count"); -} - -[Test] -public void NSOrderedSet_Distinct () -{ -using var set = MakeOrderedSet ("a", "b"); -var distinct = set.Distinct ().ToList (); -Assert.That (distinct.Count, Is.EqualTo (2), "Distinct count"); -} - -[Test] -public void NSOrderedSet_Reverse () -{ -using var set = MakeOrderedSet ("a", "b", "c"); -var reversed = set.Reverse ().ToList (); -Assert.That (reversed [0].ToString (), Is.EqualTo ("c"), "Reverse [0]"); -Assert.That (reversed [2].ToString (), Is.EqualTo ("a"), "Reverse [2]"); -} - -[Test] -public void NSOrderedSet_Concat () -{ -using var set = MakeOrderedSet ("a", "b"); -var all = set.Concat (new [] { S ("c") }).ToList (); -Assert.That (all.Count, Is.EqualTo (3), "Concat count"); -} - -[Test] -public void NSOrderedSet_ToList () -{ -using var set = MakeOrderedSet ("a", "b"); -var list = set.ToList (); -Assert.That (list.Count, Is.EqualTo (2), "ToList count"); -} - -[Test] -public void NSOrderedSet_ToArray () -{ -using var set = MakeOrderedSet ("a", "b"); -var arr = set.ToArray (); -Assert.That (arr.Length, Is.EqualTo (2), "ToArray length"); -} - -[Test] -public void NSOrderedSet_Aggregate () -{ -using var set = MakeOrderedSet ("a", "b", "c"); -var result = set.Aggregate ((acc, s) => (NSString) (acc.ToString () + s.ToString ())); -Assert.That (result.ToString (), Is.EqualTo ("abc"), "Aggregate"); -} - -[Test] -public void NSOrderedSet_Aggregate_Seed () -{ -using var set = MakeOrderedSet ("a", "b", "c"); -var result = set.Aggregate ("", (acc, s) => acc + s.ToString ()); -Assert.That (result, Is.EqualTo ("abc"), "Aggregate seed"); -} - -// ===== NSMutableOrderedSet ===== - -[Test] -public void NSMutableOrderedSet_First () -{ -using var set = MakeMutableOrderedSet ("a", "b", "c"); -Assert.That (set.First ().ToString (), Is.EqualTo ("a"), "First"); -} - -[Test] -public void NSMutableOrderedSet_First_Empty_Throws () -{ -using var set = MakeMutableOrderedSet (); -Assert.Throws (() => set.First ()); -} - -[Test] -public void NSMutableOrderedSet_FirstOrDefault_Empty () -{ -using var set = MakeMutableOrderedSet (); -Assert.That (set.FirstOrDefault (), Is.Null, "FirstOrDefault empty"); -} - -[Test] -public void NSMutableOrderedSet_FirstOrDefault () -{ -using var set = MakeMutableOrderedSet ("x", "y"); -Assert.That (set.FirstOrDefault ()?.ToString (), Is.EqualTo ("x"), "FirstOrDefault"); -} - -[Test] -public void NSMutableOrderedSet_FirstOrDefault_Predicate () -{ -using var set = MakeMutableOrderedSet ("a", "b", "c"); -Assert.That (set.FirstOrDefault (s => s.ToString () == "b")?.ToString (), Is.EqualTo ("b"), "FirstOrDefault predicate match"); -Assert.That (set.FirstOrDefault (s => s.ToString () == "z"), Is.Null, "FirstOrDefault predicate no match"); -} - -[Test] -public void NSMutableOrderedSet_Last () -{ -using var set = MakeMutableOrderedSet ("a", "b", "c"); -Assert.That (set.Last ().ToString (), Is.EqualTo ("c"), "Last"); -} - -[Test] -public void NSMutableOrderedSet_LastOrDefault_Empty () -{ -using var set = MakeMutableOrderedSet (); -Assert.That (set.LastOrDefault (), Is.Null, "LastOrDefault empty"); -} - -[Test] -public void NSMutableOrderedSet_Single () -{ -using var set = MakeMutableOrderedSet ("only"); -Assert.That (set.Single ().ToString (), Is.EqualTo ("only"), "Single"); -} - -[Test] -public void NSMutableOrderedSet_Single_Throws_OnMultiple () -{ -using var set = MakeMutableOrderedSet ("a", "b"); -Assert.Throws (() => set.Single ()); -} - -[Test] -public void NSMutableOrderedSet_SingleOrDefault_Empty () -{ -using var set = MakeMutableOrderedSet (); -Assert.That (set.SingleOrDefault (), Is.Null, "SingleOrDefault empty"); -} - -[Test] -public void NSMutableOrderedSet_ElementAt () -{ -using var set = MakeMutableOrderedSet ("a", "b", "c"); -Assert.That (set.ElementAt (2).ToString (), Is.EqualTo ("c"), "ElementAt 2"); -} - -[Test] -public void NSMutableOrderedSet_ElementAtOrDefault () -{ -using var set = MakeMutableOrderedSet ("a"); -Assert.That (set.ElementAtOrDefault (0)?.ToString (), Is.EqualTo ("a"), "in range"); -Assert.That (set.ElementAtOrDefault (5), Is.Null, "out of range"); -} - -[Test] -public void NSMutableOrderedSet_Any () -{ -using var empty = MakeMutableOrderedSet (); -Assert.That (empty.Any (), Is.False, "Any empty"); -using var set = MakeMutableOrderedSet ("a"); -Assert.That (set.Any (), Is.True, "Any non-empty"); -} - -[Test] -public void NSMutableOrderedSet_All () -{ -using var set = MakeMutableOrderedSet ("ab", "abc"); -Assert.That (set.All (s => s.Length > 1), Is.True, "All true"); -} - -[Test] -public void NSMutableOrderedSet_Count () -{ -using var set = MakeMutableOrderedSet ("a", "b", "c"); -Assert.That (set.Count (), Is.EqualTo (3), "Count"); -Assert.That (set.Count (s => s.ToString () == "a"), Is.EqualTo (1), "Count predicate"); -} - -[Test] -public void NSMutableOrderedSet_LongCount () -{ -using var set = MakeMutableOrderedSet ("a", "b"); -Assert.That (set.LongCount (), Is.EqualTo (2L), "LongCount"); -} - -[Test] -public void NSMutableOrderedSet_Where () -{ -using var set = MakeMutableOrderedSet ("a", "bb", "ccc"); -var result = set.Where (s => s.Length > 1).ToList (); -Assert.That (result.Count, Is.EqualTo (2), "Where count"); -} - -[Test] -public void NSMutableOrderedSet_Select () -{ -using var set = MakeMutableOrderedSet ("hello", "world"); -var lengths = set.Select (s => s.Length).ToList (); -Assert.That (lengths [0], Is.EqualTo (5), "Select [0]"); -} - -[Test] -public void NSMutableOrderedSet_OrderBy () -{ -using var set = MakeMutableOrderedSet ("banana", "apple", "cherry"); -var sorted = set.OrderBy (s => s.ToString ()).ToList (); -Assert.That (sorted [0].ToString (), Is.EqualTo ("apple"), "OrderBy first"); -} - -[Test] -public void NSMutableOrderedSet_OrderByDescending () -{ -using var set = MakeMutableOrderedSet ("banana", "apple", "cherry"); -var sorted = set.OrderByDescending (s => s.ToString ()).ToList (); -Assert.That (sorted [0].ToString (), Is.EqualTo ("cherry"), "OrderByDesc first"); -} - -[Test] -public void NSMutableOrderedSet_Skip_Take () -{ -using var set = MakeMutableOrderedSet ("a", "b", "c", "d"); -var sliced = set.Skip (1).Take (2).ToList (); -Assert.That (sliced.Count, Is.EqualTo (2), "Skip/Take count"); -Assert.That (sliced [0].ToString (), Is.EqualTo ("b"), "Skip/Take [0]"); -} - -[Test] -public void NSMutableOrderedSet_SkipWhile_TakeWhile () -{ -using var set = MakeMutableOrderedSet ("a", "b", "c"); -var skipped = set.SkipWhile (s => s.ToString () == "a").ToList (); -Assert.That (skipped.Count, Is.EqualTo (2), "SkipWhile count"); -var taken = set.TakeWhile (s => s.ToString () != "c").ToList (); -Assert.That (taken.Count, Is.EqualTo (2), "TakeWhile count"); -} - -[Test] -public void NSMutableOrderedSet_Distinct () -{ -using var set = MakeMutableOrderedSet ("a", "b"); -var distinct = set.Distinct ().ToList (); -Assert.That (distinct.Count, Is.EqualTo (2), "Distinct count"); -} - -[Test] -public void NSMutableOrderedSet_Reverse () -{ -using var set = MakeMutableOrderedSet ("a", "b", "c"); -var reversed = set.Reverse ().ToList (); -Assert.That (reversed [0].ToString (), Is.EqualTo ("c"), "Reverse [0]"); -Assert.That (reversed [2].ToString (), Is.EqualTo ("a"), "Reverse [2]"); -} - -[Test] -public void NSMutableOrderedSet_Concat () -{ -using var set = MakeMutableOrderedSet ("a", "b"); -var all = set.Concat (new [] { S ("c") }).ToList (); -Assert.That (all.Count, Is.EqualTo (3), "Concat count"); -} - -[Test] -public void NSMutableOrderedSet_ToList () -{ -using var set = MakeMutableOrderedSet ("a", "b"); -var list = set.ToList (); -Assert.That (list.Count, Is.EqualTo (2), "ToList count"); -} - -[Test] -public void NSMutableOrderedSet_ToArray () -{ -using var set = MakeMutableOrderedSet ("a", "b"); -var arr = set.ToArray (); -Assert.That (arr.Length, Is.EqualTo (2), "ToArray length"); -} - -[Test] -public void NSMutableOrderedSet_Aggregate () -{ -using var set = MakeMutableOrderedSet ("a", "b", "c"); -var result = set.Aggregate ((acc, s) => (NSString) (acc.ToString () + s.ToString ())); -Assert.That (result.ToString (), Is.EqualTo ("abc"), "Aggregate"); -} - -[Test] -public void NSMutableOrderedSet_Aggregate_Seed () -{ -using var set = MakeMutableOrderedSet ("a", "b", "c"); -var result = set.Aggregate ("", (acc, s) => acc + s.ToString ()); -Assert.That (result, Is.EqualTo ("abc"), "Aggregate seed"); -} -} + [TestFixture] + [Preserve (AllMembers = true)] + public class NSCollectionLinqTest { + + // ----- helpers ----- + + static NSString S (string s) => (NSString) s; + + static NSSet MakeSet (params string [] items) + { + return new NSSet (items.Select (S).ToArray ()); + } + + static NSMutableSet MakeMutableSet (params string [] items) + { + return new NSMutableSet (items.Select (S).ToArray ()); + } + + static NSArray MakeArray (params string [] items) + { + return NSArray.FromNSObjects (items.Select (S).ToArray ()); + } + + static NSMutableArray MakeMutableArray (params string [] items) + { + var arr = new NSMutableArray (); + foreach (var s in items) + arr.Add (S (s)); + return arr; + } + + static NSOrderedSet MakeOrderedSet (params string [] items) + { + return new NSOrderedSet (items.Select (S).ToArray ()); + } + + static NSMutableOrderedSet MakeMutableOrderedSet (params string [] items) + { + var set = new NSMutableOrderedSet (); + foreach (var s in items) + set.Add (S (s)); + return set; + } + + // ===== NSSet ===== + + [Test] + public void NSSet_First () + { + using var set = MakeSet ("a"); + var first = set.First (); + Assert.That (first.ToString (), Is.EqualTo ("a"), "First"); + } + + [Test] + public void NSSet_First_Predicate () + { + using var set = MakeSet ("a", "b", "c"); + var found = set.First (s => s.ToString () == "b"); + Assert.That (found.ToString (), Is.EqualTo ("b"), "First predicate"); + } + + [Test] + public void NSSet_First_Empty_Throws () + { + using var set = MakeSet (); + Assert.Throws (() => set.First ()); + } + + [Test] + public void NSSet_FirstOrDefault_Empty () + { + using var set = MakeSet (); + Assert.That (set.FirstOrDefault (), Is.Null, "FirstOrDefault empty"); + } + + [Test] + public void NSSet_FirstOrDefault () + { + using var set = MakeSet ("x"); + Assert.That (set.FirstOrDefault (), Is.Not.Null, "FirstOrDefault"); + } + + [Test] + public void NSSet_FirstOrDefault_Predicate_NoMatch () + { + using var set = MakeSet ("a", "b"); + Assert.That (set.FirstOrDefault (s => s.ToString () == "z"), Is.Null, "no match"); + } + + [Test] + public void NSSet_Last () + { + using var set = MakeSet ("a"); + var last = set.Last (); + Assert.That (last.ToString (), Is.EqualTo ("a"), "Last"); + } + + [Test] + public void NSSet_Last_Predicate () + { + using var set = MakeSet ("a", "b", "c"); + var found = set.Last (s => s.ToString () != "c"); + Assert.That (found, Is.Not.Null, "Last predicate not null"); + } + + [Test] + public void NSSet_Last_Empty_Throws () + { + using var set = MakeSet (); + Assert.Throws (() => set.Last ()); + } + + [Test] + public void NSSet_LastOrDefault_Empty () + { + using var set = MakeSet (); + Assert.That (set.LastOrDefault (), Is.Null, "LastOrDefault empty"); + } + + [Test] + public void NSSet_LastOrDefault_Predicate_NoMatch () + { + using var set = MakeSet ("a"); + Assert.That (set.LastOrDefault (s => s.ToString () == "z"), Is.Null, "LastOrDefault no match"); + } + + [Test] + public void NSSet_Single () + { + using var set = MakeSet ("only"); + Assert.That (set.Single ().ToString (), Is.EqualTo ("only"), "Single"); + } + + [Test] + public void NSSet_Single_Throws_OnMultiple () + { + using var set = MakeSet ("a", "b"); + Assert.Throws (() => set.Single ()); + } + + [Test] + public void NSSet_SingleOrDefault_Empty () + { + using var set = MakeSet (); + Assert.That (set.SingleOrDefault (), Is.Null, "SingleOrDefault empty"); + } + + [Test] + public void NSSet_SingleOrDefault_Predicate () + { + using var set = MakeSet ("a", "b"); + Assert.That (set.SingleOrDefault (s => s.ToString () == "a")?.ToString (), Is.EqualTo ("a"), "SingleOrDefault predicate"); + } + + [Test] + public void NSSet_Any_Empty () + { + using var set = MakeSet (); + Assert.That (set.Any (), Is.False, "Any empty"); + } + + [Test] + public void NSSet_Any_NonEmpty () + { + using var set = MakeSet ("a"); + Assert.That (set.Any (), Is.True, "Any non-empty"); + } + + [Test] + public void NSSet_Any_Predicate () + { + using var set = MakeSet ("a", "b"); + Assert.That (set.Any (s => s.ToString () == "b"), Is.True, "Any predicate true"); + Assert.That (set.Any (s => s.ToString () == "z"), Is.False, "Any predicate false"); + } + + [Test] + public void NSSet_All () + { + using var set = MakeSet ("ab", "abc"); + Assert.That (set.All (s => s.Length > 1), Is.True, "All true"); + Assert.That (set.All (s => s.Length > 2), Is.False, "All false"); + } + + [Test] + public void NSSet_Count () + { + using var set = MakeSet ("a", "b", "c"); + Assert.That (set.Count (), Is.EqualTo (3), "Count"); + Assert.That (set.Count (s => s.ToString () == "a"), Is.EqualTo (1), "Count predicate"); + } + + [Test] + public void NSSet_LongCount () + { + using var set = MakeSet ("a", "b"); + Assert.That (set.LongCount (), Is.EqualTo (2L), "LongCount"); + Assert.That (set.LongCount (s => s.ToString () == "a"), Is.EqualTo (1L), "LongCount predicate"); + } + + [Test] + public void NSSet_Where () + { + using var set = MakeSet ("a", "bb", "ccc"); + var result = set.Where (s => s.Length > 1).ToList (); + Assert.That (result.Count, Is.EqualTo (2), "Where count"); + } + + [Test] + public void NSSet_Where_Index () + { + using var arr = MakeOrderedSet ("a", "b", "c"); + var result = arr.Where ((s, i) => i % 2 == 0).ToList (); + Assert.That (result.Count, Is.EqualTo (2), "Where index count"); + } + + [Test] + public void NSSet_Select () + { + using var set = MakeSet ("hello"); + var lengths = set.Select (s => s.Length).ToList (); + Assert.That (lengths, Contains.Item (5), "Select length"); + } + + [Test] + public void NSSet_Select_Index () + { + using var arr = MakeOrderedSet ("a", "b", "c"); + var indexed = arr.Select ((s, i) => $"{i}:{s}").ToList (); + Assert.That (indexed [0], Is.EqualTo ("0:a"), "Select index 0"); + Assert.That (indexed [1], Is.EqualTo ("1:b"), "Select index 1"); + } + + [Test] + public void NSSet_OrderBy () + { + using var set = MakeSet ("banana", "apple", "cherry"); + var sorted = set.OrderBy (s => s.ToString ()).ToList (); + Assert.That (sorted [0].ToString (), Is.EqualTo ("apple"), "OrderBy first"); + Assert.That (sorted [2].ToString (), Is.EqualTo ("cherry"), "OrderBy last"); + } + + [Test] + public void NSSet_OrderByDescending () + { + using var set = MakeSet ("banana", "apple", "cherry"); + var sorted = set.OrderByDescending (s => s.ToString ()).ToList (); + Assert.That (sorted [0].ToString (), Is.EqualTo ("cherry"), "OrderByDesc first"); + } + + [Test] + public void NSSet_Distinct () + { + using var set = MakeSet ("a", "b", "b"); + // NSSet already ensures uniqueness, but verify Distinct works + var distinct = set.Distinct ().ToList (); + Assert.That (distinct.Count, Is.EqualTo (2), "Distinct count"); + } + + [Test] + public void NSSet_Reverse () + { + using var arr = MakeOrderedSet ("a", "b", "c"); + var reversed = arr.Reverse ().ToList (); + Assert.That (reversed [0].ToString (), Is.EqualTo ("c"), "Reverse first"); + Assert.That (reversed [2].ToString (), Is.EqualTo ("a"), "Reverse last"); + } + + [Test] + public void NSSet_Concat () + { + using var set = MakeSet ("a", "b"); + var extra = new [] { S ("c"), S ("d") }; + var all = set.Concat (extra).ToList (); + Assert.That (all.Count, Is.EqualTo (4), "Concat count"); + } + + [Test] + public void NSSet_Skip_Take () + { + using var arr = MakeOrderedSet ("a", "b", "c", "d"); + var sliced = arr.Skip (1).Take (2).ToList (); + Assert.That (sliced.Count, Is.EqualTo (2), "Skip/Take count"); + Assert.That (sliced [0].ToString (), Is.EqualTo ("b"), "Skip/Take first"); + } + + [Test] + public void NSSet_SkipWhile_TakeWhile () + { + using var arr = MakeOrderedSet ("a", "b", "c"); + var skipped = arr.SkipWhile (s => s.ToString () == "a").ToList (); + Assert.That (skipped.Count, Is.EqualTo (2), "SkipWhile count"); + + var taken = arr.TakeWhile (s => s.ToString () != "c").ToList (); + Assert.That (taken.Count, Is.EqualTo (2), "TakeWhile count"); + } + + [Test] + public void NSSet_ElementAt () + { + using var arr = MakeOrderedSet ("a", "b", "c"); + Assert.That (arr.ElementAt (1).ToString (), Is.EqualTo ("b"), "ElementAt"); + } + + [Test] + public void NSSet_ElementAtOrDefault () + { + using var arr = MakeOrderedSet ("a", "b"); + Assert.That (arr.ElementAtOrDefault (0), Is.Not.Null, "ElementAtOrDefault in range"); + Assert.That (arr.ElementAtOrDefault (99), Is.Null, "ElementAtOrDefault out of range"); + } + + [Test] + public void NSSet_ToList () + { + using var set = MakeSet ("a", "b"); + var list = set.ToList (); + Assert.That (list, Is.TypeOf> (), "ToList type"); + Assert.That (list.Count, Is.EqualTo (2), "ToList count"); + } + + [Test] + public void NSSet_ToArray () + { + using var set = MakeSet ("a", "b"); + var arr = set.ToArray (); + Assert.That (arr, Is.TypeOf (), "ToArray type"); + Assert.That (arr.Length, Is.EqualTo (2), "ToArray length"); + } + + [Test] + public void NSSet_Aggregate () + { + using var arr = MakeOrderedSet ("a", "b", "c"); + var result = arr.Aggregate ((acc, s) => (NSString) (acc.ToString () + s.ToString ())); + Assert.That (result.ToString (), Is.EqualTo ("abc"), "Aggregate"); + } + + [Test] + public void NSSet_Aggregate_Seed () + { + using var arr = MakeOrderedSet ("a", "b", "c"); + var result = arr.Aggregate ("", (acc, s) => acc + s.ToString ()); + Assert.That (result, Is.EqualTo ("abc"), "Aggregate seed"); + } + + // ===== NSMutableSet ===== + + [Test] + public void NSMutableSet_First () + { + using var set = MakeMutableSet ("a"); + Assert.That (set.First ().ToString (), Is.EqualTo ("a"), "First"); + } + + [Test] + public void NSMutableSet_FirstOrDefault_Empty () + { + using var set = MakeMutableSet (); + Assert.That (set.FirstOrDefault (), Is.Null, "FirstOrDefault empty"); + } + + [Test] + public void NSMutableSet_Last () + { + using var set = MakeMutableSet ("a"); + Assert.That (set.Last ().ToString (), Is.EqualTo ("a"), "Last"); + } + + [Test] + public void NSMutableSet_LastOrDefault_Empty () + { + using var set = MakeMutableSet (); + Assert.That (set.LastOrDefault (), Is.Null, "LastOrDefault empty"); + } + + [Test] + public void NSMutableSet_Single () + { + using var set = MakeMutableSet ("only"); + Assert.That (set.Single ().ToString (), Is.EqualTo ("only"), "Single"); + } + + [Test] + public void NSMutableSet_SingleOrDefault_Empty () + { + using var set = MakeMutableSet (); + Assert.That (set.SingleOrDefault (), Is.Null, "SingleOrDefault empty"); + } + + [Test] + public void NSMutableSet_Any () + { + using var set = MakeMutableSet (); + Assert.That (set.Any (), Is.False, "Any empty"); + using var set2 = MakeMutableSet ("a"); + Assert.That (set2.Any (), Is.True, "Any non-empty"); + } + + [Test] + public void NSMutableSet_All () + { + using var set = MakeMutableSet ("ab", "abc"); + Assert.That (set.All (s => s.Length > 1), Is.True, "All true"); + } + + [Test] + public void NSMutableSet_Count () + { + using var set = MakeMutableSet ("a", "b", "c"); + Assert.That (set.Count (), Is.EqualTo (3), "Count"); + } + + [Test] + public void NSMutableSet_LongCount () + { + using var set = MakeMutableSet ("a", "b"); + Assert.That (set.LongCount (), Is.EqualTo (2L), "LongCount"); + } + + [Test] + public void NSMutableSet_Where () + { + using var set = MakeMutableSet ("a", "bb", "ccc"); + var result = set.Where (s => s.Length > 1).ToList (); + Assert.That (result.Count, Is.EqualTo (2), "Where count"); + } + + [Test] + public void NSMutableSet_Select () + { + using var set = MakeMutableSet ("hello"); + var lengths = set.Select (s => s.Length).ToList (); + Assert.That (lengths, Contains.Item (5), "Select length"); + } + + [Test] + public void NSMutableSet_OrderBy () + { + using var set = MakeMutableSet ("banana", "apple", "cherry"); + var sorted = set.OrderBy (s => s.ToString ()).ToList (); + Assert.That (sorted [0].ToString (), Is.EqualTo ("apple"), "OrderBy first"); + } + + [Test] + public void NSMutableSet_Skip_Take () + { + using var arr = MakeOrderedSet ("a", "b", "c", "d"); + var sliced = arr.Skip (1).Take (2).ToList (); + Assert.That (sliced.Count, Is.EqualTo (2), "Skip/Take count"); + } + + [Test] + public void NSMutableSet_ToList () + { + using var set = MakeMutableSet ("a", "b"); + var list = set.ToList (); + Assert.That (list.Count, Is.EqualTo (2), "ToList count"); + } + + [Test] + public void NSMutableSet_ToArray () + { + using var set = MakeMutableSet ("a", "b"); + var arr = set.ToArray (); + Assert.That (arr.Length, Is.EqualTo (2), "ToArray length"); + } + + [Test] + public void NSMutableSet_Aggregate () + { + using var set = MakeMutableSet ("a"); + var result = set.Aggregate ((acc, s) => (NSString) (acc.ToString () + s.ToString ())); + Assert.That (result.ToString (), Is.EqualTo ("a"), "Aggregate"); + } + + // ===== NSArray ===== + + [Test] + public void NSArray_First () + { + using var arr = MakeArray ("a", "b", "c"); + Assert.That (arr.First ().ToString (), Is.EqualTo ("a"), "First"); + } + + [Test] + public void NSArray_First_Predicate () + { + using var arr = MakeArray ("a", "b", "c"); + Assert.That (arr.First (s => s.ToString () == "b").ToString (), Is.EqualTo ("b"), "First predicate"); + } + + [Test] + public void NSArray_First_Empty_Throws () + { + using var arr = MakeArray (); + Assert.Throws (() => arr.First ()); + } + + [Test] + public void NSArray_FirstOrDefault_Empty () + { + using var arr = MakeArray (); + Assert.That (arr.FirstOrDefault (), Is.Null, "FirstOrDefault empty"); + } + + [Test] + public void NSArray_FirstOrDefault () + { + using var arr = MakeArray ("x", "y"); + Assert.That (arr.FirstOrDefault ()?.ToString (), Is.EqualTo ("x"), "FirstOrDefault"); + } + + [Test] + public void NSArray_FirstOrDefault_Predicate () + { + using var arr = MakeArray ("a", "b", "c"); + Assert.That (arr.FirstOrDefault (s => s.ToString () == "b")?.ToString (), Is.EqualTo ("b"), "FirstOrDefault predicate match"); + Assert.That (arr.FirstOrDefault (s => s.ToString () == "z"), Is.Null, "FirstOrDefault predicate no match"); + } + + [Test] + public void NSArray_Last () + { + using var arr = MakeArray ("a", "b", "c"); + Assert.That (arr.Last ().ToString (), Is.EqualTo ("c"), "Last"); + } + + [Test] + public void NSArray_Last_Predicate () + { + using var arr = MakeArray ("a", "b", "c"); + Assert.That (arr.Last (s => s.ToString () != "c").ToString (), Is.EqualTo ("b"), "Last predicate"); + } + + [Test] + public void NSArray_Last_Empty_Throws () + { + using var arr = MakeArray (); + Assert.Throws (() => arr.Last ()); + } + + [Test] + public void NSArray_LastOrDefault_Empty () + { + using var arr = MakeArray (); + Assert.That (arr.LastOrDefault (), Is.Null, "LastOrDefault empty"); + } + + [Test] + public void NSArray_LastOrDefault_Predicate_NoMatch () + { + using var arr = MakeArray ("a", "b"); + Assert.That (arr.LastOrDefault (s => s.ToString () == "z"), Is.Null, "LastOrDefault no match"); + } + + [Test] + public void NSArray_Single () + { + using var arr = MakeArray ("only"); + Assert.That (arr.Single ().ToString (), Is.EqualTo ("only"), "Single"); + } + + [Test] + public void NSArray_Single_Throws_OnEmpty () + { + using var arr = MakeArray (); + Assert.Throws (() => arr.Single ()); + } + + [Test] + public void NSArray_Single_Throws_OnMultiple () + { + using var arr = MakeArray ("a", "b"); + Assert.Throws (() => arr.Single ()); + } + + [Test] + public void NSArray_SingleOrDefault_Empty () + { + using var arr = MakeArray (); + Assert.That (arr.SingleOrDefault (), Is.Null, "SingleOrDefault empty"); + } + + [Test] + public void NSArray_SingleOrDefault_Predicate () + { + using var arr = MakeArray ("a", "b"); + Assert.That (arr.SingleOrDefault (s => s.ToString () == "a")?.ToString (), Is.EqualTo ("a"), "SingleOrDefault predicate match"); + Assert.That (arr.SingleOrDefault (s => s.ToString () == "z"), Is.Null, "SingleOrDefault predicate no match"); + } + + [Test] + public void NSArray_ElementAt () + { + using var arr = MakeArray ("a", "b", "c"); + Assert.That (arr.ElementAt (0).ToString (), Is.EqualTo ("a"), "ElementAt 0"); + Assert.That (arr.ElementAt (2).ToString (), Is.EqualTo ("c"), "ElementAt 2"); + } + + [Test] + public void NSArray_ElementAt_OutOfRange_Throws () + { + using var arr = MakeArray ("a"); + Assert.Throws (() => arr.ElementAt (5)); + } + + [Test] + public void NSArray_ElementAtOrDefault () + { + using var arr = MakeArray ("a", "b"); + Assert.That (arr.ElementAtOrDefault (1)?.ToString (), Is.EqualTo ("b"), "ElementAtOrDefault in range"); + Assert.That (arr.ElementAtOrDefault (99), Is.Null, "ElementAtOrDefault out of range"); + } + + [Test] + public void NSArray_Any () + { + using var empty = MakeArray (); + Assert.That (empty.Any (), Is.False, "Any empty"); + using var arr = MakeArray ("a"); + Assert.That (arr.Any (), Is.True, "Any non-empty"); + Assert.That (arr.Any (s => s.ToString () == "a"), Is.True, "Any predicate true"); + Assert.That (arr.Any (s => s.ToString () == "z"), Is.False, "Any predicate false"); + } + + [Test] + public void NSArray_All () + { + using var arr = MakeArray ("ab", "abc"); + Assert.That (arr.All (s => s.Length > 1), Is.True, "All true"); + Assert.That (arr.All (s => s.Length > 2), Is.False, "All false"); + } + + [Test] + public void NSArray_Count () + { + using var arr = MakeArray ("a", "b", "c"); + Assert.That (arr.Count (), Is.EqualTo (3), "Count"); + Assert.That (arr.Count (s => s.ToString () == "a"), Is.EqualTo (1), "Count predicate"); + } + + [Test] + public void NSArray_LongCount () + { + using var arr = MakeArray ("a", "b"); + Assert.That (arr.LongCount (), Is.EqualTo (2L), "LongCount"); + Assert.That (arr.LongCount (s => s.ToString () == "a"), Is.EqualTo (1L), "LongCount predicate"); + } + + [Test] + public void NSArray_Where () + { + using var arr = MakeArray ("a", "bb", "ccc"); + var result = arr.Where (s => s.Length > 1).ToList (); + Assert.That (result.Count, Is.EqualTo (2), "Where count"); + } + + [Test] + public void NSArray_Where_Index () + { + using var arr = MakeArray ("a", "b", "c"); + var result = arr.Where ((s, i) => i % 2 == 0).ToList (); + Assert.That (result.Count, Is.EqualTo (2), "Where index count"); + Assert.That (result [0].ToString (), Is.EqualTo ("a"), "Where index [0]"); + Assert.That (result [1].ToString (), Is.EqualTo ("c"), "Where index [1]"); + } + + [Test] + public void NSArray_Select () + { + using var arr = MakeArray ("hello", "world"); + var lengths = arr.Select (s => s.Length).ToList (); + Assert.That (lengths [0], Is.EqualTo (5), "Select length [0]"); + Assert.That (lengths [1], Is.EqualTo (5), "Select length [1]"); + } + + [Test] + public void NSArray_Select_Index () + { + using var arr = MakeArray ("a", "b", "c"); + var indexed = arr.Select ((s, i) => $"{i}:{s}").ToList (); + Assert.That (indexed [0], Is.EqualTo ("0:a"), "Select index 0"); + Assert.That (indexed [2], Is.EqualTo ("2:c"), "Select index 2"); + } + + [Test] + public void NSArray_OrderBy () + { + using var arr = MakeArray ("banana", "apple", "cherry"); + var sorted = arr.OrderBy (s => s.ToString ()).ToList (); + Assert.That (sorted [0].ToString (), Is.EqualTo ("apple"), "OrderBy first"); + Assert.That (sorted [1].ToString (), Is.EqualTo ("banana"), "OrderBy second"); + Assert.That (sorted [2].ToString (), Is.EqualTo ("cherry"), "OrderBy third"); + } + + [Test] + public void NSArray_OrderByDescending () + { + using var arr = MakeArray ("banana", "apple", "cherry"); + var sorted = arr.OrderByDescending (s => s.ToString ()).ToList (); + Assert.That (sorted [0].ToString (), Is.EqualTo ("cherry"), "OrderByDesc first"); + Assert.That (sorted [2].ToString (), Is.EqualTo ("apple"), "OrderByDesc last"); + } + + [Test] + public void NSArray_Skip () + { + using var arr = MakeArray ("a", "b", "c", "d"); + var skipped = arr.Skip (2).ToList (); + Assert.That (skipped.Count, Is.EqualTo (2), "Skip count"); + Assert.That (skipped [0].ToString (), Is.EqualTo ("c"), "Skip [0]"); + } + + [Test] + public void NSArray_SkipWhile () + { + using var arr = MakeArray ("a", "b", "c"); + var result = arr.SkipWhile (s => s.ToString () != "b").ToList (); + Assert.That (result.Count, Is.EqualTo (2), "SkipWhile count"); + Assert.That (result [0].ToString (), Is.EqualTo ("b"), "SkipWhile first"); + } + + [Test] + public void NSArray_Take () + { + using var arr = MakeArray ("a", "b", "c"); + var taken = arr.Take (2).ToList (); + Assert.That (taken.Count, Is.EqualTo (2), "Take count"); + Assert.That (taken [1].ToString (), Is.EqualTo ("b"), "Take [1]"); + } + + [Test] + public void NSArray_TakeWhile () + { + using var arr = MakeArray ("a", "b", "c"); + var taken = arr.TakeWhile (s => s.ToString () != "c").ToList (); + Assert.That (taken.Count, Is.EqualTo (2), "TakeWhile count"); + } + + [Test] + public void NSArray_Distinct () + { + using var arr = MakeArray ("a", "a", "b"); + var distinct = arr.Distinct ().ToList (); + Assert.That (distinct.Count, Is.EqualTo (2), "Distinct count"); + } + + [Test] + public void NSArray_Reverse () + { + using var arr = MakeArray ("a", "b", "c"); + var reversed = arr.Reverse ().ToList (); + Assert.That (reversed [0].ToString (), Is.EqualTo ("c"), "Reverse [0]"); + Assert.That (reversed [2].ToString (), Is.EqualTo ("a"), "Reverse [2]"); + } + + [Test] + public void NSArray_Concat () + { + using var arr = MakeArray ("a", "b"); + var extra = new [] { S ("c") }; + var all = arr.Concat (extra).ToList (); + Assert.That (all.Count, Is.EqualTo (3), "Concat count"); + Assert.That (all [2].ToString (), Is.EqualTo ("c"), "Concat last"); + } + + [Test] + public void NSArray_ToList () + { + using var arr = MakeArray ("a", "b", "c"); + var list = arr.ToList (); + Assert.That (list, Is.TypeOf> (), "ToList type"); + Assert.That (list.Count, Is.EqualTo (3), "ToList count"); + } + + [Test] + public void NSArray_ToArray () + { + using var arr = MakeArray ("a", "b"); + var result = arr.ToArray (); + Assert.That (result, Is.TypeOf (), "ToArray type"); + Assert.That (result.Length, Is.EqualTo (2), "ToArray length"); + } + + [Test] + public void NSArray_Aggregate () + { + using var arr = MakeArray ("a", "b", "c"); + var result = arr.Aggregate ((acc, s) => (NSString) (acc.ToString () + s.ToString ())); + Assert.That (result.ToString (), Is.EqualTo ("abc"), "Aggregate"); + } + + [Test] + public void NSArray_Aggregate_Seed () + { + using var arr = MakeArray ("a", "b", "c"); + var result = arr.Aggregate ("", (acc, s) => acc + s.ToString ()); + Assert.That (result, Is.EqualTo ("abc"), "Aggregate seed"); + } + + // ===== NSMutableArray ===== + + [Test] + public void NSMutableArray_First () + { + using var arr = MakeMutableArray ("a", "b"); + Assert.That (arr.First ().ToString (), Is.EqualTo ("a"), "First"); + } + + [Test] + public void NSMutableArray_First_Empty_Throws () + { + using var arr = MakeMutableArray (); + Assert.Throws (() => arr.First ()); + } + + [Test] + public void NSMutableArray_FirstOrDefault_Empty () + { + using var arr = MakeMutableArray (); + Assert.That (arr.FirstOrDefault (), Is.Null, "FirstOrDefault empty"); + } + + [Test] + public void NSMutableArray_FirstOrDefault () + { + using var arr = MakeMutableArray ("x", "y"); + Assert.That (arr.FirstOrDefault ()?.ToString (), Is.EqualTo ("x"), "FirstOrDefault"); + } + + [Test] + public void NSMutableArray_Last () + { + using var arr = MakeMutableArray ("a", "b", "c"); + Assert.That (arr.Last ().ToString (), Is.EqualTo ("c"), "Last"); + } + + [Test] + public void NSMutableArray_LastOrDefault_Empty () + { + using var arr = MakeMutableArray (); + Assert.That (arr.LastOrDefault (), Is.Null, "LastOrDefault empty"); + } + + [Test] + public void NSMutableArray_Single () + { + using var arr = MakeMutableArray ("only"); + Assert.That (arr.Single ().ToString (), Is.EqualTo ("only"), "Single"); + } + + [Test] + public void NSMutableArray_Single_Throws_OnMultiple () + { + using var arr = MakeMutableArray ("a", "b"); + Assert.Throws (() => arr.Single ()); + } + + [Test] + public void NSMutableArray_SingleOrDefault_Empty () + { + using var arr = MakeMutableArray (); + Assert.That (arr.SingleOrDefault (), Is.Null, "SingleOrDefault empty"); + } + + [Test] + public void NSMutableArray_ElementAt () + { + using var arr = MakeMutableArray ("a", "b", "c"); + Assert.That (arr.ElementAt (1).ToString (), Is.EqualTo ("b"), "ElementAt 1"); + } + + [Test] + public void NSMutableArray_ElementAtOrDefault () + { + using var arr = MakeMutableArray ("a"); + Assert.That (arr.ElementAtOrDefault (0)?.ToString (), Is.EqualTo ("a"), "ElementAtOrDefault in range"); + Assert.That (arr.ElementAtOrDefault (10), Is.Null, "ElementAtOrDefault out of range"); + } + + [Test] + public void NSMutableArray_Any () + { + using var empty = MakeMutableArray (); + Assert.That (empty.Any (), Is.False, "Any empty"); + using var arr = MakeMutableArray ("a"); + Assert.That (arr.Any (), Is.True, "Any non-empty"); + } + + [Test] + public void NSMutableArray_All () + { + using var arr = MakeMutableArray ("ab", "abc"); + Assert.That (arr.All (s => s.Length > 1), Is.True, "All true"); + } + + [Test] + public void NSMutableArray_Count () + { + using var arr = MakeMutableArray ("a", "b", "c"); + Assert.That (arr.Count (), Is.EqualTo (3), "Count"); + } + + [Test] + public void NSMutableArray_LongCount () + { + using var arr = MakeMutableArray ("a", "b"); + Assert.That (arr.LongCount (), Is.EqualTo (2L), "LongCount"); + } + + [Test] + public void NSMutableArray_Where () + { + using var arr = MakeMutableArray ("a", "bb", "ccc"); + var result = arr.Where (s => s.Length > 1).ToList (); + Assert.That (result.Count, Is.EqualTo (2), "Where count"); + } + + [Test] + public void NSMutableArray_Select () + { + using var arr = MakeMutableArray ("hello", "world"); + var lengths = arr.Select (s => s.Length).ToList (); + Assert.That (lengths [0], Is.EqualTo (5), "Select [0]"); + } + + [Test] + public void NSMutableArray_OrderBy () + { + using var arr = MakeMutableArray ("banana", "apple", "cherry"); + var sorted = arr.OrderBy (s => s.ToString ()).ToList (); + Assert.That (sorted [0].ToString (), Is.EqualTo ("apple"), "OrderBy first"); + } + + [Test] + public void NSMutableArray_OrderByDescending () + { + using var arr = MakeMutableArray ("banana", "apple", "cherry"); + var sorted = arr.OrderByDescending (s => s.ToString ()).ToList (); + Assert.That (sorted [0].ToString (), Is.EqualTo ("cherry"), "OrderByDesc first"); + } + + [Test] + public void NSMutableArray_Skip_Take () + { + using var arr = MakeMutableArray ("a", "b", "c", "d"); + var sliced = arr.Skip (1).Take (2).ToList (); + Assert.That (sliced.Count, Is.EqualTo (2), "Skip/Take count"); + } + + [Test] + public void NSMutableArray_SkipWhile_TakeWhile () + { + using var arr = MakeMutableArray ("a", "b", "c"); + var skipped = arr.SkipWhile (s => s.ToString () == "a").ToList (); + Assert.That (skipped.Count, Is.EqualTo (2), "SkipWhile count"); + var taken = arr.TakeWhile (s => s.ToString () != "c").ToList (); + Assert.That (taken.Count, Is.EqualTo (2), "TakeWhile count"); + } + + [Test] + public void NSMutableArray_Distinct () + { + using var arr = MakeMutableArray ("a", "a", "b"); + var distinct = arr.Distinct ().ToList (); + Assert.That (distinct.Count, Is.EqualTo (2), "Distinct count"); + } + + [Test] + public void NSMutableArray_Reverse () + { + using var arr = MakeMutableArray ("a", "b", "c"); + var reversed = arr.Reverse ().ToList (); + Assert.That (reversed [0].ToString (), Is.EqualTo ("c"), "Reverse [0]"); + } + + [Test] + public void NSMutableArray_Concat () + { + using var arr = MakeMutableArray ("a"); + var all = arr.Concat (new [] { S ("b") }).ToList (); + Assert.That (all.Count, Is.EqualTo (2), "Concat count"); + } + + [Test] + public void NSMutableArray_ToList () + { + using var arr = MakeMutableArray ("a", "b"); + var list = arr.ToList (); + Assert.That (list.Count, Is.EqualTo (2), "ToList count"); + } + + [Test] + public void NSMutableArray_ToArray () + { + using var arr = MakeMutableArray ("a", "b"); + var result = arr.ToArray (); + Assert.That (result.Length, Is.EqualTo (2), "ToArray length"); + } + + [Test] + public void NSMutableArray_Aggregate () + { + using var arr = MakeMutableArray ("a", "b", "c"); + var result = arr.Aggregate ((acc, s) => (NSString) (acc.ToString () + s.ToString ())); + Assert.That (result.ToString (), Is.EqualTo ("abc"), "Aggregate"); + } + + [Test] + public void NSMutableArray_Aggregate_Seed () + { + using var arr = MakeMutableArray ("a", "b", "c"); + var result = arr.Aggregate (0, (acc, s) => acc + s.Length); + Assert.That (result, Is.EqualTo (3), "Aggregate seed"); + } + + // ===== NSOrderedSet ===== + + [Test] + public void NSOrderedSet_First () + { + using var set = MakeOrderedSet ("a", "b", "c"); + Assert.That (set.First ().ToString (), Is.EqualTo ("a"), "First"); + } + + [Test] + public void NSOrderedSet_First_Predicate () + { + using var set = MakeOrderedSet ("a", "b", "c"); + Assert.That (set.First (s => s.ToString () == "c").ToString (), Is.EqualTo ("c"), "First predicate"); + } + + [Test] + public void NSOrderedSet_First_Empty_Throws () + { + using var set = MakeOrderedSet (); + Assert.Throws (() => set.First ()); + } + + [Test] + public void NSOrderedSet_FirstOrDefault_Empty () + { + using var set = MakeOrderedSet (); + Assert.That (set.FirstOrDefault (), Is.Null, "FirstOrDefault empty"); + } + + [Test] + public void NSOrderedSet_FirstOrDefault () + { + using var set = MakeOrderedSet ("x", "y"); + Assert.That (set.FirstOrDefault ()?.ToString (), Is.EqualTo ("x"), "FirstOrDefault"); + } + + [Test] + public void NSOrderedSet_Last () + { + using var set = MakeOrderedSet ("a", "b", "c"); + Assert.That (set.Last ().ToString (), Is.EqualTo ("c"), "Last"); + } + + [Test] + public void NSOrderedSet_Last_Predicate () + { + using var set = MakeOrderedSet ("a", "b", "c"); + Assert.That (set.Last (s => s.ToString () != "c").ToString (), Is.EqualTo ("b"), "Last predicate"); + } + + [Test] + public void NSOrderedSet_Last_Empty_Throws () + { + using var set = MakeOrderedSet (); + Assert.Throws (() => set.Last ()); + } + + [Test] + public void NSOrderedSet_LastOrDefault_Empty () + { + using var set = MakeOrderedSet (); + Assert.That (set.LastOrDefault (), Is.Null, "LastOrDefault empty"); + } + + [Test] + public void NSOrderedSet_Single () + { + using var set = MakeOrderedSet ("only"); + Assert.That (set.Single ().ToString (), Is.EqualTo ("only"), "Single"); + } + + [Test] + public void NSOrderedSet_Single_Throws_OnMultiple () + { + using var set = MakeOrderedSet ("a", "b"); + Assert.Throws (() => set.Single ()); + } + + [Test] + public void NSOrderedSet_SingleOrDefault_Empty () + { + using var set = MakeOrderedSet (); + Assert.That (set.SingleOrDefault (), Is.Null, "SingleOrDefault empty"); + } + + [Test] + public void NSOrderedSet_SingleOrDefault_Predicate () + { + using var set = MakeOrderedSet ("a", "b"); + Assert.That (set.SingleOrDefault (s => s.ToString () == "a")?.ToString (), Is.EqualTo ("a"), "SingleOrDefault predicate match"); + } + + [Test] + public void NSOrderedSet_ElementAt () + { + using var set = MakeOrderedSet ("a", "b", "c"); + Assert.That (set.ElementAt (1).ToString (), Is.EqualTo ("b"), "ElementAt 1"); + } + + [Test] + public void NSOrderedSet_ElementAtOrDefault () + { + using var set = MakeOrderedSet ("a"); + Assert.That (set.ElementAtOrDefault (0)?.ToString (), Is.EqualTo ("a"), "in range"); + Assert.That (set.ElementAtOrDefault (5), Is.Null, "out of range"); + } + + [Test] + public void NSOrderedSet_Any () + { + using var empty = MakeOrderedSet (); + Assert.That (empty.Any (), Is.False, "Any empty"); + using var set = MakeOrderedSet ("a"); + Assert.That (set.Any (), Is.True, "Any non-empty"); + Assert.That (set.Any (s => s.ToString () == "a"), Is.True, "Any predicate true"); + Assert.That (set.Any (s => s.ToString () == "z"), Is.False, "Any predicate false"); + } + + [Test] + public void NSOrderedSet_All () + { + using var set = MakeOrderedSet ("ab", "abc"); + Assert.That (set.All (s => s.Length > 1), Is.True, "All true"); + Assert.That (set.All (s => s.Length > 2), Is.False, "All false"); + } + + [Test] + public void NSOrderedSet_Count () + { + using var set = MakeOrderedSet ("a", "b", "c"); + Assert.That (set.Count (), Is.EqualTo (3), "Count"); + Assert.That (set.Count (s => s.ToString () == "a"), Is.EqualTo (1), "Count predicate"); + } + + [Test] + public void NSOrderedSet_LongCount () + { + using var set = MakeOrderedSet ("a", "b"); + Assert.That (set.LongCount (), Is.EqualTo (2L), "LongCount"); + } + + [Test] + public void NSOrderedSet_Where () + { + using var set = MakeOrderedSet ("a", "bb", "ccc"); + var result = set.Where (s => s.Length > 1).ToList (); + Assert.That (result.Count, Is.EqualTo (2), "Where count"); + } + + [Test] + public void NSOrderedSet_Where_Index () + { + using var set = MakeOrderedSet ("a", "b", "c"); + var result = set.Where ((s, i) => i % 2 == 0).ToList (); + Assert.That (result.Count, Is.EqualTo (2), "Where index count"); + } + + [Test] + public void NSOrderedSet_Select () + { + using var set = MakeOrderedSet ("hello", "world"); + var lengths = set.Select (s => s.Length).ToList (); + Assert.That (lengths [0], Is.EqualTo (5), "Select [0]"); + } + + [Test] + public void NSOrderedSet_Select_Index () + { + using var set = MakeOrderedSet ("a", "b"); + var indexed = set.Select ((s, i) => $"{i}:{s}").ToList (); + Assert.That (indexed [0], Is.EqualTo ("0:a"), "Select index 0"); + } + + [Test] + public void NSOrderedSet_OrderBy () + { + using var set = MakeOrderedSet ("banana", "apple", "cherry"); + var sorted = set.OrderBy (s => s.ToString ()).ToList (); + Assert.That (sorted [0].ToString (), Is.EqualTo ("apple"), "OrderBy first"); + } + + [Test] + public void NSOrderedSet_OrderByDescending () + { + using var set = MakeOrderedSet ("banana", "apple", "cherry"); + var sorted = set.OrderByDescending (s => s.ToString ()).ToList (); + Assert.That (sorted [0].ToString (), Is.EqualTo ("cherry"), "OrderByDesc first"); + } + + [Test] + public void NSOrderedSet_Skip_Take () + { + using var set = MakeOrderedSet ("a", "b", "c", "d"); + var sliced = set.Skip (1).Take (2).ToList (); + Assert.That (sliced.Count, Is.EqualTo (2), "Skip/Take count"); + Assert.That (sliced [0].ToString (), Is.EqualTo ("b"), "Skip/Take [0]"); + } + + [Test] + public void NSOrderedSet_SkipWhile_TakeWhile () + { + using var set = MakeOrderedSet ("a", "b", "c"); + var skipped = set.SkipWhile (s => s.ToString () == "a").ToList (); + Assert.That (skipped.Count, Is.EqualTo (2), "SkipWhile count"); + var taken = set.TakeWhile (s => s.ToString () != "c").ToList (); + Assert.That (taken.Count, Is.EqualTo (2), "TakeWhile count"); + } + + [Test] + public void NSOrderedSet_Distinct () + { + using var set = MakeOrderedSet ("a", "b"); + var distinct = set.Distinct ().ToList (); + Assert.That (distinct.Count, Is.EqualTo (2), "Distinct count"); + } + + [Test] + public void NSOrderedSet_Reverse () + { + using var set = MakeOrderedSet ("a", "b", "c"); + var reversed = set.Reverse ().ToList (); + Assert.That (reversed [0].ToString (), Is.EqualTo ("c"), "Reverse [0]"); + Assert.That (reversed [2].ToString (), Is.EqualTo ("a"), "Reverse [2]"); + } + + [Test] + public void NSOrderedSet_Concat () + { + using var set = MakeOrderedSet ("a", "b"); + var all = set.Concat (new [] { S ("c") }).ToList (); + Assert.That (all.Count, Is.EqualTo (3), "Concat count"); + } + + [Test] + public void NSOrderedSet_ToList () + { + using var set = MakeOrderedSet ("a", "b"); + var list = set.ToList (); + Assert.That (list.Count, Is.EqualTo (2), "ToList count"); + } + + [Test] + public void NSOrderedSet_ToArray () + { + using var set = MakeOrderedSet ("a", "b"); + var arr = set.ToArray (); + Assert.That (arr.Length, Is.EqualTo (2), "ToArray length"); + } + + [Test] + public void NSOrderedSet_Aggregate () + { + using var set = MakeOrderedSet ("a", "b", "c"); + var result = set.Aggregate ((acc, s) => (NSString) (acc.ToString () + s.ToString ())); + Assert.That (result.ToString (), Is.EqualTo ("abc"), "Aggregate"); + } + + [Test] + public void NSOrderedSet_Aggregate_Seed () + { + using var set = MakeOrderedSet ("a", "b", "c"); + var result = set.Aggregate ("", (acc, s) => acc + s.ToString ()); + Assert.That (result, Is.EqualTo ("abc"), "Aggregate seed"); + } + + // ===== NSMutableOrderedSet ===== + + [Test] + public void NSMutableOrderedSet_First () + { + using var set = MakeMutableOrderedSet ("a", "b", "c"); + Assert.That (set.First ().ToString (), Is.EqualTo ("a"), "First"); + } + + [Test] + public void NSMutableOrderedSet_First_Empty_Throws () + { + using var set = MakeMutableOrderedSet (); + Assert.Throws (() => set.First ()); + } + + [Test] + public void NSMutableOrderedSet_FirstOrDefault_Empty () + { + using var set = MakeMutableOrderedSet (); + Assert.That (set.FirstOrDefault (), Is.Null, "FirstOrDefault empty"); + } + + [Test] + public void NSMutableOrderedSet_FirstOrDefault () + { + using var set = MakeMutableOrderedSet ("x", "y"); + Assert.That (set.FirstOrDefault ()?.ToString (), Is.EqualTo ("x"), "FirstOrDefault"); + } + + [Test] + public void NSMutableOrderedSet_FirstOrDefault_Predicate () + { + using var set = MakeMutableOrderedSet ("a", "b", "c"); + Assert.That (set.FirstOrDefault (s => s.ToString () == "b")?.ToString (), Is.EqualTo ("b"), "FirstOrDefault predicate match"); + Assert.That (set.FirstOrDefault (s => s.ToString () == "z"), Is.Null, "FirstOrDefault predicate no match"); + } + + [Test] + public void NSMutableOrderedSet_Last () + { + using var set = MakeMutableOrderedSet ("a", "b", "c"); + Assert.That (set.Last ().ToString (), Is.EqualTo ("c"), "Last"); + } + + [Test] + public void NSMutableOrderedSet_LastOrDefault_Empty () + { + using var set = MakeMutableOrderedSet (); + Assert.That (set.LastOrDefault (), Is.Null, "LastOrDefault empty"); + } + + [Test] + public void NSMutableOrderedSet_Single () + { + using var set = MakeMutableOrderedSet ("only"); + Assert.That (set.Single ().ToString (), Is.EqualTo ("only"), "Single"); + } + + [Test] + public void NSMutableOrderedSet_Single_Throws_OnMultiple () + { + using var set = MakeMutableOrderedSet ("a", "b"); + Assert.Throws (() => set.Single ()); + } + + [Test] + public void NSMutableOrderedSet_SingleOrDefault_Empty () + { + using var set = MakeMutableOrderedSet (); + Assert.That (set.SingleOrDefault (), Is.Null, "SingleOrDefault empty"); + } + + [Test] + public void NSMutableOrderedSet_ElementAt () + { + using var set = MakeMutableOrderedSet ("a", "b", "c"); + Assert.That (set.ElementAt (2).ToString (), Is.EqualTo ("c"), "ElementAt 2"); + } + + [Test] + public void NSMutableOrderedSet_ElementAtOrDefault () + { + using var set = MakeMutableOrderedSet ("a"); + Assert.That (set.ElementAtOrDefault (0)?.ToString (), Is.EqualTo ("a"), "in range"); + Assert.That (set.ElementAtOrDefault (5), Is.Null, "out of range"); + } + + [Test] + public void NSMutableOrderedSet_Any () + { + using var empty = MakeMutableOrderedSet (); + Assert.That (empty.Any (), Is.False, "Any empty"); + using var set = MakeMutableOrderedSet ("a"); + Assert.That (set.Any (), Is.True, "Any non-empty"); + } + + [Test] + public void NSMutableOrderedSet_All () + { + using var set = MakeMutableOrderedSet ("ab", "abc"); + Assert.That (set.All (s => s.Length > 1), Is.True, "All true"); + } + + [Test] + public void NSMutableOrderedSet_Count () + { + using var set = MakeMutableOrderedSet ("a", "b", "c"); + Assert.That (set.Count (), Is.EqualTo (3), "Count"); + Assert.That (set.Count (s => s.ToString () == "a"), Is.EqualTo (1), "Count predicate"); + } + + [Test] + public void NSMutableOrderedSet_LongCount () + { + using var set = MakeMutableOrderedSet ("a", "b"); + Assert.That (set.LongCount (), Is.EqualTo (2L), "LongCount"); + } + + [Test] + public void NSMutableOrderedSet_Where () + { + using var set = MakeMutableOrderedSet ("a", "bb", "ccc"); + var result = set.Where (s => s.Length > 1).ToList (); + Assert.That (result.Count, Is.EqualTo (2), "Where count"); + } + + [Test] + public void NSMutableOrderedSet_Select () + { + using var set = MakeMutableOrderedSet ("hello", "world"); + var lengths = set.Select (s => s.Length).ToList (); + Assert.That (lengths [0], Is.EqualTo (5), "Select [0]"); + } + + [Test] + public void NSMutableOrderedSet_OrderBy () + { + using var set = MakeMutableOrderedSet ("banana", "apple", "cherry"); + var sorted = set.OrderBy (s => s.ToString ()).ToList (); + Assert.That (sorted [0].ToString (), Is.EqualTo ("apple"), "OrderBy first"); + } + + [Test] + public void NSMutableOrderedSet_OrderByDescending () + { + using var set = MakeMutableOrderedSet ("banana", "apple", "cherry"); + var sorted = set.OrderByDescending (s => s.ToString ()).ToList (); + Assert.That (sorted [0].ToString (), Is.EqualTo ("cherry"), "OrderByDesc first"); + } + + [Test] + public void NSMutableOrderedSet_Skip_Take () + { + using var set = MakeMutableOrderedSet ("a", "b", "c", "d"); + var sliced = set.Skip (1).Take (2).ToList (); + Assert.That (sliced.Count, Is.EqualTo (2), "Skip/Take count"); + Assert.That (sliced [0].ToString (), Is.EqualTo ("b"), "Skip/Take [0]"); + } + + [Test] + public void NSMutableOrderedSet_SkipWhile_TakeWhile () + { + using var set = MakeMutableOrderedSet ("a", "b", "c"); + var skipped = set.SkipWhile (s => s.ToString () == "a").ToList (); + Assert.That (skipped.Count, Is.EqualTo (2), "SkipWhile count"); + var taken = set.TakeWhile (s => s.ToString () != "c").ToList (); + Assert.That (taken.Count, Is.EqualTo (2), "TakeWhile count"); + } + + [Test] + public void NSMutableOrderedSet_Distinct () + { + using var set = MakeMutableOrderedSet ("a", "b"); + var distinct = set.Distinct ().ToList (); + Assert.That (distinct.Count, Is.EqualTo (2), "Distinct count"); + } + + [Test] + public void NSMutableOrderedSet_Reverse () + { + using var set = MakeMutableOrderedSet ("a", "b", "c"); + var reversed = set.Reverse ().ToList (); + Assert.That (reversed [0].ToString (), Is.EqualTo ("c"), "Reverse [0]"); + Assert.That (reversed [2].ToString (), Is.EqualTo ("a"), "Reverse [2]"); + } + + [Test] + public void NSMutableOrderedSet_Concat () + { + using var set = MakeMutableOrderedSet ("a", "b"); + var all = set.Concat (new [] { S ("c") }).ToList (); + Assert.That (all.Count, Is.EqualTo (3), "Concat count"); + } + + [Test] + public void NSMutableOrderedSet_ToList () + { + using var set = MakeMutableOrderedSet ("a", "b"); + var list = set.ToList (); + Assert.That (list.Count, Is.EqualTo (2), "ToList count"); + } + + [Test] + public void NSMutableOrderedSet_ToArray () + { + using var set = MakeMutableOrderedSet ("a", "b"); + var arr = set.ToArray (); + Assert.That (arr.Length, Is.EqualTo (2), "ToArray length"); + } + + [Test] + public void NSMutableOrderedSet_Aggregate () + { + using var set = MakeMutableOrderedSet ("a", "b", "c"); + var result = set.Aggregate ((acc, s) => (NSString) (acc.ToString () + s.ToString ())); + Assert.That (result.ToString (), Is.EqualTo ("abc"), "Aggregate"); + } + + [Test] + public void NSMutableOrderedSet_Aggregate_Seed () + { + using var set = MakeMutableOrderedSet ("a", "b", "c"); + var result = set.Aggregate ("", (acc, s) => acc + s.ToString ()); + Assert.That (result, Is.EqualTo ("abc"), "Aggregate seed"); + } + } }