-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: make Mock{File,Directory}Info cache file attributes #791
Conversation
This makes them behave more similar to the real file system implementation Fixes #661
@BrianMcBrayer Wanna have a look at this? (I warned you in advance 😀) |
…ractions/System.IO.Abstractions into fix/directory-info-exists
Yeah! I'll take a look today! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good and clean.
I had one comment/question about multithreading, but I don't think it's an issue.
Thanks a lot for the quick review! |
This is addressed in release v16.0.8. |
In 5216e0d ("fix: make Mock{File,Directory}Info cache file attributes (TestableIO#791)", 2022-01-09) a cache of the MockFileData was introduced, to mimic the behaviour that a FileInfo object will not read the data from disk but instead also remembers its internal state, which can be updated by calling its `Refresh` method. This internal (or cached state) is invalidated when calling the methods `Create`, `Delete` and `MoveTo` methods, as can be seen by the `Invalidate` calls in https://github.com/dotnet/runtime/blob/8766a1cf1ed6c3b69cef50154139699b72fb52c5/src/libraries/System.Private.CoreLib/src/System/IO/FileInfo.cs In the PR TestableIO#791 it was overlooked to also invalidate the cached data in these methods. This commit fixes it by invalidating the cached data only for `Create`, `CreateText` and `Delete`. The two `MoveTo` variants are not changed as I could not manage to find any behaviour which is broken without that invalidation. Most likely reason is that the MockFileData is updated to represent the destination file ofter the move, so invalidating is not needed. Fixes TestableIO#822
This makes them behave more similar to the real file system implementation
Fixes #661