Uh oh!
There was an error while loading. Please reload this page.
fix: make Mock{File,Directory}Info cache file attributes - #791
Merged
Conversation
This makes them behave more similar to the real file system implementation Fixes#661
fgreinacher
commented
Jan 8, 2022
ContributorAuthor
@BrianMcBrayer Wanna have a look at this? (I warned you in advance 😀) |
…ractions/System.IO.Abstractions into fix/directory-info-exists
BrianMcBrayer
commented
Jan 8, 2022
Contributor
Yeah! I'll take a look today! |
BrianMcBrayer
approved these changes
Jan 8, 2022
BrianMcBrayer
left a comment
Contributor
There was a problem hiding this comment.
Looks really good and clean.
I had one comment/question about multithreading, but I don't think it's an issue.
Uh oh!
There was an error while loading. Please reload this page.
fgreinacher
commented
Jan 9, 2022
ContributorAuthor
Thanks a lot for the quick review! |
This is addressed in release v16.0.8. |
This was referenced Jan 9, 2022
siprbaum added a commit
to siprbaum/System.IO.Abstractions
that referenced
this pull request
Mar 22, 2022
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. FixesTestableIO#822
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This makes them behave more similar to the real file system implementation
Fixes#661