From 9e446369cf9cafdfe3187dcbede5cc980d7412a6 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 9 Jul 2024 21:31:29 +0800 Subject: [PATCH] Ban == on span and use `is` to match constant string --- CodeAnalysis/BannedSymbols.txt | 1 + osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs | 2 +- osu.Game/Skinning/LegacyManiaSkinDecoder.cs | 4 ++-- osu.Game/Skinning/LegacySkinDecoder.cs | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CodeAnalysis/BannedSymbols.txt b/CodeAnalysis/BannedSymbols.txt index 3c60b287651f..085673fa99fa 100644 --- a/CodeAnalysis/BannedSymbols.txt +++ b/CodeAnalysis/BannedSymbols.txt @@ -22,3 +22,4 @@ M:Humanizer.InflectorExtensions.Pascalize(System.String);Humanizer's .Pascalize( M:Humanizer.InflectorExtensions.Camelize(System.String);Humanizer's .Camelize() extension method changes behaviour depending on CultureInfo.CurrentCulture. Use StringDehumanizeExtensions.ToCamelCase() instead. M:Humanizer.InflectorExtensions.Underscore(System.String);Humanizer's .Underscore() extension method changes behaviour depending on CultureInfo.CurrentCulture. Use StringDehumanizeExtensions.ToSnakeCase() instead. M:Humanizer.InflectorExtensions.Kebaberize(System.String);Humanizer's .Kebaberize() extension method changes behaviour depending on CultureInfo.CurrentCulture. Use StringDehumanizeExtensions.ToKebabCase() instead. +M:System.ReadOnlySpan`1.op_Equality(System.ReadOnlySpan`1,System.ReadOnlySpan`1)~System.Boolean;== on spans produces reference equality. Use SequenceEqual for value equality, or "is" to match ReadOnlySpan with constant string. diff --git a/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs index 76dda63f5ac3..5e9f9b514273 100644 --- a/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs @@ -70,7 +70,7 @@ private void handleGeneral(Storyboard storyboard, ReadOnlySpan line) switch (pair.Key) { case "UseSkinSprites": - storyboard.UseSkinSprites = pair.Value.SequenceEqual("1"); + storyboard.UseSkinSprites = pair.Value is "1"; break; } } diff --git a/osu.Game/Skinning/LegacyManiaSkinDecoder.cs b/osu.Game/Skinning/LegacyManiaSkinDecoder.cs index 6844d0fe9148..629632afb3a2 100644 --- a/osu.Game/Skinning/LegacyManiaSkinDecoder.cs +++ b/osu.Game/Skinning/LegacyManiaSkinDecoder.cs @@ -99,11 +99,11 @@ private void flushPendingLines() break; case "JudgementLine": - currentConfig.ShowJudgementLine = pair.Value == "1"; + currentConfig.ShowJudgementLine = pair.Value is "1"; break; case "KeysUnderNotes": - currentConfig.KeysUnderNotes = pair.Value == "1"; + currentConfig.KeysUnderNotes = pair.Value is "1"; break; case "LightingNWidth": diff --git a/osu.Game/Skinning/LegacySkinDecoder.cs b/osu.Game/Skinning/LegacySkinDecoder.cs index 00669fb33af5..5ea2a5df46ed 100644 --- a/osu.Game/Skinning/LegacySkinDecoder.cs +++ b/osu.Game/Skinning/LegacySkinDecoder.cs @@ -34,7 +34,7 @@ protected override void ParseLine(SkinConfiguration skin, Section section, ReadO return; case @"Version": - if (pair.Value.SequenceEqual("latest")) + if (pair.Value is "latest") skin.LegacyVersion = SkinConfiguration.LATEST_VERSION; else if (decimal.TryParse(pair.Value, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out decimal version)) skin.LegacyVersion = version;