1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 05:22:54 +08:00
osu-lazer/osu.Game/Screens/Select
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
..
Carousel Use for with exposed IReadOnlyList rather than making internal container public 2024-09-04 15:25:36 +09:00
Details Creating method in ModUtils to calculate the rate for the song 2024-06-06 10:06:07 -03:00
Filter Automated pass 2023-06-24 01:00:03 +09:00
Leaderboards Fix song select leaderboard tab ordering not matching stable 2023-12-28 14:13:35 +09:00
Options Use new overlay pop-in/pop-out samples 2023-08-17 18:36:36 +09:00
BeatmapCarousel.cs Fix selection being dropped when changing carousel sort mode from difficulty sort 2024-09-08 16:06:35 +02:00
BeatmapClearScoresDialog.cs make ResetConfirmDialog properly utilise its parent's logic 2023-03-05 20:57:26 +01:00
BeatmapDeleteDialog.cs make ResetConfirmDialog properly utilise its parent's logic 2023-03-05 20:57:26 +01:00
BeatmapDetailArea.cs functionality is done 2023-09-03 02:09:01 +03:00
BeatmapDetailAreaDetailTabItem.cs Automated pass 2023-06-24 01:00:03 +09:00
BeatmapDetailAreaLeaderboardTabItem.cs Automated pass 2023-06-24 01:00:03 +09:00
BeatmapDetailAreaTabControl.cs Partial everything 2022-11-27 00:00:27 +09:00
BeatmapDetailAreaTabItem.cs Automated #nullable processing 2022-06-17 16:37:17 +09:00
BeatmapDetails.cs Apply padding to GridContainers directly 2024-02-20 23:18:37 +03:00
BeatmapInfoWedge.cs Adjust song select info icon size slightly 2024-08-05 17:21:50 +09:00
BeatmapInfoWedgeBackground.cs Automated pass 2023-06-24 01:00:03 +09:00
BeatmapInfoWedgeV2.cs Add comment explaining the max width 2023-09-06 15:01:55 -07:00
FilterControl.cs Adjust calls to GetContainingInputManager() 2024-06-18 07:41:19 +02:00
FilterCriteria.cs Add mods to FilterCriteria, pass to ruleset method 2024-03-28 23:03:26 +09:00
FilterQueryParser.cs Add 'yes'/'no' acronyms to the played= filter 2024-09-06 18:04:39 +09:00
Footer.cs Partial everything 2022-11-27 00:00:27 +09:00
FooterButton.cs Partial everything 2022-11-27 00:00:27 +09:00
FooterButtonMods.cs Swap the low and high multiplier color 2024-06-26 21:39:14 +08:00
FooterButtonOptions.cs Automated pass 2023-06-24 01:00:03 +09:00
FooterButtonRandom.cs Show "rewind" text on random button when beginning a right mouse press 2023-05-17 14:51:40 +09:00
LocalScoreDeleteDialog.cs Make ScoreInfo.BeatmapInfo nullable 2023-07-04 14:50:34 +09:00
ModSpeedHotkeyHandler.cs Rewrite implementation 2024-05-24 13:03:42 +02:00
NoResultsPlaceholder.cs Partial everything 2022-11-27 00:00:27 +09:00
PlayBeatmapDetailArea.cs Fix song select leaderboard tab ordering not matching stable 2023-12-28 14:13:35 +09:00
PlaySongSelect.cs Adjust calls to GetContainingInputManager() 2024-06-18 07:41:19 +02:00
SkinDeleteDialog.cs make ResetConfirmDialog properly utilise its parent's logic 2023-03-05 20:57:26 +01:00
SongSelect.cs Fix some tests not always waiting long enough for beatmap loading 2024-08-29 18:42:43 +09:00
SongSelectTouchInputDetector.cs Rename touch "input handlers" to detectors 2023-11-06 10:08:19 +01:00
WedgeBackground.cs Only apply dim changes when background blur is disabled 2023-02-15 14:16:34 +09:00