From 81f09ad7d2f60221de63f247fca37bf6369199a2 Mon Sep 17 00:00:00 2001 From: rushiiMachine <33725716+rushiiMachine@users.noreply.github.com> Date: Sun, 31 Mar 2024 12:05:33 -0700 Subject: [PATCH] sort stubs --- Osu.Stubs.Tests/Program.cs | 34 +++++++++++++++++++++---------- Osu.Stubs/Graphics/SkinManager.cs | 2 +- Osu.Stubs/Scoring/Score.cs | 2 +- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Osu.Stubs.Tests/Program.cs b/Osu.Stubs.Tests/Program.cs index da472cb..6e8bf83 100644 --- a/Osu.Stubs.Tests/Program.cs +++ b/Osu.Stubs.Tests/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using System.Reflection; using System.Threading.Tasks; @@ -25,6 +26,8 @@ private static async Task Main() AppDomain.CurrentDomain.AppendPrivatePath(osuDir); Assembly.LoadFile(osuExe); + List> stubs = new(200); + foreach (var type in Assembly.GetAssembly(typeof(Stub)).GetTypes()) { foreach (var field in type.GetFields(BindingFlags.Public | BindingFlags.Static)) @@ -32,17 +35,26 @@ private static async Task Main() if (field.GetCustomAttribute(typeof(Stub)) == null) continue; - var lazy = field.GetValue>(null); - - try - { - Console.WriteLine($"{lazy.Name} -> {lazy.Reference}"); - } - catch (Exception e) - { - Console.WriteLine($"{lazy.Name} -> [Failure]"); - Console.WriteLine(e); - } + var stub = field.GetValue>(null); + if (stub == null) throw new Exception(); + + stubs.Add(stub); + } + } + + stubs.Sort((a, b) => + string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase)); + + foreach (var lazy in stubs) + { + try + { + Console.WriteLine($"{lazy.Name} -> {lazy.Reference}"); + } + catch (Exception e) + { + Console.WriteLine($"{lazy.Name} -> [Failure]"); + Console.WriteLine(e); } } } diff --git a/Osu.Stubs/Graphics/SkinManager.cs b/Osu.Stubs/Graphics/SkinManager.cs index 68c9d8c..a7964db 100644 --- a/Osu.Stubs/Graphics/SkinManager.cs +++ b/Osu.Stubs/Graphics/SkinManager.cs @@ -44,7 +44,7 @@ public static class SkinManager /// [Stub] public static readonly LazyField Current = new( - "SkinManager#Current", + "osu.Graphics.Skinning.SkinManager::Current", // There is two fields with type SkinOsu; Current and CurrentUserSkin in that order () => Class.Reference.GetDeclaredFields() .First(f => f.FieldType == SkinOsu.Class.Reference) diff --git a/Osu.Stubs/Scoring/Score.cs b/Osu.Stubs/Scoring/Score.cs index 8628c76..d243140 100644 --- a/Osu.Stubs/Scoring/Score.cs +++ b/Osu.Stubs/Scoring/Score.cs @@ -104,7 +104,7 @@ public static class Score /// [Stub] public static readonly LazyField EnabledMods = new( - "Score#EnabledMods", + "osu.GameplayElements.Scoring.Score::EnabledMods", () => Class.Reference .GetDeclaredFields() .Single(field => field.FieldType.IsGenericType &&