Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: TestableIO/System.IO.Abstractions
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v19.2.9
Choose a base ref
...
head repository: TestableIO/System.IO.Abstractions
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v19.2.11
Choose a head ref
  • 2 commits
  • 3 files changed
  • 2 contributors

Commits on Apr 11, 2023

  1. chore(deps): update dependency dotnet-sdk to v7.0.203 (#967)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Apr 11, 2023
    Configuration menu
    Copy the full SHA
    85fc762 View commit details
    Browse the repository at this point in the history

Commits on Apr 13, 2023

  1. feat: Implemented MockDirectory.CreateTempSubDirectory (#964)

    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
    1. There's a potential temporary directory namespace of $62^6$ or about 56.8 billion. As we get closer to this limit, the likelihood of generating a duplicate increases as well as the likelihood of slowdowns of the random generation. At the extreme case, if all possible temporary directories are created, creating a random directory name will effectively become an infinite loop. I assume we don't need to handle conditions close to the limit.
    2. `MockDirectory` now contains a `Random` instance to generate random temp directory names. `Random.Shared` can't be used as it was introduced in .NET 6 it it appears we are supporting earlier .NET versions.
    3. `MockDirectory` is marked as `[Serializable]`, however the `Random` instance cannot be serialized. I have marked the `Random` instance as `[NonSerialized]` and created a new `Random` instance 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 the `Random` instance when creating the `MockDirectory` instance, so there's no way to generate the same sequence of random directories again (besides a very slim chance).
    4. I have had to add `<EnableUnsafeBinaryFormatterSerialization>` on the test project and `#pragma warning disable SYSLIB0011` on the deserialize method to allow testing that deserialization of a `MockDirectory` also instantiates a new random number generator. Deserialization is heavily deprecated and this is only on test classes, so I am assuming this is OK.
    gregington authored Apr 13, 2023
    Configuration menu
    Copy the full SHA
    941f487 View commit details
    Browse the repository at this point in the history
Loading