We've traced an EF Core issue to a behavioral difference between .NET Framework and Core, and I'd like to be sure we have the right picture.
The scenario in question was enumerating the Dictionary's values and removing entries during that enumeration. While in certain cases .NET Framework throws InvalidOperationException ("Collection was modified"), .NET Core does not ever seem to do so. It's worth emphasizing that no concurrency is involved - a single thread is doing all the operations. A cursory look at Dictionary.cs shows that ConcurrentOperationsNotSupported exceptions are thrown only from mutating methods, but enumerators don't seem to throw them.
/cc @stephentoub @jkotas @benaadams @ajcvickers
Is it correct to say that the current implementation of Dictionary supports non-concurrent mutation during iteration?
Only removal. This was enabled as a feature in https://github.com/dotnet/coreclr/pull/18854.
is this something that can be depended on going forward
Yes.
We should ensure the docs are updated to reflect this.
Great, thanks!
@roji do you want to open an issue (or PR) against https://github.com/dotnet/dotnet-api-docs/ ? That's the place for it.
Yep @danmosemsft, will do that soon.
OK, let's close this then. Thanks.
Most helpful comment
Only removal. This was enabled as a feature in https://github.com/dotnet/coreclr/pull/18854.
Yes.
We should ensure the docs are updated to reflect this.