Enable nullable reference types in DetectIfAppWasUninstalled.cs#11599
Merged
jonathanpeppers merged 2 commits intoJun 8, 2026
Conversation
9 tasks
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Enable nullable reference types in DetectIfAppWasUninstalled
Enable nullable reference types in Jun 8, 2026
DetectIfAppWasUninstalled.cs
jonathanpeppers
approved these changes
Jun 8, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enables nullable reference types in DetectIfAppWasUninstalled.cs (a debugging MSBuild task) and updates task properties/method signatures to follow the repo’s nullable conventions for netstandard2.0.
Changes:
- Added
#nullable enableto opt the file into nullable analysis. - Updated task properties: non-required inputs (
AdbTarget,UserID) tostring?, and[Required]inputs (PackageName,UploadFlagFile) to non-nullablestringwith= ""defaults. - Adjusted
QueryPackagessignature to return a nullable list (currentlyTask<List<AndroidInstalledPackage>?>).
Comments suppressed due to low confidence (1)
src/Xamarin.Android.Build.Debugging.Tasks/Tasks/DetectIfAppWasUninstalled.cs:65
- ❌ Changing
QueryPackagesto returnTask<List<AndroidInstalledPackage>?>breaks the registered task object type:WaitForAppDetectionretrieves it asTask<List<AndroidInstalledPackage>>(seeWaitForAppDetection.cs:16-21), so the lookup can fail due to the generic type mismatch and the wait will be skipped. Also, in nullable contextUser = UserIDwill produce a nullability warning becausePmListPackagesCommand.Useris a non-nullablestring. Keep the return type non-nullable, coalesceUserIDto"", and return an empty list on failure instead ofnull.
async System.Threading.Tasks.Task<List<AndroidInstalledPackage>?> QueryPackages (AndroidDevice device, string uploadFlagFileFullPath)
{
// DO NOT use the Log.XXXX methods in this method.
// Because this is running on a background thread they will
// end up locking the UI in VS.
Comment on lines
+26
to
28
| public string? UserID { get; set; } | ||
|
|
||
| public CancellationToken Token { get { return tcs.Token; } } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enable
#nullable enableinDetectIfAppWasUninstalled.csand apply standard nullable conventions.AdbTarget,UserID) →string?[Required]properties (PackageName,UploadFlagFile) →stringwith= ""defaultQueryPackagesreturn type →Task<List<AndroidInstalledPackage>?>(returnsnullincatch)Project targets
netstandard2.0, so noArgumentNullException.ThrowIfNullusage.