Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ public void GetDefaultBasePathForSources()

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
[SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Browser | TestPlatforms.iOS | TestPlatforms.tvOS, "System.IO.FileSystem.Watcher is not supported on Browser/iOS/tvOS")]
public void CanEnumerateProviders()
{
var config = CreateBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ internal PhysicalFilesWatcher CreateFileWatcher()

FileSystemWatcher watcher;
#if NETCOREAPP
// 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())
{
UsePollingFileWatcher = true;
UseActivePolling = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public PhysicalFilesWatcher(
if (fileSystemWatcher != null)
{
#if NETCOREAPP
if (OperatingSystem.IsBrowser())
if (OperatingSystem.IsBrowser() || (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS())
{
throw new PlatformNotSupportedException(SR.Format(SR.FileSystemWatcher_PlatformNotSupported, typeof(FileSystemWatcher)));
}
Expand Down Expand Up @@ -148,7 +148,7 @@ public IChangeToken CreateFileChangeToken(string filter)
}

IChangeToken changeToken = GetOrAddChangeToken(filter);
// We made sure that browser never uses FileSystemWatcher.
// We made sure that browser/iOS/tvOS never uses FileSystemWatcher.
#pragma warning disable CA1416 // Validate platform compatibility
TryEnableFileSystemWatcher();
#pragma warning restore CA1416 // Validate platform compatibility
Expand Down Expand Up @@ -276,6 +276,9 @@ protected virtual void Dispose(bool disposing)
}

[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
private void OnRenamed(object sender, RenamedEventArgs e)
{
// For a file name change or a directory's name change notify registered tokens.
Expand Down Expand Up @@ -309,12 +312,18 @@ ex is DirectoryNotFoundException ||
}

[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
private void OnChanged(object sender, FileSystemEventArgs e)
{
OnFileSystemEntryChange(e.FullPath);
}

[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
private void OnError(object sender, ErrorEventArgs e)
{
// Notify all cache entries on error.
Expand All @@ -325,6 +334,9 @@ private void OnError(object sender, ErrorEventArgs e)
}

[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
private void OnFileSystemEntryChange(string fullPath)
{
try
Expand All @@ -348,6 +360,9 @@ ex is SecurityException ||
}

[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
private void ReportChangeForMatchedEntries(string path)
{
if (string.IsNullOrEmpty(path))
Expand Down Expand Up @@ -385,6 +400,9 @@ private void ReportChangeForMatchedEntries(string path)
}

[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
private void TryDisableFileSystemWatcher()
{
if (_fileWatcher != null)
Expand All @@ -403,6 +421,9 @@ private void TryDisableFileSystemWatcher()
}

[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
private void TryEnableFileSystemWatcher()
{
if (_fileWatcher != null)
Expand Down
Loading