Skip to content

Commit 8bf8817

Browse files
fix: suppress Android build warnings (Linker.xml stale entries + IL2075)
Agent-Logs-Url: https://github.com/winnerspiros/osu/sessions/bfc25f05-93a4-41df-b509-00e60ffe6d52 Co-authored-by: winnerspiros <1675249+winnerspiros@users.noreply.github.com>
1 parent ec8c98e commit 8bf8817

3 files changed

Lines changed: 28 additions & 10 deletions

File tree

osu.Android/Linker.xml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,17 @@
6767
Shader attribute scanning, TextureLoaderStore fallback chain, bindable system,
6868
resource store extension routing — all reflection-dependent.
6969
ppy.osu.Framework.Android: Android-specific host, input handling, surface wrappers.
70-
ppy.Veldrid.SPIRV: SPIR-V cross-compiler; dynamically loads shader reflector types. -->
71-
<assembly fullname="ppy.osu.Framework" preserve="all" />
72-
<assembly fullname="ppy.osu.Framework.Android" preserve="all" />
73-
<assembly fullname="ppy.Veldrid.SPIRV" preserve="all" />
70+
ppy.Veldrid.SPIRV: SPIR-V cross-compiler; dynamically loads shader reflector types.
71+
72+
NOTE: ppy.osu.Framework and ppy.osu.Framework.Android are intentionally omitted
73+
from this descriptor. ILLink (in .NET Android Full-link mode) cannot resolve these
74+
assemblies during the trimmer pass — they originate from a net10.0 NuGet package
75+
that is not visible in ILLink's assembly search path for the android TFM. The
76+
linker therefore cannot apply a preserve="all" rule, and having the entries only
77+
generates "Could not resolve assembly" warnings with no benefit. The assemblies
78+
are included intact in the APK (ILLink cannot trim what it cannot find), and every
79+
reachable type is rooted from osu.Android / osu.Game which ARE in the preserve list. -->
80+
<assembly fullname="ppy.Veldrid.SPIRV" preserve="all" />
7481

7582
<!-- ═══════════════════════════════════════════════════════════════════════
7683
Audio (ManagedBass)
@@ -89,9 +96,11 @@
8996
compile time, but at runtime it discovers RealmObject schemas by
9097
reflecting over IRealmObject-derived types and their [MapTo]/[Indexed]
9198
attributes. Stripping any Realm type (or any osu RealmObject property)
92-
causes a RealmException at database open time. -->
93-
<assembly fullname="Realm" preserve="all" />
94-
<assembly fullname="Realms.PlatformHelpers" preserve="all" />
99+
causes a RealmException at database open time.
100+
NOTE: Realms.PlatformHelpers was a separate assembly in older Realm SDK
101+
versions (≤ 10.x) and was merged into Realm in v11. Realm 20.x does not
102+
ship it as a standalone assembly, so the entry is omitted here. -->
103+
<assembly fullname="Realm" preserve="all" />
95104

96105
<!-- ═══════════════════════════════════════════════════════════════════════
97106
JSON / binary serialisation
@@ -147,16 +156,19 @@
147156
The DI container (IServiceProvider / ServiceCollection) scans constructor
148157
parameters via ConstructorInfo.GetParameters() to wire services at runtime.
149158
IOptions<T> binders use PropertyInfo reflection to populate typed config
150-
objects from key-value pairs. ILoggerFactory finds providers by type. -->
159+
objects from key-value pairs. ILoggerFactory finds providers by type.
160+
NOTE: Microsoft.Extensions.Configuration (non-Abstractions) and
161+
Microsoft.Extensions.Http are NOT directly referenced by this project and
162+
are not shipped as standalone assemblies in .NET 10 (their APIs are in-box
163+
or merged into the Abstractions layer). Adding them here would generate
164+
"Could not resolve assembly" linker warnings with no preservation benefit. -->
151165
<assembly fullname="Microsoft.Extensions.DependencyInjection" preserve="all" />
152166
<assembly fullname="Microsoft.Extensions.DependencyInjection.Abstractions" preserve="all" />
153167
<assembly fullname="Microsoft.Extensions.Logging" preserve="all" />
154168
<assembly fullname="Microsoft.Extensions.Logging.Abstractions" preserve="all" />
155169
<assembly fullname="Microsoft.Extensions.Options" preserve="all" />
156-
<assembly fullname="Microsoft.Extensions.Configuration" preserve="all" />
157170
<assembly fullname="Microsoft.Extensions.Configuration.Abstractions" preserve="all" />
158171
<assembly fullname="Microsoft.Extensions.Primitives" preserve="all" />
159-
<assembly fullname="Microsoft.Extensions.Http" preserve="all" />
160172

161173
<!-- ═══════════════════════════════════════════════════════════════════════
162174
SQLite stack

osu.Android/OboeAudioRedirector.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,14 @@ private bool enqueueOnAudioThread(Action action)
178178

179179
while (t != null && cachedEnqueueActionMethod == null)
180180
{
181+
#pragma warning disable IL2075 // Type obtained via GetType()/BaseType does not carry DynamicallyAccessedMembers — reflection loop intentional, preserved by Linker.xml
181182
cachedEnqueueActionMethod = t.GetMethod(
182183
"EnqueueAction",
183184
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public,
184185
binder: null,
185186
types: new[] { typeof(Action) },
186187
modifiers: null);
188+
#pragma warning restore IL2075
187189

188190
t = t.BaseType;
189191
}
@@ -252,12 +254,14 @@ private void triggerMixerRecreation()
252254

253255
while (t != null && cachedUpdateDeviceMethod == null)
254256
{
257+
#pragma warning disable IL2075 // Type obtained via typeof().BaseType does not carry DynamicallyAccessedMembers — reflection loop intentional, preserved by Linker.xml
255258
cachedUpdateDeviceMethod = t.GetMethod(
256259
"UpdateDevice",
257260
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public,
258261
binder: null,
259262
types: new[] { typeof(int) },
260263
modifiers: null);
264+
#pragma warning restore IL2075
261265

262266
t = t.BaseType;
263267
}

osu.Android/OsuGameAndroid.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2754,7 +2754,9 @@ protected override void Dispose(bool isDisposing)
27542754
{
27552755
try
27562756
{
2757+
#pragma warning disable IL2075 // activeMixersList is typed as object — runtime type is known to be an INotifyCollectionChanged-derived BindableList, preserved by Linker.xml
27572758
MethodInfo? unbindMethod = activeMixersList.GetType().GetMethod("UnbindCollectionChanged", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
2759+
#pragma warning restore IL2075
27582760
unbindMethod?.Invoke(activeMixersList, new object[] { activeMixersHandler });
27592761
}
27602762
catch { }

0 commit comments

Comments
 (0)