Hot reloading reacts to >1 file change notification representing a single "Save File" action. DAB should only react to the first file change event which represents processing the changed file. DAB should only react to subsequent file change events when the file has actually changed.
What is this change?
Modifies ConfigFileWatcher class such that it no longer needs to have FileSystemRuntimeConfigLoader as a dependency/constructor parameter. ConfigFileWatcher just called the passed in loader's methods which was a confusing layer of abstraction.
ConfigFileWatcher now (due to this PR's changes) has a hash persistence mechanism of runtimeconfig file contents and compares the currently tracked hash to a new hash calculated on the file after a "file change" event is emitted from the file watcher. One file change (e.g. clicking save in a text editor) causes multiple file change events to be detected by the file watcher (Added code comments to clarify). Dotnet docs describe the hashing mechanism included in this PR as a way to "ignore" subsequent file change events and only act on one event per file change.
Due to collision problems with SHA1, Microsoft recommends a security model based on SHA256 or better.
ConfigFileWatcher now raises an event (NewFileContentsDetected) when the hash of the old versus new runtime config file is detected. FileSystemRuntimeConfigLoader subscribes to NewFileContentsDetected and
reacts by calling HotReloadConfig(...)
Fixes how FileSystemRuntimeConfigLoader reads the config file to avoid issues where the disposable doesn't immediately close the file handle and we get occurrences of "IOException file being used by another process". Now using File.ReadAllText so that the file handle is closed immediately.
Adds field _isCliLoader to FIleSystemRuntimeConfigLoader so DAB knows not to init filewatcher for CLI usage. This fixed a pipeline file IO bug due to CLI usage of filesystemruntimeconfigloader initializing the file watcher.
How was this tested?
The following two integration tests are added to validate the functionality of the modified ConfigFileWatcher class. These tests immitate a user change the runtime config file's contents (or not changing contents) and the test check that the NewFileContentsDetected is raised the expected number times.
Why make this change?
What is this change?
ConfigFileWatcher
class such that it no longer needs to haveFileSystemRuntimeConfigLoader
as a dependency/constructor parameter.ConfigFileWatcher
just called the passed in loader's methods which was a confusing layer of abstraction.FileSystemRuntimeConfigLoader
subscribes toNewFileContentsDetected
and reacts by callingHotReloadConfig(...)
FileSystemRuntimeConfigLoader
reads the config file to avoid issues where the disposable doesn't immediately close the file handle and we get occurrences of "IOException file being used by another process". Now using File.ReadAllText so that the file handle is closed immediately._isCliLoader
to FIleSystemRuntimeConfigLoader so DAB knows not to init filewatcher for CLI usage. This fixed a pipeline file IO bug due to CLI usage of filesystemruntimeconfigloader initializing the file watcher.How was this tested?
The following two integration tests are added to validate the functionality of the modified
ConfigFileWatcher
class. These tests immitate a user change the runtime config file's contents (or not changing contents) and the test check that theNewFileContentsDetected
is raised the expected number times.ConfigFileWatcher_NotifiedOfOneNetNewChanges
ConfigFileWatcher_NotifiedOfZeroNetNewChange