This adds a watcher to pick up when a file in the App_Code folder has been modified, and on modification causes a recompile. There is probably a better way of doing it but I figured may as well submit what i did. Feel free to rip it apart.
Damien
--- clean/System.Web/System.Web/HttpApplicationFactory.cs 2007-01-11 18:03:43.000000000 +0000 +++ hacked/System.Web/System.Web/HttpApplicationFactory.cs 2007-01-11 18:08:52.000000000 +0000 @@ -77,6 +77,9 @@ Hashtable app_event_handlers; #if !TARGET_JVM FileSystemWatcher app_file_watcher; +#if NET_2_0 + FileSystemWatcher app_code_watcher; +#endif FileSystemWatcher bin_watcher; FileSystemWatcher config_watcher; #endif @@ -233,10 +236,27 @@ config_watcher.EnableRaisingEvents = false; if (bin_watcher != null) bin_watcher.EnableRaisingEvents = false; +#if NET_2_0 + if (app_code_watcher != null) + app_code_watcher.EnableRaisingEvents = false; +#endif if (app_file_watcher != null) app_file_watcher.EnableRaisingEvents = false; HttpRuntime.UnloadAppDomain (); } +#if NET_2_0 + void OnAppCodeFileRenamed (object sender, RenamedEventArgs args) + { + OnAppCodeFileChanged (sender, args); + } + + void OnAppCodeFileChanged (object sender, FileSystemEventArgs args) + { + AppCodeCompiler acc = new AppCodeCompiler (); + acc.Compile (); + OnAppFileChanged (sender, args); + } +#endif #endif internal static void AttachEvents (HttpApplication app) @@ -461,6 +481,15 @@ RenamedEventHandler reh = new RenamedEventHandler (factory.OnAppFileRenamed); // We watch bin or bin/*.dll if the directory exists factory.bin_watcher = CreateWatcher (bin, fseh, reh); +#if NET_2_0 + string app_code = context.Server.MapPath(@"App_Code"); + if (Directory.Exists (app_code)) + app_code = Path.Combine (app_code, "*.cs"); + + fseh = new FileSystemEventHandler (factory.OnAppCodeFileChanged); + reh = new RenamedEventHandler (factory.OnAppCodeFileRenamed); + factory.app_code_watcher = CreateWatcher (app_code, fseh, reh); +#endif #endif app = factory.FireOnAppStart (context); factory.app_start_needed = false;
_______________________________________________ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list