mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-13 11:20:31 +00:00
CA1825: use Array.Empty instead of new [0].
This commit is contained in:
@@ -71,7 +71,4 @@
|
||||
<Rule Id="CA2237" Action="None" />
|
||||
<Rule Id="CA5351" Action="None" />
|
||||
</Rules>
|
||||
<Rules AnalyzerId="Microsoft.NetCore.CSharp.Analyzers" RuleNamespace="Microsoft.NetCore.CSharp.Analyzers">
|
||||
<Rule Id="CA1825" Action="None" />
|
||||
</Rules>
|
||||
</RuleSet>
|
||||
@@ -38,7 +38,9 @@ namespace osu.Framework.Tests.Lists
|
||||
public void TestEmptyJaggedToRectangular()
|
||||
{
|
||||
int[,] result = null;
|
||||
Assert.DoesNotThrow(() => result = new int[0][].ToRectangular());
|
||||
#pragma warning disable CA1825 // Avoid zero-length array allocations.
|
||||
Assert.DoesNotThrow(() => result = new int[0][].ToRectangular()); // Not natural for the APi shape
|
||||
#pragma warning restore CA1825 // Avoid zero-length array allocations.
|
||||
Assert.AreEqual(0, result.Length);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace osu.Framework.Tests.MathUtils
|
||||
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
{
|
||||
ReadOnlySpan<Vector2> list = new Vector2[0];
|
||||
ReadOnlySpan<Vector2> list = Array.Empty<Vector2>();
|
||||
Interpolation.Lagrange(list, 4);
|
||||
});
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace osu.Framework.Tests.Visual.Layout
|
||||
var method =
|
||||
GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).SingleOrDefault(m => m.GetCustomAttribute<FlowTestCaseAttribute>()?.TestType == testType);
|
||||
if (method != null)
|
||||
method.Invoke(this, new object[0]);
|
||||
method.Invoke(this, Array.Empty<object>());
|
||||
}
|
||||
|
||||
private void buildTest()
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace osu.Framework.Graphics.Transforms
|
||||
|
||||
private static ReadFunc createPropertyGetter(MethodInfo getter)
|
||||
{
|
||||
if (!RuntimeInfo.SupportsJIT) return transformable => (TValue)getter.Invoke(transformable, new object[0]);
|
||||
if (!RuntimeInfo.SupportsJIT) return transformable => (TValue)getter.Invoke(transformable, Array.Empty<object>());
|
||||
|
||||
return (ReadFunc)getter.CreateDelegate(typeof(ReadFunc));
|
||||
}
|
||||
|
||||
@@ -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.Collections.Generic;
|
||||
using osu.Framework.Input.Handlers;
|
||||
using osu.Framework.Logging;
|
||||
@@ -59,7 +60,7 @@ namespace osu.Framework.Platform
|
||||
base.UpdateFrame();
|
||||
}
|
||||
|
||||
protected override IEnumerable<InputHandler> CreateAvailableInputHandlers() => new InputHandler[] { };
|
||||
protected override IEnumerable<InputHandler> CreateAvailableInputHandlers() => Array.Empty<InputHandler>();
|
||||
|
||||
private class FastClock : IClock
|
||||
{
|
||||
|
||||
@@ -364,7 +364,7 @@ namespace osu.Framework.Testing
|
||||
// should run inline where possible. this is to fix RunAllSteps potentially finding no steps if the steps are added in LoadComplete (else they get forcefully scheduled too late)
|
||||
private void schedule(Action action) => Scheduler.Add(action, false);
|
||||
|
||||
public virtual IReadOnlyList<Type> RequiredTypes => new Type[] { };
|
||||
public virtual IReadOnlyList<Type> RequiredTypes => Array.Empty<Type>();
|
||||
|
||||
internal void RunSetUpSteps()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user