1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

CA1825: use Array.Empty.

This commit is contained in:
Huo Yaoyuan 2019-11-28 21:41:29 +08:00
parent 46dc2251e8
commit ecfc6dfa3d
20 changed files with 28 additions and 29 deletions

View File

@ -57,7 +57,4 @@
<Rule Id="CA2213" Action="None" />
<Rule Id="CA2235" Action="None" />
</Rules>
<Rules AnalyzerId="Microsoft.NetCore.CSharp.Analyzers" RuleNamespace="Microsoft.NetCore.CSharp.Analyzers">
<Rule Id="CA1825" Action="None" />
</Rules>
</RuleSet>

View File

@ -18,6 +18,7 @@ using osu.Game.Rulesets.Catch.Beatmaps;
using osu.Game.Rulesets.Catch.Difficulty;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Scoring;
using System;
namespace osu.Game.Rulesets.Catch
{
@ -112,7 +113,7 @@ namespace osu.Game.Rulesets.Catch
};
default:
return new Mod[] { };
return Array.Empty<Mod>();
}
}

View File

@ -158,7 +158,7 @@ namespace osu.Game.Rulesets.Mania
};
default:
return new Mod[] { };
return Array.Empty<Mod>();
}
}
@ -268,7 +268,7 @@ namespace osu.Game.Rulesets.Mania
return stage1Bindings.Concat(stage2Bindings);
}
return new KeyBinding[0];
return Array.Empty<KeyBinding>();
}
public override string GetVariantName(int variant)

View File

@ -26,6 +26,7 @@ using osu.Game.Rulesets.Osu.Difficulty;
using osu.Game.Rulesets.Osu.Skinning;
using osu.Game.Scoring;
using osu.Game.Skinning;
using System;
namespace osu.Game.Rulesets.Osu
{
@ -149,7 +150,7 @@ namespace osu.Game.Rulesets.Osu
};
default:
return new Mod[] { };
return Array.Empty<Mod>();
}
}

View File

@ -18,6 +18,7 @@ using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Taiko.Beatmaps;
using osu.Game.Rulesets.Taiko.Difficulty;
using osu.Game.Scoring;
using System;
namespace osu.Game.Rulesets.Taiko
{
@ -111,7 +112,7 @@ namespace osu.Game.Rulesets.Taiko
};
default:
return new Mod[] { };
return Array.Empty<Mod>();
}
}

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics;
@ -31,7 +32,7 @@ namespace osu.Game.Tests.Visual.Gameplay
requestCount = 0;
increment = skip_time;
Child = gameplayClockContainer = new GameplayClockContainer(CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)), new Mod[] { }, 0)
Child = gameplayClockContainer = new GameplayClockContainer(CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)), Array.Empty<Mod>(), 0)
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]

View File

@ -45,7 +45,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
});
AddStep(@"set max", () => Room.MaxParticipants.Value = 10);
AddStep(@"clear users", () => Room.Participants.Value = new User[] { });
AddStep(@"clear users", () => Room.Participants.Value = System.Array.Empty<User>());
AddStep(@"set max to null", () => Room.MaxParticipants.Value = null);
}
}

View File

@ -70,7 +70,7 @@ namespace osu.Game.Tests.Visual.Online
},
Title = "osu!volunteer",
Colour = "ff0000",
Achievements = new User.UserAchievement[0],
Achievements = Array.Empty<User.UserAchievement>(),
};
public TestSceneUserProfileOverlay()

View File

@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual.Online
new User { PreviousUsernames = new[] { "longusername", "longerusername" } },
new User { PreviousUsernames = new[] { "test", "angelsim", "verylongusername" } },
new User { PreviousUsernames = new[] { "ihavenoidea", "howcani", "makethistext", "anylonger" } },
new User { PreviousUsernames = new string[0] },
new User { PreviousUsernames = Array.Empty<string>() },
null
};

View File

@ -49,7 +49,7 @@ namespace osu.Game.Tournament.Screens.Editors
get
{
if (editorInfo == null)
return new MenuItem[0];
return Array.Empty<MenuItem>();
return new MenuItem[]
{

View File

@ -192,7 +192,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
get
{
if (editorInfo == null)
return new MenuItem[0];
return Array.Empty<MenuItem>();
return new MenuItem[]
{

View File

@ -98,7 +98,7 @@ namespace osu.Game.Beatmaps
{
if (string.IsNullOrEmpty(value))
{
Bookmarks = new int[0];
Bookmarks = Array.Empty<int>();
return;
}
@ -111,7 +111,7 @@ namespace osu.Game.Beatmaps
}
[NotMapped]
public int[] Bookmarks { get; set; } = new int[0];
public int[] Bookmarks { get; set; } = Array.Empty<int>();
public double DistanceSpacing { get; set; }
public int BeatDivisor { get; set; }

View File

@ -55,7 +55,7 @@ namespace osu.Game.Beatmaps
private class DummyRuleset : Ruleset
{
public override IEnumerable<Mod> GetModsFor(ModType type) => new Mod[] { };
public override IEnumerable<Mod> GetModsFor(ModType type) => Array.Empty<Mod>();
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
{

View File

@ -81,7 +81,7 @@ namespace osu.Game.Overlays.Mods
}
}
private ModButton[] buttons = { };
private ModButton[] buttons = Array.Empty<ModButton>();
protected override bool OnKeyDown(KeyDownEvent e)
{

View File

@ -239,7 +239,7 @@ namespace osu.Game.Overlays.Music
private class ItemSearchContainer : FillFlowContainer<PlaylistItem>, IHasFilterableChildren
{
public IEnumerable<string> FilterTerms => new string[] { };
public IEnumerable<string> FilterTerms => Array.Empty<string>();
public bool MatchingFilter
{

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
@ -55,10 +56,7 @@ namespace osu.Game.Overlays
new BeatmapsSection(),
new KudosuSection()
}
: new ProfileSection[]
{
//new AboutSection(),
};
: Array.Empty<ProfileSection>();
tabs = new ProfileTabControl
{

View File

@ -64,7 +64,7 @@ namespace osu.Game.Rulesets.Mods
/// The mods this mod cannot be enabled with.
/// </summary>
[JsonIgnore]
public virtual Type[] IncompatibleMods => new Type[] { };
public virtual Type[] IncompatibleMods => Array.Empty<Type>();
/// <summary>
/// Creates a copy of this <see cref="Mod"/> initialised to a default state.

View File

@ -42,7 +42,7 @@ namespace osu.Game.Rulesets
/// </summary>
/// <param name="mods">The legacy enum which will be converted</param>
/// <returns>An enumerable of constructed <see cref="Mod"/>s</returns>
public virtual IEnumerable<Mod> ConvertLegacyMods(LegacyMods mods) => new Mod[] { };
public virtual IEnumerable<Mod> ConvertLegacyMods(LegacyMods mods) => Array.Empty<Mod>();
public ModAutoplay GetAutoplayMod() => GetAllMods().OfType<ModAutoplay>().First();
@ -116,7 +116,7 @@ namespace osu.Game.Rulesets
/// </summary>
/// <param name="variant">A variant.</param>
/// <returns>A list of valid <see cref="KeyBinding"/>s.</returns>
public virtual IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new KeyBinding[] { };
public virtual IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => Array.Empty<KeyBinding>();
/// <summary>
/// Gets the name for a key binding variant. This is used for display in the settings overlay.

View File

@ -38,7 +38,7 @@ namespace osu.Game.Screens.Play
}
}
private float[] calculatedValues = { }; // values but adjusted to fit the amount of columns
private float[] calculatedValues = Array.Empty<float>(); // values but adjusted to fit the amount of columns
private int[] values;

View File

@ -27,8 +27,8 @@ namespace osu.Game.Screens.Select.Details
metrics = value;
var retries = Metrics?.Retries ?? new int[0];
var fails = Metrics?.Fails ?? new int[0];
var retries = Metrics?.Retries ?? Array.Empty<int>();
var fails = Metrics?.Fails ?? Array.Empty<int>();
float maxValue = fails.Any() ? fails.Zip(retries, (fail, retry) => fail + retry).Max() : 0;
failGraph.MaxValue = maxValue;