Skip to content

fix: suppress ILLink trimmer warnings across osu.Game and osu.Desktop - #362

Merged
winnerspiros merged 1 commit into
masterfrom
copilot/fix-build-errors-and-warnings
May 28, 2026
Merged

fix: suppress ILLink trimmer warnings across osu.Game and osu.Desktop#362
winnerspiros merged 1 commit into
masterfrom
copilot/fix-build-errors-and-warnings

Conversation

Copilot AI commented May 28, 2026

Copy link
Copy Markdown

The build emitted 1 error and 34 ILLink/Roslyn trim-analyzer warnings across Linux, Windows, macOS, and iOS jobs. The error was a RequiresUnreferencedCode annotation mismatch on a virtual override; the warnings were unannotated reflection/dynamic call sites.

Changes

Annotation mismatch (error → warning → clean)

  • BackgroundDataStoreProcessor.LoadComplete(): removed [RequiresUnreferencedCode] from the override — base Drawable.LoadComplete() carries no such annotation, making the pairing illegal. Replaced with #pragma warning disable IL2026 scoped to the single processScoresWithMissingStatistics() call site.
  • SettingSourceAttribute 4-param ctor: added [DynamicallyAccessedMembers(All)] to the declaringType parameter to match the 3-param ctor it delegates to.

Newtonsoft.Json / reflection suppressions

  • JsonSerializableExtensions: [UnconditionalSuppressMessage("ILLink", "IL2026")] on all four methods — suppresses without propagating to every caller.
  • SnakeCaseStringEnumConverter ctor, ModSettingChangeTracker ctor: same pattern.
  • OsuWebSocketProvider.broadcast, OsuGameDesktop.LoadComplete, Program: inline #pragma warning disable IL2026 at the specific call sites.

Type.GetType / Activator.CreateInstance in TypedListConverter

  • #pragma warning disable IL2057 around Type.GetType(typeName).
  • #pragma warning disable IL2072 around Activator.CreateInstance(type).

Dynamic binding in RealmAccess migrations

  • [UnconditionalSuppressMessage("ILLink", "IL2026")] on applyMigrationsForVersion — covers all dynamic/Binder.GetMember hits within that method.

RequiresAssemblyFiles in GameplayWinKeyBlocker

  • #pragma warning disable IL3000 around the WindowsKey.Disable/Enable scheduler calls (Windows-only, never single-file).

@winnerspiros
winnerspiros marked this pull request as ready for review May 28, 2026 17:22
Copilot AI review requested due to automatic review settings May 28, 2026 17:22
@winnerspiros
winnerspiros merged commit e983ae8 into master May 28, 2026
19 of 23 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Suppresses ILLink/Roslyn trim-analyzer warnings across osu.Game and osu.Desktop by scoping suppressions to known reflection/dynamic call sites and fixing an attribute mismatch that produced a build error.

Changes:

  • Fixed RequiresUnreferencedCode annotation mismatch on a virtual override by moving suppression to the specific call site (BackgroundDataStoreProcessor.LoadComplete()).
  • Added targeted suppressions for Newtonsoft.Json reflection, Type.GetType / Activator.CreateInstance, and Realm migration dynamic binding.
  • Added/adjusted trimming annotations (DynamicallyAccessedMembers) to align constructor contracts.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
osu.Game/IO/Serialization/JsonSerializableExtensions.cs Adds unconditional IL2026 suppressions around Newtonsoft.Json-based serialization helpers.
osu.Game/IO/Serialization/Converters/TypedListConverter.cs Suppresses IL2057/IL2072 around Type.GetType and Activator.CreateInstance.
osu.Game/IO/Serialization/Converters/SnakeCaseStringEnumConverter.cs Suppresses IL2026 on converter construction due to Newtonsoft.Json reflection.
osu.Game/Database/RealmAccess.cs Suppresses IL2026 for dynamic binding inside Realm migrations.
osu.Game/Database/BackgroundDataStoreProcessor.cs Removes invalid override-level RUC annotation and suppresses IL2026 at the specific call site.
osu.Game/Configuration/SettingSourceAttribute.cs Aligns DynamicallyAccessedMembers annotation on the 4-arg ctor parameter.
osu.Game/Configuration/ModSettingChangeTracker.cs Suppresses IL2026 on constructor that calls reflection-based settings control creation.
osu.Desktop/Windows/GameplayWinKeyBlocker.cs Suppresses IL3000 around WindowsKey.Disable/Enable scheduling.
osu.Desktop/Program.cs Suppresses IL2026 around legacy IPC provider construction.
osu.Desktop/OsuGameDesktop.cs Suppresses IL2026 around DiscordRichPresence component async load.
osu.Desktop/IPC/OsuWebSocketProvider.cs Suppresses IL2026 around websocket message serialization via Newtonsoft.Json.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +15 to 25
[UnconditionalSuppressMessage("ILLink", "IL2026", Justification = "Newtonsoft.Json reflection usage is intentional and safe for non-trimmed targets.")]
public static string Serialize(this object obj) => JsonConvert.SerializeObject(obj, CreateGlobalSettings());

[UnconditionalSuppressMessage("ILLink", "IL2026", Justification = "Newtonsoft.Json reflection usage is intentional and safe for non-trimmed targets.")]
public static T Deserialize<T>(this string objString) => JsonConvert.DeserializeObject<T>(objString, CreateGlobalSettings());

[UnconditionalSuppressMessage("ILLink", "IL2026", Justification = "Newtonsoft.Json reflection usage is intentional and safe for non-trimmed targets.")]
public static void DeserializeInto<T>(this string objString, T target) => JsonConvert.PopulateObject(objString, target, CreateGlobalSettings());

[UnconditionalSuppressMessage("ILLink", "IL2026", Justification = "Newtonsoft.Json reflection usage is intentional and safe for non-trimmed targets.")]
public static JsonSerializerSettings CreateGlobalSettings() => new JsonSerializerSettings
{
public class SnakeCaseStringEnumConverter : StringEnumConverter
{
[UnconditionalSuppressMessage("ILLink", "IL2026", Justification = "Newtonsoft.Json reflection usage is intentional and safe for non-trimmed targets.")]
Comment on lines +34 to 35
[UnconditionalSuppressMessage("ILLink", "IL2026", Justification = "SettingSourceAttribute uses reflection intentionally; callers on trimmed targets must ensure mod types are preserved.")]
public ModSettingChangeTracker(IEnumerable<Mod> mods)
applyMigrationsForVersion(migration, i);
}

[UnconditionalSuppressMessage("ILLink", "IL2026", Justification = "Dynamic binding in realm migrations is intentional and safe for non-trimmed targets.")]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants