Skip to content

Remove null-forgiving operator (!) in BaseTest.AssertApkSigned#12036

Merged
jonathanpeppers merged 2 commits into
mainfrom
copilot/fix-finder-remove-null-forgiving-operator
Jul 13, 2026
Merged

Remove null-forgiving operator (!) in BaseTest.AssertApkSigned#12036
jonathanpeppers merged 2 commits into
mainfrom
copilot/fix-finder-remove-null-forgiving-operator

Conversation

Copilot AI commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Process.Start can return null, but the previous code used proc! to suppress the compiler warning, risking a raw NullReferenceException on failure. Replace with an explicit ?? throw to surface a clear error.

Changes

  • BaseTest.cs: Replace proc!.StandardOutput with a null-coalescing throw on the Process.Start result:
// Before
using var proc = Process.Start (psi);
string stdout = proc!.StandardOutput.ReadToEnd ();

// After
using var proc = Process.Start (psi) ?? throw new InvalidOperationException ($"Failed to start '{apksignerExe}'.");
string stdout = proc.StandardOutput.ReadToEnd ();

Subsequent dereferences of proc (StandardError, WaitForExit, ExitCode) are already !-free and require no change.

Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove null-forgiving operator in BaseTest.AssertApkSigned Remove null-forgiving operator (!) in BaseTest.AssertApkSigned Jul 11, 2026
Copilot AI requested a review from jonathanpeppers July 11, 2026 02:54
@jonathanpeppers jonathanpeppers marked this pull request as ready for review July 13, 2026 13:36
Copilot AI review requested due to automatic review settings July 13, 2026 13:36
@jonathanpeppers jonathanpeppers merged commit a5c09ec into main Jul 13, 2026
42 checks passed
@jonathanpeppers jonathanpeppers deleted the copilot/fix-finder-remove-null-forgiving-operator branch July 13, 2026 13:36

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 hardens the BaseTest.AssertApkIsSigned test helper by removing a null-forgiving dereference on the Process.Start(ProcessStartInfo) result and replacing it with an explicit null check that throws a clear exception when the process fails to start.

Changes:

  • Replace proc!.StandardOutput... with Process.Start (psi) ?? throw ... to avoid a potential NullReferenceException.
  • Keep the rest of the process interaction (StandardError, WaitForExit, ExitCode) unchanged and !-free.

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.

[fix-finder] Remove null-forgiving operator (!) in BaseTest.AssertApkSigned

4 participants