I have a native AOT compilation project here: https://github.com/smoogipoo/osu-native-diffcalc It compiles the most minimal types from osu+osu-framework+osuTK into a project that can be used to perform difficulty calculation with.
This change should remove the need for these workarounds with very little code-wise overhead from the game itself. This is probably good practice in general though I'm not sure when we'll/if ever move towards trimming more aggressively in production.
Here's a test app:
using System.Diagnostics.CodeAnalysis;
new X().Clone().Print();
new Y().Clone().Print();
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
public class X
{
public virtual void Print()
{
Console.WriteLine("hello from x!");
}
public X Clone() => (X)Activator.CreateInstance(GetType())!;
}
public class Y : X
{
public override void Print()
{
Console.WriteLine("hello from y!");
}
}
I have a native AOT compilation project here: https://github.com/smoogipoo/osu-native-diffcalc It compiles the most minimal types from osu+osu-framework+osuTK into a project that can be used to perform difficulty calculation with.
In it, I've had to add a few workarounds for these types which use
Activator.CreateInstance()
down various paths: https://github.com/smoogipoo/osu-native-diffcalc/blob/8fb300329425e52aa078b78728ba802bb8124345/Sources/osu.Game.Native.Desktop/Program.cs#L25-L71This change should remove the need for these workarounds with very little code-wise overhead from the game itself. This is probably good practice in general though I'm not sure when we'll/if ever move towards trimming more aggressively in production.
Here's a test app:
In .csproj: