Make ScanFromPhotosAsync iOS-only - #1
Merged
Merged
Conversation
On Android the method opened ML Kit's camera scanner rather than the
gallery, because ML Kit cannot start in the gallery. Mark it
[SupportedOSPlatform("ios")] so an unguarded call is a CA1416 warning,
and throw NotSupportedException on Android with the alternative in the
message. Android's scanner now always offers its import-from-gallery
button, which is the platform's real gallery route.
Document the per-platform behaviour on both methods so IntelliSense
answers it without the README.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
What
ScanFromPhotosAsyncis now iOS-only: annotated[SupportedOSPlatform("ios")]and throwingNotSupportedExceptionon Android. Android's ML Kit scanner always offers its import-from-gallery button.Why
On Android the method opened the camera scanner, not the gallery — ML Kit cannot start in the gallery. A method named "scan from photos" that opens a camera is misleading, and the intermediate attempts to paper over it (renaming it, adding an
IsScanFromPhotosSupportedflag, anAllowGalleryImportoption) each left the confusion somewhere in the public API.How
The platform annotation turns an unguarded call into a CA1416 compile-time warning instead of a runtime surprise;
OperatingSystem.IsIOS()is the guard consumers use, so no capability property is needed. XML docs on both methods now state the per-platform behaviour, and the Android exception message names the alternative.Testing
dotnet buildon the solution: 0 errors, no CS/CA warnings, bothnet10.0-androidandnet10.0-ios. Confirmed CA1416 actually fires by temporarily dropping the sample's guard and rebuilding. Not redeployed to hardware for this change — the scan flows themselves were device-tested earlier, but the Android gallery-button default and the new throw have not been exercised on a device.Notes for reviewers
Breaking for anyone on 0.1.0 calling
ScanFromPhotosAsyncon Android; recorded under the unreleased 0.2.0 in CHANGELOG. Also folded in three README fixes found while editing those sections: the usage snippet declaredpagesthree times (wouldn't compile if pasted), the platform table'sPageLimitrow was stale, and the text claimedScanAsyncthrowsNotSupportedExceptionon all platforms when only Android does.