1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 02:12:56 +08:00
osu-lazer/osu.Game
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
..
Audio Adjust AudioFilter to framework-side changes 2024-06-18 07:30:46 +02:00
Beatmaps Merge pull request #29446 from OliBomby/last-anchor 2024-09-02 18:40:19 +09:00
Collections Apply corner radius at a higher level so hover click sounds account for it 2024-08-01 18:45:47 -07:00
Configuration fix config mistake 2024-09-04 03:37:52 -04:00
Database Add note about using hard links in the future 2024-09-06 16:01:47 +09:00
Extensions Fix date failing to display on leaderboard for some scores with weird datetimes 2024-01-14 13:52:39 +01:00
Graphics Apply review suggestions wrt border appearance 2024-09-05 11:21:59 +02:00
Input change sample seek keybind to ctrl shift 2024-08-28 09:57:13 +02:00
IO Update naming of enum fields in ObjType 2024-05-01 17:24:53 +03:00
IPC
Localisation rework code logic to make more sense 2024-09-03 00:59:42 -04:00
Models Use native query to avoid huge overheads when cleaning up realm files 2024-01-09 15:37:29 +09:00
Online Trigger request failure on receiving a null response for a typed APIRequest 2024-09-05 01:00:23 +09:00
Overlays Merge pull request #29714 from Crystallized21/total-participation-tooltip 2024-09-08 22:42:02 +09:00
Performance Expose high performance session state 2024-04-16 10:04:38 +08:00
Properties Make medal overlay respect overlay disable via activation mode 2024-02-20 16:31:31 +01:00
Replays Update HasFlag usages 2024-07-03 00:19:04 +09:00
Rulesets Move analysis container implementation completely local to osu! ruleset 2024-09-04 19:00:22 +09:00
Scoring Fix mouseX legacy replay parsing for high key counts in mania 2024-08-11 09:45:43 -07:00
Screens Fix selection being dropped when changing carousel sort mode from difficulty sort 2024-09-08 16:06:35 +02:00
Skinning Fix deserialise failing with some old skins 2024-08-23 20:44:45 +09:00
Storyboards Fix storyboard sprites leaving gaps on edges when resolving from an atlas 2024-07-17 14:47:17 +03:00
Tests Merge pull request #29542 from frenzibyte/show-daily-challenge-intro-once-per-session 2024-09-01 21:27:16 +09:00
Updater Resurrect SimpleUpdateManager as MobileUpdateNotifier 2024-07-05 03:29:09 -04:00
Users Fix nullability inspection 2024-05-10 23:26:43 +08:00
Utils Merge pull request #29616 from peppy/break-overlay-animation 2024-09-04 19:39:35 +09:00
.editorconfig
FodyWeavers.xml
osu!.res
osu.Game.csproj Update framework 2024-09-07 21:46:43 +09:00
OsuGame.cs Add basic detached beatmap store 2024-08-28 16:03:37 +09:00
OsuGameBase_Importing.cs
OsuGameBase.cs Fix weird test critical failure if exception happens too early in execution 2024-08-30 18:35:31 +09:00
PerformFromMenuRunner.cs