Skip to content

Conversation

@akoeplinger
Copy link
Member

@akoeplinger akoeplinger commented Aug 25, 2021

In #57931 we found out that the FSEventStream APIs which are used to implement System.IO.FileSystem.Watcher aren't allowed on the App Store.
According to Apple's docs these APIs are only supported on macOS and Mac Catalyst.

Mark System.IO.FileSystem.Watcher as unsupported on iOS/tvOS and throw PNSE.
Switch PhysicalFileProvider to use active polling instead, like we do for Browser.

Addresses #57931

@ghost
Copy link

ghost commented Aug 25, 2021

Tagging subscribers to this area: @maryamariyan, @dotnet/area-extensions-filesystem
See info in area-owners.md if you want to be subscribed.

Issue Details

In #57931 we found out that the FSEventStream APIs which are used to implement System.IO.FileSystemWatcher aren't allowed on the App Store.
According to Apple's docs these APIs are only supported on macOS and Mac Catalyst.

Mark System.IO.FileSystemWatcher as unsupported on iOS/tvOS and throw PNSE.
Switch PhysicalFileProvider to use active polling instead, like we do for Browser.

Addresses #57931

Author: akoeplinger
Assignees: -
Labels:

area-Extensions-FileSystem

Milestone: -

@akoeplinger akoeplinger requested a review from steveisok August 25, 2021 23:07
… on iOS/tvOS

In dotnet#57931 we found out that the FSEventStream APIs which are used to implement System.IO.FileSystemWatcher aren't allowed on the App Store.
According to [Apple's docs](https://developer.apple.com/documentation/coreservices/1443980-fseventstreamcreate) these APIs are only supported on macOS and Mac Catalyst.

Mark System.IO.FileSystemWatcher as unsupported on iOS/tvOS and throw PNSE.
Switch PhysicalFileProvider to use active polling instead, like we do for Browser.

Addresses dotnet#57931
@akoeplinger akoeplinger force-pushed the physicalfileprovider-polling branch from 742ac2a to f2d56e3 Compare August 25, 2021 23:48
// For browser we will proactively fallback to polling since FileSystemWatcher is not supported.
if (OperatingSystem.IsBrowser())
// For browser/iOS/tvOS we will proactively fallback to polling since FileSystemWatcher is not supported.
if (OperatingSystem.IsBrowser() || (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS())
Copy link
Member

@am11 am11 Aug 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, ideally we should have a runtime config like System.Globalization.Invariant corresponding to DOTNET_USE_POLLING_FILE_WATCHER environment variable; given how many different machine setups in practice are requiring fallback to polling even on Linux/macOS (see commit history / issues redirecting from aspnetcore when it broke on .NET 5 and still is broken since the fix was never backported..)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree. Something to keep in mind for .NET 7 but I'll keep this more focused change since we need to backport to .NET 6.

@akoeplinger
Copy link
Member Author

/backport to release/6.0-rc1

@github-actions
Copy link
Contributor

Started backporting to release/6.0-rc1: https://github.com/dotnet/runtime/actions/runs/1169962239

[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@buyaa-n - what does it say about other platforms (windows, linux, etc) when you have some attributes as UnsupportedOSPlatform and some attributes SupportedOSPlatform? What does this combination mean for windows?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I talked to @buyaa-n and there's apparently a special case in the analyzer where this pattern causes it to be marked unsupported on iOS and supported on MacCatalyst and everywhere else.

Copy link
Member

@am11 am11 Aug 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsupported on iOS and supported on MacCatalyst and everywhere else.

Wouldn't it be the case if we e.g. delete [SupportedOSPlatform("maccatalyst")] line? Unsupported on ios, tvos and browser and supported everywhere else (including maccatalyst)
Or does [UnsupportedOSPlatform("ios")] somehow imply; unsupported on ios && maccatalyst?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @akoeplinger. I found the PR that implemented this: dotnet/roslyn-analyzers#5266. It has a lot of good information on this specific situation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or does [UnsupportedOSPlatform("ios")] somehow imply; unsupported on ios && maccatalyst?

Yes [UnsupportedOSPlatform("ios")] imply unsupported on ios && maccatalyst (with latest change made in 6.0), to remove macatalyst unsupport from there need to add [SupportedOSPlatform("maccatalyst")]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concern was that adding [SupportedOSPlatform("maccatalyst")] didn't imply that it wasn't supported on other platforms, like windows and linux.

Copy link
Contributor

@buyaa-n buyaa-n Aug 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concern was that adding [SupportedOSPlatform("maccatalyst")] didn't imply that it wasn't supported on other platforms, like windows and linux.

Originally it would imply what you said, but with the latest update for macatalyst-ios relation we special case related platforms scenario and this [SupportedOSPlatform("maccatalyst")] would only remove maccatalyst part from ios-maccatalyst relation

@ghost ghost locked as resolved and limited conversation to collaborators Sep 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants