You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EmptyDirectoryConstraint currently tries to read in and instantiate all content in a directory in order to determine if the directory is empty or not empty.
An alternative could be to use one call to EnumerateFileSystemInfos().Any() to detect existence of either files or subdirectories without instantiating a whole array of them. Unfortunately, this API isn't available in .NET 35, so some sort of fallback would be required to go this route. A fallback could be either the currently implementation, or using GetFileSystemInfos().Any(). Example:
EmptyDirectoryConstraint
currently tries to read in and instantiate all content in a directory in order to determine if the directory is empty or not empty.https://github.com/nunit/nunit/blob/master/src/NUnitFramework/framework/Constraints/EmptyDirectoryConstraint.cs#L55-L57
An alternative could be to use one call to
EnumerateFileSystemInfos().Any()
to detect existence of either files or subdirectories without instantiating a whole array of them. Unfortunately, this API isn't available in .NET 35, so some sort of fallback would be required to go this route. A fallback could be either the currently implementation, or usingGetFileSystemInfos().Any()
. Example:I've done a quick verification via BenchmarkDotNet, and it seems promising (N = number of files, N/2 = number of subdirectories)
The text was updated successfully, but these errors were encountered: