Bug 19741 - FileSystemWatcher does not pick up changes in files on OSX
Summary: FileSystemWatcher does not pick up changes in files on OSX
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-05-13 18:02 UTC by Miguel de Icaza [MSFT]
Modified: 2015-04-16 14:47 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Miguel de Icaza [MSFT] 2014-05-13 18:02:57 UTC
The following test case shows the problem, it does not seem to raise any events for changes in files:

Compile like this:
mcs foo.cs

Run like this:
mkdir mydir
mono foo.exe mydir

Then make changes on another window to the contents of mydir.

Possibly connected to bug 16259.

using System;
using System.IO;
using System.Threading;

namespace OtherStuff
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            var fswatcher = new FileSystemWatcher(); 
            fswatcher.Path = args [0];
            fswatcher.IncludeSubdirectories = true; 
            fswatcher.Renamed += (object sender, RenamedEventArgs e) => { 
                Console.Error.WriteLine ("Renamed '" + e.OldFullPath + "' to '" + e.FullPath + "'"); 
                Console.Error.Flush (); 
            }; 
            fswatcher.Deleted += (object sender, FileSystemEventArgs e) => { 
                Console.Error.WriteLine("Deleted '"+e.FullPath+"'"); 
                Console.Error.Flush (); 
            }; 
            fswatcher.Changed += (object sender, FileSystemEventArgs e) => { 
                Console.Error.WriteLine("Changed '"+e.FullPath+"'"); 
                Console.Error.Flush (); 
            }; 
            fswatcher.Created += (object sender, FileSystemEventArgs e) => { 
                Console.Error.WriteLine("Created '"+e.FullPath+"'"); 
                Console.Error.Flush (); 
            }; 
            fswatcher.Error += (object sender, ErrorEventArgs e) => { 
                Console.Error.WriteLine ("Error"); 
                Console.Error.Flush (); 
                throw new Exception ("Error"); 
            }; 

            fswatcher.EnableRaisingEvents = true; 

            Thread.Sleep (int.MaxValue); 
        }
    }
}
Comment 1 David Fowler 2014-06-24 00:04:27 UTC
Any progress on this?
Comment 2 Miguel de Icaza [MSFT] 2014-06-24 08:47:08 UTC
I'll exchange information for some merging of our pull request :-)
Comment 3 Dylan Borg 2014-07-09 12:55:00 UTC
This bug also occurs on Linux making ASP.NET vNext not respond to file changes
Comment 4 Miguel de Icaza [MSFT] 2014-07-09 14:29:18 UTC
We have a pending pull request, but it only addresses the OSX backend and the test suite is not working, so we need to either determine if this is a regression, or if it is a bug in the implementation).

Linux probably suffers from something similar.  You might want to study the pull request and figure out if Linux suffers from it.

Currently on vacation, so I wont be able to spend much time following up on this.
Comment 5 Rogier Rietdijk 2015-02-05 07:13:07 UTC
It's  still not working...:-(
Comment 6 Miguel de Icaza [MSFT] 2015-04-16 14:47:48 UTC
This is fixed in Mono 4.0