Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions osu.Desktop/IPC/OsuWebSocketProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ private void broadcast(OsuWebSocketMessage message)
if (server?.IsRunning != true)
return;

#pragma warning disable IL2026
string messageString = JsonConvert.SerializeObject(message);
#pragma warning restore IL2026
server.BroadcastAsync(messageString).FireAndForget();
}

Expand Down
2 changes: 2 additions & 0 deletions osu.Desktop/OsuGameDesktop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ protected override void LoadComplete()
{
base.LoadComplete();

#pragma warning disable IL2026
LoadComponentAsync(new DiscordRichPresence(), Add);
#pragma warning restore IL2026

switch (RuntimeInfo.OS)
{
Expand Down
2 changes: 2 additions & 0 deletions osu.Desktop/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ public static void Main(string[] args)
try
{
Logger.Log("Starting legacy IPC provider...");
#pragma warning disable IL2026
legacyIpc = new LegacyTcpIpcProvider();
#pragma warning restore IL2026
legacyIpc.Bind();
}
catch (Exception ex)
Expand Down
2 changes: 2 additions & 0 deletions osu.Desktop/Windows/GameplayWinKeyBlocker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ private void updateBlocking()
{
bool shouldDisable = isActive.Value && disableWinKey.Value && localUserPlaying.Value == LocalUserPlayingState.Playing;

#pragma warning disable IL3000
if (shouldDisable)
host.InputThread.Scheduler.Add(WindowsKey.Disable);
else
host.InputThread.Scheduler.Add(WindowsKey.Enable);
#pragma warning restore IL3000
}
}
}
2 changes: 2 additions & 0 deletions osu.Game/Configuration/ModSettingChangeTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Mods;
Expand All @@ -30,6 +31,7 @@ public class ModSettingChangeTracker : IDisposable
/// Creates a new <see cref="ModSettingChangeTracker"/> for a set of <see cref="Mod"/>s.
/// </summary>
/// <param name="mods">The set of <see cref="Mod"/>s whose settings need to be tracked.</param>
[UnconditionalSuppressMessage("ILLink", "IL2026", Justification = "SettingSourceAttribute uses reflection intentionally; callers on trimmed targets must ensure mod types are preserved.")]
public ModSettingChangeTracker(IEnumerable<Mod> mods)
Comment on lines +34 to 35
{
foreach (var mod in mods)
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Configuration/SettingSourceAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public SettingSourceAttribute(string? label, string? description = null)
Description = description ?? string.Empty;
}

public SettingSourceAttribute(Type declaringType, string label, string description, int orderPosition)
public SettingSourceAttribute([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type declaringType, string label, string description, int orderPosition)
: this(declaringType, label, description)
{
OrderPosition = orderPosition;
Expand Down
3 changes: 2 additions & 1 deletion osu.Game/Database/BackgroundDataStoreProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public partial class BackgroundDataStoreProcessor : Component

protected virtual int TimeToSleepDuringGameplay => 30000;

[RequiresUnreferencedCode("Calls processScoresWithMissingStatistics which uses Newtonsoft.Json reflection.")]
protected override void LoadComplete()
{
base.LoadComplete();
Expand All @@ -94,7 +93,9 @@ protected override void LoadComplete()
processOnlineBeatmapSetsWithNoUpdate();
// Note that the previous method will also update these on a fresh run.
processBeatmapsWithMissingObjectCounts();
#pragma warning disable IL2026
processScoresWithMissingStatistics();
#pragma warning restore IL2026
convertLegacyTotalScoreToStandardised();
upgradeScoreRanks();
backpopulateMissingSubmissionAndRankDates();
Expand Down
2 changes: 2 additions & 0 deletions osu.Game/Database/RealmAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
Expand Down Expand Up @@ -838,6 +839,7 @@ private void onMigration(Migration migration, ulong lastSchemaVersion)
applyMigrationsForVersion(migration, i);
}

[UnconditionalSuppressMessage("ILLink", "IL2026", Justification = "Dynamic binding in realm migrations is intentional and safe for non-trimmed targets.")]
private void applyMigrationsForVersion(Migration migration, ulong targetVersion)
{
Logger.Log($"Running realm migration to version {targetVersion}...");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;

namespace osu.Game.IO.Serialization.Converters
{
public class SnakeCaseStringEnumConverter : StringEnumConverter
{
[UnconditionalSuppressMessage("ILLink", "IL2026", Justification = "Newtonsoft.Json reflection usage is intentional and safe for non-trimmed targets.")]
public SnakeCaseStringEnumConverter()
{
NamingStrategy = new SnakeCaseNamingStrategy();
Expand Down
4 changes: 4 additions & 0 deletions osu.Game/IO/Serialization/Converters/TypedListConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@ public override IReadOnlyList<T> ReadJson(JsonReader reader, Type objectType, IR
throw new JsonException("Expected $type token.");

// Prevent instantiation of types that do not inherit the type targetted by this converter
#pragma warning disable IL2057
Type type = Type.GetType(lookupTable[(int)tok["$type"]]).AsNonNull();
#pragma warning restore IL2057
if (!type.IsAssignableTo(typeof(T)))
continue;

#pragma warning disable IL2072
var instance = (T)Activator.CreateInstance(type)!;
#pragma warning restore IL2072
serializer.Populate(itemReader, instance);

list.Add(instance);
Expand Down
5 changes: 5 additions & 0 deletions osu.Game/IO/Serialization/JsonSerializableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@
#nullable disable

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json;
using osu.Framework.IO.Serialization;

namespace osu.Game.IO.Serialization
{
public static class JsonSerializableExtensions
{
[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
Comment on lines +15 to 25
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
Expand Down
Loading