Uh oh!
There was an error while loading. Please reload this page.
feat: Implemented MockDirectory.CreateTempSubDirectory - #964
Conversation
vbreuss
left a comment
There was a problem hiding this comment.
@gregington : Thank you for working on this missing implementation!
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…ith for full temporary path. This is due to MacOS using /private/var when returning the temp path.
gregington
commented
Apr 11, 2023
I changed one of the tests to hopefully work with MacOS and whether the I don't have access to a Windows platform so I couldn't reproduce failure with the |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…19.2.11 (#291) [](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [TestableIO.System.IO.Abstractions](https://togithub.com/TestableIO/System.IO.Abstractions) | nuget | patch | `19.2.9` -> `19.2.11` | --- ### Release Notes <details> <summary>TestableIO/System.IO.Abstractions</summary> ### [`v19.2.11`](https://togithub.com/TestableIO/System.IO.Abstractions/releases/tag/v19.2.11) ##### What's Changed - chore(deps): update dependency dotnet-sdk to v7.0.203 by [@​renovate](https://togithub.com/renovate) in [https://github.com/TestableIO/System.IO.Abstractions/pull/967](https://togithub.com/TestableIO/System.IO.Abstractions/pull/967) - feat: Implemented MockDirectory.CreateTempSubDirectory by [@​gregington](https://togithub.com/gregington) in [https://github.com/TestableIO/System.IO.Abstractions/pull/964](https://togithub.com/TestableIO/System.IO.Abstractions/pull/964) ##### New Contributors - [@​gregington](https://togithub.com/gregington) made their first contribution in [https://github.com/TestableIO/System.IO.Abstractions/pull/964](https://togithub.com/TestableIO/System.IO.Abstractions/pull/964) **Full Changelog**: TestableIO/System.IO.Abstractions@v19.2.9...v19.2.11 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/Testably/Testably.Abstractions). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS40MC4wIiwidXBkYXRlZEluVmVyIjoiMzUuNDAuMCJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This is addressed in release v19.2.11. |
Implemented MockDirectory.CreateTempSubdirectory(). This implementation generates a random 6 character string with an optional user specified prefix and creates the directory in the temporary directory returned by
Path.GetTempPath().The 6 random characters seems to be the algorithm used on my platform (Mac) by the System.IO implementation.
Notes on this PR
MockDirectorynow contains aRandominstance to generate random temp directory names.Random.Sharedcan't be used as it was introduced in .NET 6 it it appears we are supporting earlier .NET versions.MockDirectoryis marked as[Serializable], however theRandominstance cannot be serialized. I have marked theRandominstance as[NonSerialized]and created a newRandominstance on deserializing. The state of the random number generator will be different when deserialized. I don't think this is an issue as there was no way to specify the seed of theRandominstance when creating theMockDirectoryinstance, so there's no way to generate the same sequence of random directories again (besides a very slim chance).<EnableUnsafeBinaryFormatterSerialization>on the test project and#pragma warning disable SYSLIB0011on the deserialize method to allow testing that deserialization of aMockDirectoryalso instantiates a new random number generator. Deserialization is heavily deprecated and this is only on test classes, so I am assuming this is OK.