microsoft / referencesource

Source from the Microsoft .NET Reference Source that represent a subset of the .NET Framework
https://referencesource.microsoft.com/
MIT License
3.13k stars 1.26k forks source link

System.Collections.Generic.List<T> Sort(Comparison<T> comparison) doesn't invalidate the enumerator #169

Open BalintPogatsa opened 2 years ago

BalintPogatsa commented 2 years ago

Incrementing the _version field is probably missing from one overload of the Sort method in List after calling Array.Sort

https://github.com/microsoft/referencesource/blob/5697c29004a34d80acdaf5742d7e699022c64ecd/mscorlib/system/collections/generic/list.cs#L992

svick commented 2 years ago

This repository is not the right place to report issues with .Net.

For .Net Core/.Net 5+, this has already been fixed in https://github.com/dotnet/coreclr/pull/8944.

For .Net Framework, you could report this issue on Developer Community, but I'm not convinced it would be fixed, considering the status of .Net Framework.

BalintPogatsa commented 2 years ago

Thank you for the info. Somehow I didn't manage to find List.cs in dotnet/runtime (System.Private.CoreLib did not seem like a place for the old System.Collections.Generic... )

I think that .NET Framework 4.8 still has a lifecycle without an end date, so I also thought these kind of bugfixes would be backported. Probably not a priority for MS.