Update the flow analysis result evaluation to account the call site reachability #5571
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.
Customer Impact
This fixes a customer-reported issue related to a combination of
SupportedOSPlatform
attributes along with flow analysis handling ofOperatingSystem
guard methods. With this edge case bug, we report a false-positive diagnostic on a call site, indicating that the call site is reachable on a version of the platform that differs from what is actually reachable.Here is the specific scenario that was reported:
It is caused by the logic we use for evaluating the flow analysis result, we suppress warnings with 2 steps:
[SupportedOSPlatform("android23.0")] [SupportedOSPlatform("ios13.0")]
attributes are suppressed (removed), therefore only unmatching[SupportedOSPlatform("windows10.0.10240")]
will be left for MyType!Windows() || Windows10OrLater()
is guarding the API call, from the OR conditionals the!Windows()
is not guarding the API for the remaining attribute[SupportedOSPlatform("windows10.0.10240")]
therefore there is a warningThe issue is we are not accounting for the call site reachability when evaluating the flow analysis result. The fix here is now accounting for that in the flow analysis result evaluation.
Testing
We have thorough unit test coverage for related scenarios, and new tests were added for these edge cases.
Risk
Low. Minimal performance implications of adding additional code during flow analysis evaluation of which platforms/versions can reach the call site.