1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 15:33:04 +08:00
osu-lazer/osu.Game/Screens
Bartłomiej Dach cefbc76490
Fix selection being dropped when changing carousel sort mode from difficulty sort
Closes https://github.com/ppy/osu/issues/29738.

This "regressed" in https://github.com/ppy/osu/pull/29639, but if I
didn't know better, I'd go as far as saying that this looks like a .NET
bug, because the fact that PR broke it looks not sane.

The TL;DR on this is that before the pull in question, the offending
`.Contains()` check that this commit modifies was called on a
`List<BeatmapSetInfo>`. The pull changed the collection type to
`BeatmapSetInfo[]`. That said, the call is a LINQ call, so all good,
right?

Not really. First off, the default overload resolution order means that
the previous code would call `List<T>.Contains()`, and not
`Enumerable.Contains<T>()`. Then again, why would that matter? In both
cases `T` is still `BeatmapSetInfo`, right? Well... about that...

It is difficult to tell for sure what precisely is happening here,
because of what looks like runtime magic. The end *symptom* is that the
old code ended up calling `Array<BeatmapSetInfo>.IndexOf()`, and the new
code ends up calling... `Array<object>.IndexOf()`.

So while yes, `BeatmapSetInfo` implements `IEquatable` and
the expectation would be that `Equals<BeatmapSetInfo>()` should be
getting called, the type elision to `object` means that we're back to
reference equality semantics, because that's what
`EqualityComparer.Default<object>` is.

A five-minute github search across dotnet/runtime yields this:

	c4792a228e/src/coreclr/vm/array.cpp (L984-L990)

Now again, if I didn't know better, I'd see that "OPTIMIZATION:"
comment, see what transpired in this scenario, and call that
optimisation invalid, because it changes semantics. But I *probably*
know that the dotnet team knows better and am probably just going to
take it for what it is, because blame on that code looks to be years
old and it's probably not a new behaviour. (I haven't tested empirically
if it is.)

Instead the fix is just to tell the `.Contains()` method to use the
correct comparer.
2024-09-08 16:06:35 +02:00
..
Backgrounds Remove requirement of specifying animateOnnter in BackgroundScreen ctor 2024-08-07 19:07:44 +09:00
Edit Fix scroll speed slider defaulting to 0.01 2024-09-07 01:44:40 -03:00
Footer Explicitly define Hue rather than implicitly provide it by enum value 2024-07-18 00:26:24 +03:00
Import Merge branch 'master' into update-framework 2022-11-26 16:19:36 +01:00
Menu Merge pull request #29542 from frenzibyte/show-daily-challenge-intro-once-per-session 2024-09-01 21:27:16 +09:00
OnlinePlay fixed if statement format 2024-09-07 14:01:38 -06:00
Play Fix stall when attempting to import replay after hitting nothing 2024-09-06 13:16:58 +02:00
Ranking Fix proposal for #29736 2024-09-06 22:58:18 +02:00
Select Fix selection being dropped when changing carousel sort mode from difficulty sort 2024-09-08 16:06:35 +02:00
SelectV2 Inline single-frame layout issue comment instead 2024-08-14 00:41:43 -07:00
Spectate Remove managed clocks from SpectatorSyncManager on gameplay completion / abort 2024-04-26 15:29:59 +08:00
Utility Adjust calls to GetContainingInputManager() 2024-06-18 07:41:19 +02:00
BackgroundScreen.cs Remove requirement of specifying animateOnnter in BackgroundScreen ctor 2024-08-07 19:07:44 +09:00
BackgroundScreenStack.cs Remove requirement of specifying animateOnnter in BackgroundScreen ctor 2024-08-07 19:07:44 +09:00
IHandlePresentBeatmap.cs Automated pass 2023-06-24 01:00:03 +09:00
IHasSubScreenStack.cs Automated pass 2023-06-24 01:00:03 +09:00
IOsuScreen.cs Move screen footer to OsuGame 2024-05-16 07:48:58 +03:00
IPerformFromScreenRunner.cs
Loader.cs Use FastCircle in demanding places in the editor 2024-08-30 17:45:26 +03:00
OsuScreen.cs Move screen footer to OsuGame 2024-05-16 07:48:58 +03:00
OsuScreenDependencies.cs
OsuScreenStack.cs Move screen footer to OsuGame 2024-05-16 07:48:58 +03:00
ScorePresentType.cs Remove redundant nullable suppression directives 2023-06-07 08:20:41 +03:00
ScreenWhiteBox.cs Partial everything 2022-11-27 00:00:27 +09:00
StartupScreen.cs Automated pass 2023-06-24 01:00:03 +09:00