Skip to content

Commit

Permalink
sort stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
rushiiMachine committed Mar 31, 2024
1 parent a2c2bc7 commit 81f09ad
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
34 changes: 23 additions & 11 deletions Osu.Stubs.Tests/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
Expand All @@ -25,24 +26,35 @@ private static async Task Main()
AppDomain.CurrentDomain.AppendPrivatePath(osuDir);
Assembly.LoadFile(osuExe);

List<ILazy<MemberInfo>> stubs = new(200);

foreach (var type in Assembly.GetAssembly(typeof(Stub)).GetTypes())
{
foreach (var field in type.GetFields(BindingFlags.Public | BindingFlags.Static))
{
if (field.GetCustomAttribute(typeof(Stub)) == null)
continue;

var lazy = field.GetValue<ILazy<MemberInfo>>(null);

try
{
Console.WriteLine($"{lazy.Name} -> {lazy.Reference}");
}
catch (Exception e)
{
Console.WriteLine($"{lazy.Name} -> [Failure]");
Console.WriteLine(e);
}
var stub = field.GetValue<ILazy<MemberInfo>>(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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Osu.Stubs/Graphics/SkinManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static class SkinManager
/// </summary>
[Stub]
public static readonly LazyField<object> 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)
Expand Down
2 changes: 1 addition & 1 deletion Osu.Stubs/Scoring/Score.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static class Score
/// </summary>
[Stub]
public static readonly LazyField<object> EnabledMods = new(
"Score#EnabledMods",
"osu.GameplayElements.Scoring.Score::EnabledMods",
() => Class.Reference
.GetDeclaredFields()
.Single(field => field.FieldType.IsGenericType &&
Expand Down

0 comments on commit 81f09ad

Please sign in to comment.