RazorEngine icon indicating copy to clipboard operation
RazorEngine copied to clipboard

Fix event args generation for FileSystemWatcher of the WatchingResolvePathTemplateManager

Open Lunatic174 opened this issue 7 years ago • 0 comments

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):

  1. Created "DirectoryPath\vfg3ps5n.nrj~"
  2. Created "DirectoryPath\Filename.cshtml~RF432f4415.TMP"
  3. Deleted "DirectoryPath\Filename.cshtml~RF432f4415.TMP"
  4. Renamed "DirectoryPath\Filename.cshtml" -> "DirectoryPath\Filename.cshtml~RF432f4415.TMP"
  5. Renamed "DirectoryPath\vfg3ps5n.nrj~" -> "DirectoryPath\Filename.cshtml"
  6. Changed "DirectoryPath\vfg3ps5n.nrj~"
  7. 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.

Lunatic174 avatar Oct 25 '18 19:10 Lunatic174