Skip to content

Add LINQ FirstOrDefault support parity across generic NS collections - #25509

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

Add LINQ FirstOrDefault support parity across generic NS collections#25509
rolfbjarne with Copilot wants to merge 7 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

Fixes #4597.

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

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

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: acba1c5ed0ee173047adaa9f573acac3528360aa [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🔥 [PR Build #acba1c5] Build failed (Build macOS tests) 🔥

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

Pipeline on Agent
Hash: acba1c5ed0ee173047adaa9f573acac3528360aa [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🔥 [CI Build #acba1c5] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

3 tests crashed, 108 tests failed, 141 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/cloudtest/vss/_work/1/s/macios/builds/downloads/dotnet-sdk-11.0.100-...
    • Xamarin.Tests.DotNetProjectTest.PublishAotMonoTouchTest_NoIL2009...: 'dotnet build' failed with exit code 1
      Full command: /Users/cloudtest/vss/_work/1/s/macios/builds/downloads/dotnet-sdk-11.0.100-...

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/cloudtest/vss/_work/1/s/macios/builds/downloads/dotnet-sdk-11.0.100-...
    • Xamarin.Tests.DotNetProjectTest.PublishAotMonoTouchTest_NoIL2009...: 'dotnet build' failed with exit code 1
      Full command: /Users/cloudtest/vss/_work/1/s/macios/builds/downloads/dotnet-sdk-11.0.100-...

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.AppSizeTest.CoreCLR_Interpreter_TrimmableStatic(Ma...: App size changed significantly (+20,308 bytes (19.8 KB = 0.0 MB) different > tolerance of +-10,240 bytes (10.0 KB = 0.0 MB)). Ex...
    • Xamarin.Tests.AppSizeTest.CoreCLR_Interpreter(MacOSX,"osx-arm64;...: App size changed significantly (+20,308 bytes (19.8 KB = 0.0 MB) different > tolerance of +-10,240 bytes (10.0 KB = 0.0 MB)). Ex...
    • Xamarin.Tests.AppSizeTest.CoreCLR_R2R(MacOSX,"osx-arm64;osx-x64"...: App size changed significantly (+122,196 bytes (119.3 KB = 0.1 MB) different > tolerance of +-10,240 bytes (10.0 KB = 0.0 MB)). ...
    • ... and 2 more

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/cloudtest/vss/_work/1/s/macios/builds/downloads/dotnet-sdk-11.0.100-...

Html Report (VSDrops) Download

❌ introspection tests

7 tests failed, 0 tests passed.

Failed tests

  • introspection/macOS/Debug: Failed (Test run failed.
    Tests run: 34 Passed: 32 Inconclusive: 0 Failed: 2 Ignored: 0)
  • introspection/Mac Catalyst/Debug: Failed (Test run failed.
    Tests run: 43 Passed: 39 Inconclusive: 0 Failed: 2 Ignored: 2)
  • introspection/Mac Catalyst/CoreCLR: Failed (Test run failed.
    Tests run: 43 Passed: 39 Inconclusive: 0 Failed: 2 Ignored: 2)
  • introspection/iOS - simulator/Debug: Failed
  • introspection/iOS - simulator/CoreCLR: Failed
  • introspection/tvOS - simulator/Debug: Failed
  • introspection/tvOS - simulator/CoreCLR: Failed

Html Report (VSDrops) Download

❌ monotouch tests (iOS)

25 tests failed, 0 tests passed.

Failed tests

  • monotouch-test/iOS - simulator/Debug: BuildFailure
  • monotouch-test/iOS - simulator/Debug (CoreCLR): BuildFailure
  • monotouch-test/iOS - simulator/Release (CoreCLR, ARM64): BuildFailure
  • monotouch-test/iOS - simulator/Release (CoreCLR, Universal): BuildFailure
  • monotouch-test/iOS - simulator/Release (link sdk): BuildFailure
  • monotouch-test/iOS - simulator/Release (link all): BuildFailure
  • monotouch-test/iOS - simulator/Debug (PrepareAssemblies): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/iOS - simulator/Debug (PrepareAssemblies, Trimmable Static Registrar, link sdk): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • 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/Release (NativeAOT): BuildFailure
  • monotouch-test/iOS - simulator/Release (trimmable static registrar, NativeAOT): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/iOS - simulator/Debug (managed static registrar): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/iOS - simulator/Debug (trimmable static registrar): BuildFailure
  • monotouch-test/iOS - simulator/Release (managed static registrar, all optimizations): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/iOS - simulator/Debug (trimmable static registrar, all optimizations): BuildFailure
  • monotouch-test/iOS - simulator/Release (trimmable static registrar, all optimizations): BuildFailure
  • monotouch-test/iOS - simulator/Debug (interpreter): BuildFailure
  • monotouch-test/iOS - simulator/Release (interpreter): BuildFailure
  • monotouch-test/iOS - simulator/Release (compat inline Class.GetHandle): BuildFailure
  • monotouch-test/iOS - simulator/Release (strict inline Class.GetHandle): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/iOS - simulator/Release (compat inline dlfcn): BuildFailure
  • 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)

25 tests failed, 0 tests passed.

Failed tests

  • monotouch-test/Mac Catalyst/Debug: BuildFailure
  • monotouch-test/Mac Catalyst/Debug (CoreCLR): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/Mac Catalyst/Release (CoreCLR, ARM64): BuildFailure
  • monotouch-test/Mac Catalyst/Release (CoreCLR, Universal): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/Mac Catalyst/Release (link sdk): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/Mac Catalyst/Release (link all): BuildFailure
  • monotouch-test/Mac Catalyst/Debug (PrepareAssemblies): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/Mac Catalyst/Debug (PrepareAssemblies, Trimmable Static Registrar, link sdk): BuildFailure
  • monotouch-test/Mac Catalyst/Debug (managed static registrar): BuildFailure
  • monotouch-test/Mac Catalyst/Debug (trimmable 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/Release (managed static registrar): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/Mac Catalyst/Release (trimmable static registrar): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • 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/Debug (trimmable static registrar, all optimizations): BuildFailure
  • monotouch-test/Mac Catalyst/Release (trimmable static registrar, all optimizations): BuildFailure
  • monotouch-test/Mac Catalyst/Release (NativeAOT): BuildFailure
  • monotouch-test/Mac Catalyst/Release (NativeAOT, .NET 11 defaults): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/Mac Catalyst/Release (trimmable static registrar, NativeAOT): BuildFailure
  • monotouch-test/Mac Catalyst/Release (static registrar): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • 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/Debug (interpreter): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/Mac Catalyst/Release (interpreter): BuildFailure
  • monotouch-test/Mac Catalyst/Release (compat inline dlfcn): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/Mac Catalyst/Release (strict inline dlfcn, link sdk): 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
  • monotouch-test/macOS/Release (link all): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Debug (PrepareAssemblies): BuildFailure
  • monotouch-test/macOS/Debug (PrepareAssemblies, Trimmable Static Registrar, link sdk): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • 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
  • monotouch-test/macOS/Release (managed static registrar): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Release (trimmable static registrar): BuildFailure
  • monotouch-test/macOS/Release (managed static registrar, all optimizations): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/macOS/Debug (trimmable 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
  • monotouch-test/macOS/Release (NativeAOT, .NET 11 defaults): BuildFailure
  • 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 (static registrar): BuildFailure
  • monotouch-test/macOS/Release (static registrar, all optimizations): BuildFailure
  • monotouch-test/macOS/Release (compat inline dlfcn): BuildFailure
  • monotouch-test/macOS/Release (strict inline dlfcn, link sdk): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))

Html Report (VSDrops) Download

❌ monotouch tests (tvOS)

25 tests failed, 0 tests passed.

Failed tests

  • monotouch-test/tvOS - simulator/Debug: BuildFailure
  • monotouch-test/tvOS - simulator/Debug (CoreCLR): BuildFailure
  • monotouch-test/tvOS - simulator/Release (CoreCLR, ARM64): BuildFailure
  • monotouch-test/tvOS - simulator/Release (CoreCLR, Universal): BuildFailure
  • monotouch-test/tvOS - simulator/Release (link sdk): BuildFailure
  • monotouch-test/tvOS - simulator/Release (link all): BuildFailure
  • monotouch-test/tvOS - simulator/Debug (PrepareAssemblies): BuildFailure
  • monotouch-test/tvOS - simulator/Debug (PrepareAssemblies, Trimmable Static Registrar, link sdk): BuildFailure
  • monotouch-test/tvOS - simulator/Debug (LinkSdk): BuildFailure
  • monotouch-test/tvOS - simulator/Debug (static registrar): BuildFailure
  • monotouch-test/tvOS - simulator/Release (all optimizations): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/tvOS - simulator/Release (NativeAOT): BuildFailure
  • monotouch-test/tvOS - simulator/Release (trimmable static registrar, NativeAOT): 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/Debug (trimmable static registrar): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/tvOS - simulator/Release (managed static registrar, all optimizations): BuildFailure
  • monotouch-test/tvOS - simulator/Debug (trimmable static registrar, all optimizations): BuildFailure ( (failed to parse the logs: The Writer is closed or in error state.))
  • monotouch-test/tvOS - simulator/Release (trimmable static registrar, all optimizations): 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 Class.GetHandle): BuildFailure
  • monotouch-test/tvOS - simulator/Release (strict inline Class.GetHandle): 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 ( (failed to parse the logs: The Writer is closed or in error state.))

Html Report (VSDrops) Download

❌ msbuild tests

1 tests failed, 1 tests passed.

Failed tests

  • MSBuild tasks tests: Failed (Execution failed with exit code 1)
    • Xamarin.MacDev.Tasks.CompileAppManifestTaskTests.SupportedOSPlat...: Assert.That(Engine.Logger.ErrorEvents [0].Message, Is.EqualTo ("The value '\n13.0' for the property 'SupportedOSPlatformVersi...

Html Report (VSDrops) Download

❌ Tests on macOS Sonoma (14) tests

⚠️ Tests did not run because the Build macOS tests job failed.

Html Report (VSDrops) Download

❌ Tests on macOS Sequoia (15) tests

⚠️ Tests did not run because the Build macOS tests job failed.

Html Report (VSDrops) Download

❌ Tests on macOS Tahoe (26) tests

⚠️ Tests did not run because the Build macOS tests job failed.

Html Report (VSDrops) Download

Successes

✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download
✅ 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 31 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 31 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 31 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: acba1c5ed0ee173047adaa9f573acac3528360aa [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

⚠️ AppSizeTest expected files changed ⚠️

The AppSizeTest detected changes in the expected app size files.

To update the expected files, add a comment with the following command:

/apply-gist https://gist.github.com/vs-mobiletools-engineering-service2/5b361c9f360c32439d64d34044827a21
Updated files
  • MacOSX-CoreCLR-Interpreter-size.txt
  • MacOSX-CoreCLR-Interpreter-TrimmableStatic-size.txt
  • MacOSX-CoreCLR-R2R-size.txt

Pipeline on Agent
Hash: acba1c5ed0ee173047adaa9f573acac3528360aa [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