Skip to content
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

feat: adjust timestamps when accessing and modifying files #861

Merged

Conversation

xtopaz
Copy link
Contributor

@xtopaz xtopaz commented Jun 29, 2022

For tests with MockFiles we would like to have the same behaviour as on a real
file system regarding the timestamps on the copied file.

This sets the timestamps for copied MockFile instances so that the CreationTime
and LastAccessTime get the timestamp of the copy operation and the LastWriteTime
is inherited from the source as before.
@xtopaz xtopaz changed the title Add adjusted timestamps on copied MockFiles feat: Add adjusted timestamps on copied MockFiles Jun 29, 2022
@fgreinacher
Copy link
Contributor

This looks very similar to #860

This fixes setting of the appropriate timestamps in the MockFileData
instances, when accessing them via the MockFileStream.

This contains the implementation intended in TestableIO#860.
@xtopaz
Copy link
Contributor Author

xtopaz commented Jul 3, 2022

Unfortunately after my last commit 920527b an issue cropped up in the static code analysis which claims that "'existingContents' is null on at least one execution path." in src/System.IO.Abstractions.TestingHelpers/MockFileStream.cs#L44.
@fgreinacher, since this is obviously a false positive, could you please set it to ignore?

Copy link
Contributor

@siprbaum siprbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline comments, mainly clarifications needed.

This removes the premature update of the LastAccessTime timestamp when a
MockFileStream is opened.
@fgreinacher
Copy link
Contributor

Unfortunately after my last commit 920527b an issue cropped up in the static code analysis which claims that "'existingContents' is null on at least one execution path." in src/System.IO.Abstractions.TestingHelpers/MockFileStream.cs#L44. @fgreinacher, since this is obviously a false positive, could you please set it to ignore?

Sure, done! Thanks for having a look at this!

@fgreinacher fgreinacher changed the title feat: Add adjusted timestamps on copied MockFiles feat: adjust timestamps when modifying files Jul 4, 2022
@fgreinacher fgreinacher changed the title feat: adjust timestamps when modifying files feat: adjust timestamps when accessing and modifying files Jul 4, 2022
@fgreinacher
Copy link
Contributor

Thanks a lot for your contribution @xtopaz.

Also thanks @siprbaum for helping with the review!

@github-actions
Copy link

This is addressed in release v17.0.21.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: released Issues that are released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants