Skip to content

[Mono.AndroidTools] Enable nullable reference types in AdbSyncNotification.cs#11778

Merged
jonathanpeppers merged 2 commits into
mainfrom
copilot/fix-finder-enable-nullable-reference-types
Jun 30, 2026
Merged

[Mono.AndroidTools] Enable nullable reference types in AdbSyncNotification.cs#11778
jonathanpeppers merged 2 commits into
mainfrom
copilot/fix-finder-enable-nullable-reference-types

Conversation

Copilot AI commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

AdbSyncNotification.cs ships in Mono.AndroidTools.dll but compiled in a nullable-oblivious context. This opts the file into NRT, making its existing null contract explicit: LocalPath is null for directory/remove/preserve operations, while RemotePath is always non-null.

Changes

  • src/Mono.AndroidTools/Adb/AdbSyncNotification.cs
    • Added #nullable enable as the first line.
    • Annotated LocalPath property and the localPath constructor parameter as string?; RemotePath stays non-nullable.
public AdbSyncNotification (AdbSyncKind kind, string remotePath, string? localPath, long size)
...
public string? LocalPath { get; private set; }

No null-throwing is required (netstandard2.0, so no ArgumentNullException.ThrowIfNull), and callers in AdbSyncContext.cs, AdbSyncClient.cs, and AndroidDevice.cs are not nullable-enabled, so no call-site changes or warnings result.

Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot AI changed the title [WIP] Enable nullable reference types in AdbSyncNotification.cs [Mono.AndroidTools] Enable nullable reference types in AdbSyncNotification.cs Jun 28, 2026
Copilot AI requested a review from jonathanpeppers June 28, 2026 03:08
@jonathanpeppers jonathanpeppers marked this pull request as ready for review June 29, 2026 14:33
Copilot AI review requested due to automatic review settings June 29, 2026 14:33
@jonathanpeppers jonathanpeppers enabled auto-merge (squash) June 29, 2026 14:34
@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Jun 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 opts AdbSyncNotification.cs (shipped in Mono.AndroidTools.dll) into nullable reference types (NRT) to make its nullability contract explicit: LocalPath can be null for non-file operations, while RemotePath is intended to always be non-null.

Changes:

  • Enabled NRT for AdbSyncNotification.cs via #nullable enable.
  • Annotated LocalPath and the corresponding constructor parameter as string? while keeping RemotePath as non-nullable.
Comments suppressed due to low confidence (1)

src/Mono.AndroidTools/Adb/AdbSyncNotification.cs:43

  • RemotePath is declared non-nullable, but the constructor currently accepts remotePath without validating it. Since this is a public API and most callers are in nullable-oblivious contexts, null can still be passed at runtime, breaking the non-null contract and potentially causing later NullReferenceExceptions. Add an ArgumentNullException guard to keep the contract sound.
		public AdbSyncNotification (AdbSyncKind kind, string remotePath, string? localPath, long size)
		{
			this.Kind = kind;
			this.RemotePath = remotePath;
			this.LocalPath = localPath;
			this.Size = size;
		}

@jonathanpeppers jonathanpeppers merged commit ada2c72 into main Jun 30, 2026
41 checks passed
@jonathanpeppers jonathanpeppers deleted the copilot/fix-finder-enable-nullable-reference-types branch June 30, 2026 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants