Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion osu.Framework.Benchmarks/BenchmarkSlimReadOnlyList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace osu.Framework.Benchmarks
[MemoryDiagnoser]
public class BenchmarkSlimReadOnlyList
{
private readonly List<int> list = new List<int> { 0, 1, 2, 3, 4, 5, 3, 2, 3, 1, 4, 5, -1 };
private readonly List<int> list = [0, 1, 2, 3, 4, 5, 3, 2, 3, 1, 4, 5, -1];

[Benchmark(Baseline = true)]
public int List()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static void VerifyMultiPhaseGeneratedSources(this GeneratorDriverRunResul

int matches = 0;

foreach (var (filename, content) in files)
foreach ((string filename, string content) in files)
{
if (!generatedSources.TryGetValue(filename, out var source))
throw new Xunit.Sdk.XunitException($"Phase {phase}: Expected generated source {filename}, but it was not found");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ public void Verify()
// Remove sources from previous phase that are not existing in the current phase
if (phase > 0)
{
foreach (var (filename, _) in multiPhaseSources[phase - 1].Where(old => sources.All(@new => @new.filename != old.filename)))
foreach ((string filename, string _) in multiPhaseSources[phase - 1].Where(old => sources.All(@new => @new.filename != old.filename)))
compilation.RemoveSource(filename);
}

// Add sources for the current phase
foreach (var (filename, content) in sources)
foreach ((string filename, string content) in sources)
{
compilation.AddOrUpdateSource(filename, content);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

List<Drawable> items = null!;

AddStep("get item references", () => items = new List<Drawable>(list.ItemMap.Values.ToList()));
AddStep("get item references", () => items = [..list.ItemMap.Values.ToList()]);

Check failure on line 87 in osu.Framework.Tests/Visual/UserInterface/TestSceneRearrangeableListContainer.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 87 in osu.Framework.Tests/Visual/UserInterface/TestSceneRearrangeableListContainer.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

for (int i = 0; i < item_count; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework/Audio/Sample/ISample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public interface ISample : IAdjustableAudioComponent
/// <summary>
/// Whether this <see cref="ISample"/> is fully loaded.
/// </summary>
public bool IsLoaded { get; }
bool IsLoaded { get; }

/// <summary>
/// The number of times this sample (as identified by name) can be played back concurrently.
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework/Audio/Track/ITrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public interface ITrack : IAdjustableClock, IHasAmplitudes, IAdjustableAudioComp
/// <summary>
/// Whether this track has finished playing back.
/// </summary>
public bool HasCompleted { get; }
bool HasCompleted { get; }

/// <summary>
/// Restarts this track from the <see cref="Track.RestartPoint"/> while retaining adjustments.
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework/Bindables/IBindableWithCurrent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface IBindableWithCurrent<T> : IBindable<T>, IHasCurrentValue<T>
/// If the value type is one supported by the <see cref="BindableNumber{T}"/>, an instance of <see cref="BindableNumberWithCurrent{T}"/> will be returned.
/// Otherwise an instance of <see cref="BindableWithCurrent{T}"/> will be returned instead.
/// </summary>
public static IBindableWithCurrent<T> Create()
static IBindableWithCurrent<T> Create()
{
if (Validation.IsSupportedBindableNumberType<T>())
return (IBindableWithCurrent<T>)Activator.CreateInstance(typeof(BindableNumberWithCurrent<>).MakeGenericType(typeof(T)), default(T));
Expand Down
4 changes: 2 additions & 2 deletions osu.Framework/Configuration/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,10 @@ protected Bindable<TValue> GetOriginalBindable<TValue>(TLookup lookup)
{
if (ConfigStore.TryGetValue(lookup, out IBindable obj))
{
if (!(obj is Bindable<TValue>))
if (!(obj is Bindable<TValue> value))
throw new InvalidCastException($"Cannot convert bindable of type {obj.GetType()} retrieved from {nameof(ConfigManager<TLookup>)} to {typeof(Bindable<TValue>)}.");

return (Bindable<TValue>)obj;
return value;
}

return null;
Expand Down
6 changes: 3 additions & 3 deletions osu.Framework/Graphics/Animations/IAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ public interface IAnimation
/// <summary>
/// The duration of the animation.
/// </summary>
public double Duration { get; }
double Duration { get; }

/// <summary>
/// True if the animation has finished playing, false otherwise.
/// </summary>
public bool FinishedPlaying => !Loop && PlaybackPosition > Duration;
bool FinishedPlaying => !Loop && PlaybackPosition > Duration;

/// <summary>
/// True if the animation is playing, false otherwise. <c>true</c> by default.
Expand All @@ -37,6 +37,6 @@ public interface IAnimation
/// <summary>
/// The current position of playback.
/// </summary>
public double PlaybackPosition { get; set; }
double PlaybackPosition { get; set; }
}
}
2 changes: 1 addition & 1 deletion osu.Framework/Graphics/Audio/WaveformGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
{
// Late initialise list to use a sane initial capacity.
if (points == null)
points = new List<Waveform.Point>(Source.resampledPoints ?? Enumerable.Empty<Waveform.Point>());
points = [..Source.resampledPoints ?? Enumerable.Empty<Waveform.Point>()];

Check failure on line 300 in osu.Framework/Graphics/Audio/WaveformGraph.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 300 in osu.Framework/Graphics/Audio/WaveformGraph.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)
else
{
points.Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private void itemsChanged(object? sender, NotifyCollectionChangedEventArgs e)
allMoves.Add((items[i], i - 1));
}

foreach (var (item, newPosition) in allMoves)
foreach ((var item, int newPosition) in allMoves)
Items.Move(item, newPosition);

break;
Expand Down
4 changes: 2 additions & 2 deletions osu.Framework/Graphics/Primitives/Vector2I.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public Vector2I(int x, int y)

public override readonly bool Equals(object obj)
{
if (!(obj is Vector2I))
if (!(obj is Vector2I i))
return false;

return Equals((Vector2I)obj);
return Equals(i);
}

[SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode")]
Expand Down
16 changes: 8 additions & 8 deletions osu.Framework/Graphics/Rendering/IRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ public interface IRenderer
/// Maximum number of <see cref="DrawNode"/>s a <see cref="Drawable"/> can draw with.
/// This is a carefully-chosen number to enable the update and draw threads to work concurrently without causing unnecessary load.
/// </summary>
public const int MAX_DRAW_NODES = 3;
const int MAX_DRAW_NODES = 3;

public const int MAX_MIPMAP_LEVELS = 3;
const int MAX_MIPMAP_LEVELS = 3;

public const int VERTICES_PER_TRIANGLE = 4;
const int VERTICES_PER_TRIANGLE = 4;

public const int VERTICES_PER_QUAD = 4;
const int VERTICES_PER_QUAD = 4;

public const int INDICES_PER_QUAD = VERTICES_PER_QUAD + 2;
const int INDICES_PER_QUAD = VERTICES_PER_QUAD + 2;

/// <summary>
/// Maximum number of vertices in a linear vertex buffer.
/// </summary>
public const int MAX_VERTICES = ushort.MaxValue;
const int MAX_VERTICES = ushort.MaxValue;

/// <summary>
/// Maximum number of quads in a quad vertex buffer.
/// </summary>
public const int MAX_QUADS = ushort.MaxValue / INDICES_PER_QUAD;
const int MAX_QUADS = ushort.MaxValue / INDICES_PER_QUAD;

/// <summary>
/// Enables or disables vertical sync.
Expand Down Expand Up @@ -353,7 +353,7 @@ public interface IRenderer
/// <summary>
/// Returns an image containing the content of a framebuffer.
/// </summary>
public Image<Rgba32>? ExtractFrameBufferData(IFrameBuffer frameBuffer);
Image<Rgba32>? ExtractFrameBufferData(IFrameBuffer frameBuffer);

/// <summary>
/// Creates a new <see cref="IShaderPart"/>.
Expand Down
8 changes: 4 additions & 4 deletions osu.Framework/Graphics/Veldrid/Pipelines/GraphicsPipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public void DrawVertices(global::Veldrid.PrimitiveTopology topology, int vertexS
Array.Resize(ref pipelineDesc.ResourceLayouts, currentShader.LayoutCount);

// Activate texture layouts.
foreach (var (unit, _) in attachedTextures)
foreach ((int unit, var _) in attachedTextures)
{
var layout = currentShader.GetTextureLayout(unit);
if (layout == null)
Expand All @@ -263,7 +263,7 @@ public void DrawVertices(global::Veldrid.PrimitiveTopology topology, int vertexS
}

// Activate uniform buffer layouts.
foreach (var (name, _) in attachedUniformBuffers)
foreach ((string name, var _) in attachedUniformBuffers)
{
var layout = currentShader.GetUniformBufferLayout(name);
if (layout == null)
Expand All @@ -276,7 +276,7 @@ public void DrawVertices(global::Veldrid.PrimitiveTopology topology, int vertexS
Commands.SetPipeline(createPipeline());

// Activate texture resources.
foreach (var (unit, texture) in attachedTextures)
foreach ((int unit, var texture) in attachedTextures)
{
var layout = currentShader.GetTextureLayout(unit);
if (layout == null)
Expand All @@ -286,7 +286,7 @@ public void DrawVertices(global::Veldrid.PrimitiveTopology topology, int vertexS
}

// Activate uniform buffer resources.
foreach (var (name, buffer) in attachedUniformBuffers)
foreach ((string name, var buffer) in attachedUniformBuffers)
{
var layout = currentShader.GetUniformBufferLayout(name);
if (layout == null)
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework/Logging/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@

private readonly GlobalStatistic<int> logCount;

private static readonly HashSet<string> reserved_names = new HashSet<string>(Enum.GetNames<LoggingTarget>().Select(n => n.ToLowerInvariant()));
private static readonly HashSet<string> reserved_names = [..Enum.GetNames<LoggingTarget>().Select(n => n.ToLowerInvariant())];

Check failure on line 94 in osu.Framework/Logging/Logger.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 94 in osu.Framework/Logging/Logger.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

private Logger(LoggingTarget target = LoggingTarget.Runtime)
: this(target.ToString(), false)
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework/Testing/TestScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ public override void BeforeTest(ITest test)
});
}

if (TestContext.CurrentContext.Test.MethodName != nameof(TestScene.TestConstructor))
if (TestContext.CurrentContext.Test.MethodName != nameof(TestConstructor))
testScene.Schedule(() => testScene.StepsContainer.Clear());

testScene.RunSetUpSteps();
Expand Down
10 changes: 4 additions & 6 deletions osu.Framework/Text/TextBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,10 @@ private bool tryCreateGlyph(char character, out TextBuilderGlyph glyph)
return tryGetGlyph(character, font, store) ??
tryGetGlyph(fallbackCharacter, font, store);

static ITexturedCharacterGlyph? tryGetGlyph(char character, FontUsage font, ITexturedGlyphLookupStore store)
{
return store.Get(font.FontName, character)
?? store.Get(font.FontNameNoFamily, character)
?? store.Get(string.Empty, character);
}
static ITexturedCharacterGlyph? tryGetGlyph(char character, FontUsage font, ITexturedGlyphLookupStore store) =>
store.Get(font.FontName, character)
?? store.Get(font.FontNameNoFamily, character)
?? store.Get(string.Empty, character);
}
}
}
26 changes: 13 additions & 13 deletions osu.Framework/Utils/IncrementalBSplineBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ namespace osu.Framework.Utils
/// </summary>
public class IncrementalBSplineBuilder
{
private readonly List<Vector2> inputPath = new List<Vector2>();
private readonly List<float> cumulativeInputPathLength = new List<float>();
private readonly List<Vector2> inputPath = [];
private readonly List<float> cumulativeInputPathLength = [];

private static Vector2 getPathAt(List<Vector2> path, List<float> cumulativeDistances, float t)
{
Expand Down Expand Up @@ -71,12 +71,12 @@ private static float getAbsWindingAt(List<Vector2> path, List<float> cumulativeD

private readonly Cached<List<Vector2>> outputCache = new Cached<List<Vector2>>
{
Value = new List<Vector2>()
Value = []
};

private readonly Cached<List<List<Vector2>>> controlPoints = new Cached<List<List<Vector2>>>
{
Value = new List<List<Vector2>>()
Value = []
};

private bool shouldOptimiseLastSegment;
Expand Down Expand Up @@ -334,7 +334,7 @@ private void updateLastSegment(List<Vector2> vertices, List<float> distances, Li
// Initialize control points for the last segment
int i = segments.Count - 1;
var lastSegment = segments[i];
var (cps, segmentPath, totalWinding) = initializeSegment(vertices, distances, cornerTs[i], cornerTs[i + 1]);
(var cps, var segmentPath, float totalWinding) = initializeSegment(vertices, distances, cornerTs[i], cornerTs[i + 1]);

// Make sure the last segment has the correct end-points
if (lastSegment.Count >= 1)
Expand Down Expand Up @@ -401,7 +401,7 @@ private void regenerateLastApproximatedSegment()

if (vertices.Count < 2)
{
controlPoints.Value = new List<List<Vector2>> { vertices };
controlPoints.Value = [vertices];
return;
}

Expand All @@ -424,7 +424,7 @@ private void regenerateLastApproximatedSegment()
// The previous segment may have been shortened by the addition of a corner.
// We have to remove the extra control points and re-optimize the path.
updateLastSegment(vertices, distances, cornerTs, segments, 100, false);
segments.Add(new List<Vector2>());
segments.Add([]);
}

if (finishedDrawing)
Expand All @@ -450,11 +450,11 @@ private void regenerateFullApproximatedPath()

if (vertices.Count < 2)
{
controlPoints.Value = new List<List<Vector2>> { vertices };
controlPoints.Value = [vertices];
return;
}

controlPoints.Value = new List<List<Vector2>>();
controlPoints.Value = [];

Debug.Assert(vertices.Count == distances.Count + 1);
var cornerTs = detectCorners(vertices, distances);
Expand All @@ -463,7 +463,7 @@ private void regenerateFullApproximatedPath()

for (int i = 1; i < cornerTs.Count; ++i)
{
var (cps, segmentPath, totalWinding) = initializeSegment(vertices, distances, cornerTs[i - 1], cornerTs[i]);
(var cps, var segmentPath, float totalWinding) = initializeSegment(vertices, distances, cornerTs[i - 1], cornerTs[i]);

if (cps.Count > 2 && cps.Count < 100)
{
Expand All @@ -480,7 +480,7 @@ private void regenerateFullApproximatedPath()

private void redrawApproximatedPath()
{
outputCache.Value = new List<Vector2>();
outputCache.Value = [];

foreach (var segment in ControlPoints)
{
Expand All @@ -496,8 +496,8 @@ public void Clear()
inputPath.Clear();
cumulativeInputPathLength.Clear();

controlPoints.Value = new List<List<Vector2>>();
outputCache.Value = new List<Vector2>();
controlPoints.Value = [];
outputCache.Value = [];

shouldOptimiseLastSegment = false;
finishedDrawing = false;
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework/Utils/NumberFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace osu.Framework.Utils
/// </summary>
public static class NumberFormatter
{
private static readonly string[] suffixes = { "y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y" };
private static readonly string[] suffixes = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];

/// <summary>
/// Prints the number with at most two decimal digits, followed by a magnitude suffic (k, M, G, T, etc.) depending on the magnitude of the number. If the number is
Expand Down
12 changes: 6 additions & 6 deletions osu.Framework/Utils/PathApproximator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static Vector2[] BSplineToBezier(ReadOnlySpan<Vector2> controlPoints, int
// Spline fitting does not make sense when the input contains no points or just one point. In this case
// the user likely wants this function to behave like a no-op.
if (controlPoints.Length < 2)
return controlPoints.Length == 0 ? Array.Empty<Vector2>() : new[] { controlPoints[0] };
return controlPoints.Length == 0 ? [] : [controlPoints[0]];

return bSplineToBezierInternal(controlPoints, ref degree).SelectMany(segment => segment).ToArray();
}
Expand Down Expand Up @@ -86,14 +86,14 @@ public static List<Vector2> BSplineToPiecewiseLinear(ReadOnlySpan<Vector2> contr
// Spline fitting does not make sense when the input contains no points or just one point. In this case
// the user likely wants this function to behave like a no-op.
if (controlPoints.Length < 2)
return controlPoints.Length == 0 ? new List<Vector2>() : new List<Vector2> { controlPoints[0] };
return controlPoints.Length == 0 ? [] : [controlPoints[0]];

// With fewer control points than the degree, splines can not be unambiguously fitted. Rather than erroring
// out, we set the degree to the minimal number that permits a unique fit to avoid special casing in
// incremental spline building algorithms that call this function.
degree = Math.Min(degree, controlPoints.Length - 1);

List<Vector2> output = new List<Vector2>();
List<Vector2> output = [];
int pointCount = controlPoints.Length - 1;

Stack<Vector2[]> toFlatten = bSplineToBezierInternal(controlPoints, ref degree);
Expand Down Expand Up @@ -211,11 +211,11 @@ public static RectangleF CircularArcBoundingBox(ReadOnlySpan<Vector2> controlPoi

// We find the bounding box using the end-points, as well as
// each 90 degree angle inside the range of the arc
List<Vector2> points = new List<Vector2>
{
List<Vector2> points =
[
controlPoints[0],
controlPoints[2]
};
];

const double right_angle = Math.PI / 2;
double step = right_angle * pr.Direction;
Expand Down
Loading