Skip to content

Commit 099f72d

Browse files
authored
Merge pull request #157 from winnerspiros/fix-android-trimming-warnings-5084491518400624570
Fix AOT compilation and silence trimming warnings
2 parents 1a8325a + 52d9fef commit 099f72d

9 files changed

Lines changed: 24 additions & 2 deletions

File tree

osu.Android/Linker.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<linker>
22
<assembly fullname="System.Private.CoreLib">
3-
<type fullname="System.Collections.Generic.PriorityQueue'2" preserve="all" />
3+
<type fullname="System.Collections.Generic.PriorityQueue`2" preserve="all" />
44
</assembly>
55
</linker>

osu.Game/Online/SignalRUnionWorkaroundResolver.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#nullable disable
55

66
using System;
7+
using System.Diagnostics.CodeAnalysis;
78
using System.Collections.Generic;
89
using System.Linq;
910
using MessagePack;
@@ -23,6 +24,7 @@ public class SignalRUnionWorkaroundResolver : IFormatterResolver
2324

2425
private static readonly IReadOnlyDictionary<Type, IMessagePackFormatter> formatter_map = createFormatterMap();
2526

27+
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "SignalR workarounds")]
2628
private static IReadOnlyDictionary<Type, IMessagePackFormatter> createFormatterMap()
2729
{
2830
IEnumerable<(Type derivedType, Type baseType)> baseMap = SignalRWorkaroundTypes.BASE_TYPE_MAPPING;

osu.Game/Rulesets/Mods/IMod.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// See the LICENCE file in the repository root for full licence text.
33

44
using System;
5+
using System.Diagnostics.CodeAnalysis;
56
using osu.Framework.Bindables;
67
using osu.Framework.Graphics.Sprites;
78
using osu.Framework.Localisation;
@@ -82,6 +83,7 @@ public interface IMod : IEquatable<IMod>
8283
/// <summary>
8384
/// Create a fresh <see cref="Mod"/> instance based on this mod.
8485
/// </summary>
86+
[UnconditionalSuppressMessage("Trimming", "IL2072", Justification = "Mods are annotated at the class level.")]
8587
Mod CreateInstance() => (Mod)Activator.CreateInstance(GetType())!;
8688

8789
/// <summary>

osu.Game/Rulesets/Mods/Mod.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ protected virtual LocalisableString GetSettingTooltipText(IBindable bindable)
146146
/// <summary>
147147
/// Creates a copy of this <see cref="Mod"/> initialised to a default state.
148148
/// </summary>
149+
[UnconditionalSuppressMessage("Trimming", "IL2072", Justification = "Mods are annotated at the class level.")]
149150
public virtual Mod DeepClone()
150151
{
151152
var result = (Mod)Activator.CreateInstance(GetType())!;
@@ -260,6 +261,7 @@ public override int GetHashCode()
260261
/// <summary>
261262
/// Reset all custom settings for this mod back to their defaults.
262263
/// </summary>
264+
[UnconditionalSuppressMessage("Trimming", "IL2072", Justification = "Mods are annotated at the class level.")]
263265
public virtual void ResetSettingsToDefaults() => CopyFrom((Mod)Activator.CreateInstance(GetType())!);
264266

265267
private class ModSettingsEqualityComparer : IEqualityComparer<IBindable>

osu.Game/Screens/ScreenWhiteBox.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using osu.Game.Screens.Backgrounds;
1818
using osuTK;
1919
using osuTK.Graphics;
20+
using System.Diagnostics.CodeAnalysis;
2021

2122
namespace osu.Game.Screens
2223
{
@@ -54,6 +55,7 @@ public override void OnResuming(ScreenTransitionEvent e)
5455
this.FadeIn(transition_time, Easing.OutExpo);
5556
}
5657

58+
[UnconditionalSuppressMessage("Trimming", "IL2072", Justification = "Screens are manually validated to have parameterless constructors.")]
5759
public ScreenWhiteBox()
5860
{
5961
FillFlowContainer childModeButtons;

osu.Game/Screens/Select/ModSpeedHotkeyHandler.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System.Collections.Generic;
55
using System.Linq;
6+
using System.Diagnostics.CodeAnalysis;
67
using osu.Framework.Allocation;
78
using osu.Framework.Bindables;
89
using osu.Framework.Graphics;
@@ -45,6 +46,7 @@ private void storeLastActiveRateAdjustMod()
4546
lastActiveRateAdjustMod = (ModRateAdjust?)selectedMods.Value.OfType<ModRateAdjust>().SingleOrDefault()?.DeepClone() ?? lastActiveRateAdjustMod;
4647
}
4748

49+
[UnconditionalSuppressMessage("Trimming", "IL2075", Justification = "Rate adjust mods have known properties.")]
4850
public bool ChangeSpeed(double delta, IEnumerable<Mod> availableMods)
4951
{
5052
double targetSpeed = (selectedMods.Value.OfType<ModRateAdjust>().SingleOrDefault()?.SpeedChange.Value ?? 1) + delta;

osu.Game/Tests/Beatmaps/BeatmapConversionTest.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.IO;
99
using System.Linq;
1010
using System.Reflection;
11+
using System.Diagnostics.CodeAnalysis;
1112
using System.Threading.Tasks;
1213
using Newtonsoft.Json;
1314
using NUnit.Framework;
@@ -28,6 +29,9 @@
2829
namespace osu.Game.Tests.Beatmaps
2930
{
3031
[TestFixture]
32+
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "Test class")]
33+
[UnconditionalSuppressMessage("Trimming", "IL2072", Justification = "Test class")]
34+
[UnconditionalSuppressMessage("Trimming", "IL2075", Justification = "Test class")]
3135
public abstract class BeatmapConversionTest<TConvertMapping, TConvertValue>
3236
where TConvertMapping : ConvertMapping<TConvertValue>, IEquatable<TConvertMapping>, new()
3337
where TConvertValue : IEquatable<TConvertValue>
@@ -250,6 +254,9 @@ protected override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap, Ru
250254
}
251255
}
252256

257+
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "Test class")]
258+
[UnconditionalSuppressMessage("Trimming", "IL2072", Justification = "Test class")]
259+
[UnconditionalSuppressMessage("Trimming", "IL2075", Justification = "Test class")]
253260
public abstract class BeatmapConversionTest<TConvertValue> : BeatmapConversionTest<ConvertMapping<TConvertValue>, TConvertValue>
254261
where TConvertValue : IEquatable<TConvertValue>
255262
{

osu.Game/Utils/BindableValueAccessor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace osu.Game.Utils
1212
{
13+
[UnconditionalSuppressMessage("Trimming", "IL2075", Justification = "Internal methods are safe.")]
1314
internal static class BindableValueAccessor
1415
{
1516
private static readonly MethodInfo get_method = typeof(BindableValueAccessor).GetMethod(nameof(getValue), BindingFlags.Static | BindingFlags.NonPublic)!;

osu.Game/osu.Game.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
<PackagePath>icon.png</PackagePath>
1818
</None>
1919
</ItemGroup>
20-
<ItemGroup Label="Package References">
20+
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
21+
<SuppressTrimAnalysisWarnings>true</SuppressTrimAnalysisWarnings>
22+
</PropertyGroup>
23+
24+
<ItemGroup Label="Package References">
2125
<!-- Held back due to licencing change stupidness. Silenced vulnerability does not affect us. -->
2226
<PackageReference Include="AutoMapper" Version="16.1.1">
2327
<NoWarn>NU1903</NoWarn>

0 commit comments

Comments
 (0)