Fix for FilePicker PickMultipleAsync nullable reference type #33163
+17
−17
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.
RootCause
FilePicker.PickMultipleAsync()has incorrect nullable reference type annotations causing compiler warnings with#nullable enable. When checking if the result is null, the compiler warns "Expression is always true" becauseIEnumerable<FileResult?>is not marked nullable, even though the method returns null.Reason for Regression:
PR #27961 attempted to fix null return behavior but applied the annotation incorrectly, making items nullable
(Task<IEnumerable<FileResult?>>)instead of making the collection nullable(Task<IEnumerable<FileResult>?>).Description of Change:
The fix moves the nullable marker from collection items to the collection itself, changing
Task<IEnumerable<FileResult?>>toTask<IEnumerable<FileResult>?>in the IFilePicker interface, FilePicker static class, and FilePickerImplementation class.Issues Fixed
Fixes #33114
Tested the behaviour on the following platforms
Note:
Test Case: Not applicable. This fix corrects nullable annotations only and does not change runtime behavior. The scenario cannot be validated through automated tests.