-
Notifications
You must be signed in to change notification settings - Fork 470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restore suppressed maccatalyst for proper flow analysis #7539
Open
buyaa-n
wants to merge
2
commits into
dotnet:main
Choose a base branch
from
buyaa-n:bug_7239
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I quite understand this or why it is specific to
maccatalyst
; it seems like a wider issue.In general a
SupportedOSPlatform("x")
attribute says that the API is supported onx
. If that includes a version then it means it is only supported on that version of x or later. InverselyUnsupportedOSPlatform("x")
attribute indicates the API is not supported onx
or later.If there are only
supported
attributes then platforms other than those listed are automatically deemed unsupported. If there are onlyunsupported
attributes then platforms other than those listed are automatically deemed supported. If there is a mix ofsupported
/unsupported
attributes then there are some rules on whether its consideredallow
,deny
, orinconsistent
.In the scenario given, we only have
supported
and so the API in question works on eitherios
ormaccatalyst
. This means that a guard that only checksIsIOSVersionAtLeast(15, 0)
should be passing for an API marked[SupportedOSPlatform("ios14.0")]
irrespectively of any otherSupportedOSPlatform
in the list; adding backmaccatalyst
should not be required.The fact that
IsIOSVersionAtLeast
also functions as a guard formaccatalyst
via theSupportedOSPlatformGuard
should be irrespective, as it should logically be treated the same asIsIOSVersionAtLeast(..) || IsMacCatalyst()
; which is that it functions as two guards under anor
condition.This change however is making it seem more like its functioning as
IsIOSVersionAtLeast(..) && IsMacCatalyst()
which seems like it is strictly incorrect and likely to lead to other bugs/issuesI would likewise expect this issue to reproduce for any other
SupportedOSPlatformGuard
usage like this scenario, it wouldn't be strictly limited toios+maccatalyst
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to check: Have you had a chance to read #7239 (comment) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but that comment doesn't cover why this is the "right fix". I think rather the actual issue is elsewhere and is what is causing the undesired behavior (that is, which is functionally treating it as an
&&
instead of an||
condition).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is works as you mentioned i.e.
IsIOSVersionAtLeast(..) || IsMacCatalystVersionAtLeast()
and the condition means the guarded code path is reachable on IOS or MacCatalyst, but theDoSomething()
method at that point only supported onios14.0
, when call site also reachable onmaccatalyst
, therefore we need to put the originalmaccatalyst
support backThe change doesn't affect the flow analysis condition. It changes (actually restores) the supported attribute list of method
DoSomething()
to it supported onIsIOS14.0 && MacCatalyst
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, that is how the analyzer works for all other unrelated platforms. But ios and maccatalyst are related:
ios is maccatalyst
butmaccatalyst is not ios
. Analyzer recognize such relation usingSupportedOSPlatformGuard
attribute on guard methods, currently the attribute only applied onIsIOS...
methods. There is lots of rules around how to handle this relation, check the original issue requirement for more info