Skip to content

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

Draft
jonathanpeppers with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-finder-remove-null-forgiving-operator
Draft

Remove null-forgiving operator (!) in BaseTest.AssertApkSigned#12036
jonathanpeppers with Copilot wants to merge 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
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

2 participants