Are file operations slower in directories containing many files? NTFS and ReFS (DevDrive) tested

I’ll share the results of a quick benchmark testing how the number of files in a directory impacts the following filesystem operations executed from a .NET application: My motivation was to decide if it was a good design performance-wise to have a single directory containing many cache files. I’m thinking about the order of magnitude … Read more

.NET 7 warning: use ‘GeneratedRegexAttribute’ (SYSLIB1045)

.NET 7 introduced the [GeneratedRegex] attribute that allows doing some regex initialization in compile time rather than in runtime. Using this attribute might help improve performance. Therefore some tooling might start showing you a warning that you miss an opportunity for free performance gains 🙂 SYSLIB1045 Use ‘GeneratedRegexAttribute’ to generate the regular expression implementation at … Read more

Migrate from Jetbrains.Annotations [NotNull] / [CanBeNull] to C# Nullable Reference Types

The most popular feature of JetBrains.Annotations is probably the addition of two cool attributes: [NotNull] and [CanBeNull]. They add a meta-information to a marked element, describing if null is a correct value for that element, or not. Then, developers using ReSharper would get help from the IDE and could easier avoid mistakes like here: I … Read more

Moq: Extension methods (here: LoggerExtensions.LogError) may not be used in setup / verification expressions.

Sometimes when we develop unit tests it’s convenient to check if the tested code wrote something to the log. Is it a good practice to assert that some particular message appeared in the logs? I think there are pros and cons. On the pros side, we can make general assertions like “no errors were written … Read more