Skip to content

Comments

[ObjCRuntime] Enable nullability and clean up Runtime.#24747

Open
rolfbjarne wants to merge 1 commit intomainfrom
dev/rolf/objcruntime-nullability-runtime-07
Open

[ObjCRuntime] Enable nullability and clean up Runtime.#24747
rolfbjarne wants to merge 1 commit intomainfrom
dev/rolf/objcruntime-nullability-runtime-07

Conversation

@rolfbjarne
Copy link
Member

@rolfbjarne rolfbjarne commented Feb 19, 2026

This is file 7 of 7 files with nullability disabled in ObjCRuntime.

  • Enable nullability for Runtime.cs by removing the file-level nullable-disable section.
  • Remove placeholder XML comments ("To be added.") and replace them with concrete documentation.
  • Normalize XML documentation spacing and fix documentation wording for updated members.

Contributes towards #17285.

This is file 7 of 7 files with nullability disabled in ObjCRuntime.

* Enable nullability for Runtime.cs by removing the file-level nullable-disable section.
* Remove placeholder XML comments ("To be added.") and replace them with concrete documentation.
* Normalize XML documentation spacing and fix documentation wording for updated members.
* Add null argument validation for GetINativeObject (IntPtr, bool, Type).

Contributes towards #17285.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 pull request enables nullability for Runtime.cs, the final file in the ObjCRuntime namespace that had nullability disabled. The changes improve type safety, remove placeholder documentation, and normalize XML documentation formatting across the file.

Changes:

  • Removed #nullable disable directive and related pragma warnings to enable nullability for Runtime.cs
  • Added defensive null checks for GetNSObject and GCHandle.FromIntPtr().Target in exception marshaling methods
  • Updated delegate signatures in Registrar.cs and Exceptions.cs to mark sender parameters as nullable (object?)
  • Replaced all "To be added" placeholder XML documentation with concrete, helpful descriptions
  • Normalized XML documentation indentation and spacing for consistency
  • Applied modern C# patterns (out var, pattern matching) for improved readability

Reviewed changes

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

File Description
src/ObjCRuntime/Runtime.cs Enabled nullability, added null safety checks in exception marshaling, improved documentation, modernized code patterns
src/ObjCRuntime/Registrar.cs Updated AssemblyRegistrationHandler delegate to use nullable sender parameter
src/ObjCRuntime/Exceptions.cs Updated exception handler delegates to use nullable sender parameters
Comments suppressed due to low confidence (1)

src/ObjCRuntime/Runtime.cs:1933

  • The PR description mentions "Add null argument validation for GetINativeObject (IntPtr, bool, Type)", but the target_type parameter is not validated for null. This parameter is a reference type and is used without null checking at line 1948 (target_type.IsAssignableFrom). Consider adding null validation at the start of the method: if (target_type is null) throw new ArgumentNullException (nameof (target_type));
		public static INativeObject? GetINativeObject (IntPtr ptr, bool owns, Type target_type)
		{
			return GetINativeObject (ptr, owns, target_type, null);
		}

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #5284b54] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 5284b547ea799a4b9d2e81d9f4e464b1d53a7748 [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 #5284b54] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 5284b547ea799a4b9d2e81d9f4e464b1d53a7748 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne enabled auto-merge (squash) February 20, 2026 20:04
@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

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

Pipeline on Agent
Hash: 5284b547ea799a4b9d2e81d9f4e464b1d53a7748 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 Unable to find the contents for the comment: D:\a\1\s\change-detection\results\gh-comment.md does not exist :fire

Pipeline on Agent
Hash: 5284b547ea799a4b9d2e81d9f4e464b1d53a7748 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 [CI Build #5284b54] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

0 tests crashed, 1 tests failed, 155 tests passed.

Failures

❌ linker tests [attempt 3]

1 tests failed, 43 tests passed.

Failed tests

  • link all/iOS - simulator/Debug: LaunchFailure

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 6 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 15 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (macOS): All 12 tests passed. Html Report (VSDrops) Download
✅ monotouch (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

✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 5284b547ea799a4b9d2e81d9f4e464b1d53a7748 [PR build]

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants