Add spec for platform exclusion#143
Conversation
eerhardt
left a comment
There was a problem hiding this comment.
Looks like a good start to me. Some early thoughts.
|
|
||
| ```XML | ||
| <ItemGroup> | ||
| <SupportedPlatform Include="android" /> |
There was a problem hiding this comment.
Looking at dotnet/sdk#12547, we already have an MSBuild item named SupportedTargetPlatform. Are we intending this to be the same thing as that? If not, these names are too similar to both be used.
There was a problem hiding this comment.
Right now we're using SupportedTargetPlatform as an itemgroup containing the supported TargetPlatformVersions that correspond to the specified TargetPlatformIdentifier.
There was a problem hiding this comment.
So no then 😄 . Your notion of supported is "what can this SDK produce" while mine is "what platforms is the author of this project file intending to support". We probably need a different name then.
There was a problem hiding this comment.
Your notion of supported is "what can this SDK produce"
Should we rename the SDK itemgroup then? I think the name SupportedTargetPlatform sounds like it is what target platforms the current project supports, not necessarily what the SDK supports.
There was a problem hiding this comment.
@dsplaisted were should I file a bug to discuss renaming the SDK's SupportedTargetPlatform item group?
There was a problem hiding this comment.
In dotnet/sdk.
Note that there was already a SupportedTargetFramework item which we use to populate the TargetFramework dropdown on the VS property page, so we went with the same pattern for SupportedTargetPlatform.
There was a problem hiding this comment.
Makes sense. In that sense I think we should come up with a new name for the analyzer. Let me chew on that.
|
I keep thinking about how the crux of the challenge we're having is that marking a specific OSPlatform as supported implies that no other platforms are supported, but we don't always want that behavior. [MinimumOSPlatform("windows7.0")]
public void WindowsOnlyAPI() {}
[MinimumOSPlatform("ios14")]
public void WorksEverywhereButOnIosVersion14IsRequired() {}If we set that problem aside for a moment, and we focus purely on excluding an OSPlatform, then I think we're otherwise OK. The following would just work, wouldn't it? [UnsupportedOSPlatform("browser")]
public void WorksEverywhereExceptBrowser() {}I believe the ranges were being introduced so that we could use I'm really concerned about the range support, regardless of the syntax. It makes the data harder to reason over as a human code reader, and potentially more brittle when reasoning over in the analyzer implementation. I think we'd introduce a higher likelihood that the data will be incomprehensible and then the analyzer will need to introduce more diagnostics for when that's the case. So what if we did the following?
I think we could then satisfy our scenarios: [MinimumOSPlatform("windows7.0")]
public void WindowsOnlyAPI() {}
[MinimumOSPlatform("ios14.0", IsExclusive = false)]
public void WorksEverywhereButOnIosVersion14IsRequired() {}
[UnsupportedOSPlatform("browser")]
public void WorksEverywhereExceptBrowser() {}The evolution of an API going from unsupported to having a minimum version required for support would involve changing To show an edge case where something comes in and out of support for a platform repeatedly: [MinimumOSPlatform("ios12.0", IsExclusive = false)]
[UnsupportedOSPlatform("ios14.0")]
[MinimumOSPlatform("ios12.0", IsExclusive = false)]
[MinimumOSPlatform("ipados16.0", IsExclusive = false)]
public void Worked_In_12_And_13_But_Not_14_Or_15_But_Works_Again_In_16() {}If this approach has merit, then I'd suggest that we also rename By default, a To address the [concern of introducing another means for obsoleting an API]([MinimumOSPlatform("ios12.0", IsExclusive = false)]), I suggest we remove the To summarize, I propose that we:
|
jeffhandley
left a comment
There was a problem hiding this comment.
Thank you @terrajobst! I left some comments and primary have 2 topics that will need resolution:
- Should we use a
params string[] platformNamesconstructor with the iOS family of platforms in mind? - I think we had problems with the
||based guards; I'll need @buyaa-n to weigh in there.
This is a more meaningful scenario than the other |
Co-authored-by: Jeff Handley <jeffhandley@users.noreply.github.com>
Co-authored-by: Jeff Handley <jeffhandley@users.noreply.github.com>
No description provided.