Skip to content

Add LINQ FirstOrDefault support parity across generic NS collections#25509

Draft
Copilot wants to merge 6 commits into
mainfrom
copilot/fix-linq-methods-inconsistent-ns-collections
Draft

Add LINQ FirstOrDefault support parity across generic NS collections#25509
Copilot wants to merge 6 commits into
mainfrom
copilot/fix-linq-methods-inconsistent-ns-collections

Conversation

Copilot AI commented May 22, 2026

Copy link
Copy Markdown
Contributor
  • Understand the issue: NS generic collections (NSSet<T>, NSMutableSet<T>, NSArray<T>, NSMutableArray<T>, NSOrderedSet<T>, NSMutableOrderedSet<T>) inherit from non-generic base classes that implement IEnumerable&lt;NSObject&gt;, causing LINQ type-inference ambiguity
  • Review existing FirstOrDefault extension overloads in NSCollectionLinqExtensions.cs
  • Expand NSCollectionLinqExtensions.cs with all common LINQ method overloads for all 6 collection types (First, FirstOrDefault, Last, LastOrDefault, Single, SingleOrDefault, ElementAt, ElementAtOrDefault, Any, All, Count, LongCount, Where, Select, OrderBy, OrderByDescending, Skip, SkipWhile, Take, TakeWhile, Distinct, Reverse, Concat, ToList, ToArray, Aggregate), each with XML docs
  • Add comprehensive LINQ tests in tests/monotouch-test/Foundation/NSCollectionLinqTest.cs covering all 6 generic NS collections
  • Validate the build compiles

Copilot AI and others added 2 commits May 22, 2026 15:07
Copilot AI changed the title [WIP] Fix inconsistent LINQ methods on NS collections Add LINQ FirstOrDefault support parity across generic NS collections May 22, 2026
Copilot AI requested a review from rolfbjarne May 22, 2026 15:09
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

…neric 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>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

rolfbjarne and others added 2 commits May 27, 2026 17:30
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>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #56709b2] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 56709b2e806746948448b35df01ab10a3e65d98b [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #56709b2] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 56709b2e806746948448b35df01ab10a3e65d98b [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 56709b2e806746948448b35df01ab10a3e65d98b [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🔥 [PR Build #56709b2] Build failed (Build macOS tests) 🔥

Build failed for the job 'Build macOS tests' (with job status 'Failed')

Pipeline on Agent
Hash: 56709b2e806746948448b35df01ab10a3e65d98b [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🔥 [CI Build #56709b2] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

5 tests crashed, 87 tests failed, 71 tests passed.

Failures

❌ cecil tests

1 tests failed, 0 tests passed.

Failed tests

  • Cecil-based tests: Failed (Execution failed with exit code 1)
    • Cecil.Tests.Documentation.VerifyEveryVisibleMemberIsDocumented: Found 1 undocumented APIs (not known failures) and 0 APIs that were marked as known failures but are now documented. If this is ...

Html Report (VSDrops) Download

❌ dotnettests tests (iOS)

1 tests failed, 0 tests passed.

Failed tests

  • DotNet tests: Failed (Execution failed with exit code 1)
    • Xamarin.Tests.DotNetProjectTest.BuildFatMonoTouchTest(iOS,"iossi...: 'dotnet build' failed with exit code 1
      Full command: /Users/builder/azdo/_work/1/s/macios/builds/downloads/dotnet-sdk-10.0.301-s...
    • Xamarin.Tests.DotNetProjectTest.PublishAotMonoTouchTest_NoIL2009...: 'dotnet build' failed with exit code 1
      Full command: /Users/builder/azdo/_work/1/s/macios/builds/downloads/dotnet-sdk-10.0.301-s...

Html Report (VSDrops) Download

❌ dotnettests tests (MacCatalyst)

1 tests failed, 0 tests passed.

Failed tests

  • DotNet tests: Failed (Execution failed with exit code 1)
    • Xamarin.Tests.DotNetProjectTest.BuildFatMonoTouchTest(MacCatalys...: 'dotnet build' failed with exit code 1
      Full command: /Users/builder/azdo/_work/3/s/macios/builds/downloads/dotnet-sdk-10.0.301-s...
    • Xamarin.Tests.DotNetProjectTest.PublishAotMonoTouchTest_NoIL2009...: 'dotnet build' failed with exit code 1
      Full command: /Users/builder/azdo/_work/3/s/macios/builds/downloads/dotnet-sdk-10.0.301-s...

Html Report (VSDrops) Download

❌ dotnettests tests (macOS)

1 tests failed, 0 tests passed.

Failed tests

  • DotNet tests: Failed (Execution failed with exit code 1)
    • Xamarin.Tests.DotNetProjectTest.BuildFatMonoTouchTest(MacOSX,"os...: 'dotnet build' failed with exit code 1
      Full command: /Users/builder/azdo/_work/1/s/macios/builds/downloads/dotnet-sdk-10.0.301-s...
    • Xamarin.Tests.DotNetProjectTest.PublishAotMonoTouchTest_NoIL2009...: 'dotnet build' failed with exit code 1
      Full command: /Users/builder/azdo/_work/1/s/macios/builds/downloads/dotnet-sdk-10.0.301-s...

Html Report (VSDrops) Download

❌ dotnettests tests (tvOS)

1 tests failed, 0 tests passed.

Failed tests

  • DotNet tests: Failed (Execution failed with exit code 1)
    • Xamarin.Tests.DotNetProjectTest.PublishAotMonoTouchTest_NoIL2009...: 'dotnet build' failed with exit code 1
      Full command: /Users/builder/azdo/_work/3/s/macios/builds/downloads/dotnet-sdk-10.0.301-s...

Html Report (VSDrops) Download

❌ introspection tests

6 tests failed, 0 tests passed.

Failed tests

  • introspection/macOS/Debug: Failed (Test run failed.
    Tests run: 34 Passed: 31 Inconclusive: 0 Failed: 1 Ignored: 2)
  • introspection/Mac Catalyst/Debug: Failed (Test run failed.
    Tests run: 43 Passed: 38 Inconclusive: 0 Failed: 1 Ignored: 4)
  • introspection/iOS - simulator/Debug: LaunchTimedOut
  • introspection/iOS - simulator/Debug (ARM64): LaunchTimedOut
  • introspection/tvOS - simulator/Debug: LaunchTimedOut
  • introspection/tvOS - simulator/Debug (ARM64): LaunchTimedOut

Html Report (VSDrops) Download

❌ monotouch tests (iOS)

18 tests failed, 0 tests passed.

Failed tests

  • monotouch-test/iOS - simulator/Debug: BuildFailure
  • monotouch-test/iOS - simulator/Release (link sdk): BuildFailure
  • monotouch-test/iOS - simulator/Release (link all): BuildFailure
  • monotouch-test/iOS - simulator/Debug (LinkSdk): BuildFailure
  • monotouch-test/iOS - simulator/Debug (static registrar): BuildFailure
  • monotouch-test/iOS - simulator/Release (all optimizations): BuildFailure
  • monotouch-test/iOS - simulator/Debug (ARM64): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/iOS - simulator/Release (NativeAOT, ARM64): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/iOS - simulator/Release (trimmable static registrar, NativeAOT, ARM64): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/iOS - simulator/Debug (managed static registrar): BuildFailure
  • monotouch-test/iOS - simulator/Release (managed static registrar, all optimizations): BuildFailure
  • monotouch-test/iOS - simulator/Release (NativeAOT, x64): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/iOS - simulator/Release (trimmable static registrar, NativeAOT, x64): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/iOS - simulator/Debug (interpreter): BuildFailure
  • monotouch-test/iOS - simulator/Release (interpreter): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/iOS - simulator/Release (compat inline dlfcn): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/iOS - simulator/Release (strict inline dlfcn, link sdk): BuildFailure
  • monotouch-test/iOS - simulator/Release (NativeAOT, .NET 11 defaults): BuildFailure

Html Report (VSDrops) Download

❌ monotouch tests (MacCatalyst)

20 tests failed, 0 tests passed.

Failed tests

  • monotouch-test/Mac Catalyst/Debug: BuildFailure
  • monotouch-test/Mac Catalyst/Release (link sdk): BuildFailure
  • monotouch-test/Mac Catalyst/Release (link all): BuildFailure
  • monotouch-test/Mac Catalyst/Debug (ARM64): BuildFailure
  • monotouch-test/Mac Catalyst/Debug (managed static registrar): BuildFailure
  • monotouch-test/Mac Catalyst/Debug (static registrar): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/Mac Catalyst/Debug (static registrar, ARM64): BuildFailure
  • monotouch-test/Mac Catalyst/Release (managed static registrar): BuildFailure
  • monotouch-test/Mac Catalyst/Release (managed static registrar, all optimizations): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/Mac Catalyst/Release (NativeAOT): BuildFailure
  • monotouch-test/Mac Catalyst/Release (NativeAOT, ARM64): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/Mac Catalyst/Release (NativeAOT, x64): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/Mac Catalyst/Release (trimmable static registrar, NativeAOT): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/Mac Catalyst/Release (trimmable static registrar, NativeAOT, ARM64): BuildFailure
  • monotouch-test/Mac Catalyst/Release (trimmable static registrar, NativeAOT, x64): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/Mac Catalyst/Release (static registrar): BuildFailure
  • monotouch-test/Mac Catalyst/Release (static registrar, all optimizations): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/Mac Catalyst/Release (ARM64, LLVM): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/Mac Catalyst/Debug (interpreter): BuildFailure
  • monotouch-test/Mac Catalyst/Release (interpreter): BuildFailure

Html Report (VSDrops) Download

❌ monotouch tests (macOS)

20 tests failed, 0 tests passed.

Failed tests

  • monotouch-test/macOS/Debug: BuildFailure
  • monotouch-test/macOS/Release (link sdk): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Release (link all): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Debug (ARM64): BuildFailure
  • monotouch-test/macOS/Debug (managed static registrar): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Debug (trimmable static registrar): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Debug (static registrar): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Debug (static registrar, ARM64): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Release (managed static registrar): BuildFailure
  • monotouch-test/macOS/Release (trimmable static registrar): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Release (managed static registrar, all optimizations): BuildFailure
  • monotouch-test/macOS/Release (trimmable static registrar, all optimizations): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Release (NativeAOT): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Release (NativeAOT, ARM64): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Release (NativeAOT, x64): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Release (trimmable static registrar, NativeAOT): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Release (trimmable static registrar, NativeAOT, ARM64): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Release (trimmable static registrar, NativeAOT, x64): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Release (static registrar): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Release (static registrar, all optimizations): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))

Html Report (VSDrops) Download

❌ monotouch tests (tvOS)

18 tests failed, 0 tests passed.

Failed tests

  • monotouch-test/tvOS - simulator/Debug: BuildFailure
  • monotouch-test/tvOS - simulator/Release (link sdk): BuildFailure
  • monotouch-test/tvOS - simulator/Release (link all): BuildFailure
  • monotouch-test/tvOS - simulator/Debug (LinkSdk): BuildFailure
  • monotouch-test/tvOS - simulator/Debug (static registrar): BuildFailure
  • monotouch-test/tvOS - simulator/Release (all optimizations): BuildFailure
  • monotouch-test/tvOS - simulator/Debug (ARM64): BuildFailure
  • monotouch-test/tvOS - simulator/Release (NativeAOT, ARM64): BuildFailure
  • monotouch-test/tvOS - simulator/Release (trimmable static registrar, NativeAOT, ARM64): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/tvOS - simulator/Debug (managed static registrar): BuildFailure
  • monotouch-test/tvOS - simulator/Release (managed static registrar, all optimizations): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/tvOS - simulator/Release (NativeAOT, x64): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/tvOS - simulator/Release (trimmable static registrar, NativeAOT, x64): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/tvOS - simulator/Debug (interpreter): BuildFailure
  • monotouch-test/tvOS - simulator/Release (interpreter): BuildFailure
  • monotouch-test/tvOS - simulator/Release (compat inline dlfcn): BuildFailure
  • monotouch-test/tvOS - simulator/Release (strict inline dlfcn, link sdk): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/tvOS - simulator/Release (NativeAOT, .NET 11 defaults): BuildFailure

Html Report (VSDrops) Download

❌ Tests on macOS Monterey (12) tests

🔥 Failed catastrophically on VSTS: test results - mac_monterey (no summary found).

Html Report (VSDrops) Download

❌ Tests on macOS Ventura (13) tests

🔥 Failed catastrophically on VSTS: test results - mac_ventura (no summary found).

Html Report (VSDrops) Download

❌ Tests on macOS Sonoma (14) tests

🔥 Failed catastrophically on VSTS: test results - mac_sonoma (no summary found).

Html Report (VSDrops) Download

❌ Tests on macOS Sequoia (15) tests

🔥 Failed catastrophically on VSTS: test results - mac_sequoia (no summary found).

Html Report (VSDrops) Download

❌ Tests on macOS Tahoe (26) tests

🔥 Failed catastrophically on VSTS: test results - mac_tahoe (no summary found).

Html Report (VSDrops) Download

Successes

✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 11 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 11 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 11 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: 56709b2e806746948448b35df01ab10a3e65d98b [PR build]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System.Linq methods on NS collections is inconsistent

3 participants