Skip to content

Conversation

@rolfbjarne
Copy link
Member

This is file 40 of 47 files with nullability disabled in Foundation.

  • Enabled nullable reference types.
  • Removed four SupportedOSPlatform attributes without version numbers.
  • Replaced 'To be added.' XML comments with proper documentation.
  • Added XML documentation for all public and protected members.
  • Used ArgumentNullException.ThrowIfNull for parameter validation.
  • Fixed XML comment formatting and added see cref attributes.
  • Made ObjectForKey return nullable TValue? since keys may not exist.
  • Made TryGetValue parameter nullable with NotNullWhen(true) attribute.
  • Kept IDictionary interface implementations non-nullable per .NET contract.
  • Used KeyNotFoundException when indexer accesses missing keys.
  • Fixed IEnumerator implementations to skip null values in enumeration.
  • Changed empty array initialization from 'new TValue[]{}' to '[]'.
  • Remove some dead code.
  • Add a few more tests.

Contributes towards #17285.

This is file 40 of 47 files with nullability disabled in Foundation.

* Enabled nullable reference types.
* Removed four SupportedOSPlatform attributes without version numbers.
* Replaced 'To be added.' XML comments with proper documentation.
* Added XML documentation for all public and protected members.
* Used ArgumentNullException.ThrowIfNull for parameter validation.
* Fixed XML comment formatting and added see cref attributes.
* Made ObjectForKey return nullable TValue? since keys may not exist.
* Made TryGetValue parameter nullable with NotNullWhen(true) attribute.
* Kept IDictionary interface implementations non-nullable per .NET contract.
* Used KeyNotFoundException when indexer accesses missing keys.
* Fixed IEnumerator implementations to skip null values in enumeration.
* Changed empty array initialization from 'new TValue[]{}' to '[]'.
* Remove some dead code.
* Add a few more tests.

Contributes towards #17285.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables nullable reference types for NSMutableDictionary<TKey, TValue>, which is file 40 of 47 in the Foundation nullability migration effort. The changes improve type safety by making nullability explicit in method signatures, particularly for methods that can return null for missing keys like ObjectForKey. The PR also improves the indexer behavior to throw KeyNotFoundException for missing keys (aligning with .NET conventions), replaces placeholder XML documentation with comprehensive summaries, and modernizes parameter validation using ArgumentNullException.ThrowIfNull.

Key changes:

  • Made ObjectForKey return TValue? (nullable) since keys may not exist in the dictionary
  • Changed public indexer getter to throw KeyNotFoundException for missing keys instead of returning null
  • Added comprehensive XML documentation for all public members

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/Foundation/NSMutableDictionary_2.cs Enabled nullable reference types, updated method signatures for nullability, replaced placeholder XML docs with comprehensive documentation, modernized parameter validation, changed indexer to throw KeyNotFoundException for missing keys
tests/monotouch-test/Foundation/NSMutableDictionary2Test.cs Added comprehensive tests for missing key access behavior, testing ObjectForKey, TryGetValue, ContainsKey, indexer, and IDictionary interface behavior
tests/cecil-tests/Documentation.KnownFailures.txt Removed entries for methods that now have proper XML documentation

@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.

@rolfbjarne rolfbjarne enabled auto-merge (squash) December 17, 2025 22:56
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #e865530] Build passed (Build packages) ✅

Pipeline on Agent
Hash: e865530026ce39db5f7a14e5374bfc14b45146e2 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

Pipeline on Agent
Hash: e865530026ce39db5f7a14e5374bfc14b45146e2 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #e865530] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: e865530026ce39db5f7a14e5374bfc14b45146e2 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #e865530] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: e865530026ce39db5f7a14e5374bfc14b45146e2 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #e865530] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: e865530026ce39db5f7a14e5374bfc14b45146e2 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #e865530] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: e865530026ce39db5f7a14e5374bfc14b45146e2 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #e865530] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: e865530026ce39db5f7a14e5374bfc14b45146e2 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #e865530] Tests on macOS arm64 - Mac Tahoe (26) passed 💻

All tests on macOS arm64 - Mac Tahoe (26) passed.

Pipeline on Agent
Hash: e865530026ce39db5f7a14e5374bfc14b45146e2 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
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: e865530026ce39db5f7a14e5374bfc14b45146e2 [PR build]

@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
Collaborator

🔥 [CI Build #e865530] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

0 tests crashed, 2 tests failed, 120 tests passed.

Failures

❌ monotouch tests (macOS) [attempt 3]

2 tests failed, 10 tests passed.

Failed tests

  • monotouch-test/macOS/Debug (static registrar, ARM64): Failed (Test run failed.
    Tests run: 3555 Passed: 3320 Inconclusive: 4 Failed: 2 Ignored: 233)
  • monotouch-test/macOS/Release (managed static registrar): Failed (Test run failed.
    Tests run: 3555 Passed: 3378 Inconclusive: 4 Failed: 1 Ignored: 176)

Html Report (VSDrops) Download

Successes

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): 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
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 9 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 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

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

5 participants