RazorEngine
RazorEngine copied to clipboard
Fix event args generation for FileSystemWatcher of the WatchingResolvePathTemplateManager
The FileSystemEventArgs takes as argument the directory path, not the full path to the file: https://docs.microsoft.com/en-us/dotnet/api/system.io.filesystemeventargs.-ctor?view=netframework-4.7.2 I tried to use WatchingResolvePathTemplateManager for debugging, but when you change template in Visual Studio it actually fires 7 events, for example (not exactly in that order):
- Created "DirectoryPath\vfg3ps5n.nrj~"
- Created "DirectoryPath\Filename.cshtml~RF432f4415.TMP"
- Deleted "DirectoryPath\Filename.cshtml~RF432f4415.TMP"
- Renamed "DirectoryPath\Filename.cshtml" -> "DirectoryPath\Filename.cshtml~RF432f4415.TMP"
- Renamed "DirectoryPath\vfg3ps5n.nrj~" -> "DirectoryPath\Filename.cshtml"
- Changed "DirectoryPath\vfg3ps5n.nrj~"
- Deleted "DirectoryPath\Filename.cshtml~RF432f4415.TMP"
So if we are looking for DirectoryPath\Filename.cshtml, it will be mentioned only in 'Renamed' event. But it was not working correctly, because of wrong FileEventArgs parameters.