Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotate ControlPoint and Mod for AOT trimming support #28503

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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.Game/Beatmaps/ControlPoints/ControlPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json;
using osu.Game.Graphics;
using osu.Game.Utils;
using osuTK.Graphics;

namespace osu.Game.Beatmaps.ControlPoints
{
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you tested that this is enough, on the real thing, rather than on the example in the OP? On a quick look [DynamicallyAccessedMembers] has Inherited = false specified so I am not immediately confident that it will fully eliminate your workaround.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I admit I initially didn't, because it's kinda annoying to, which is why I did it in a separate example.

It does look to be working in practice though, with one caveat - I missed that LegacyControlPointInfo isn't a ControlPoint (naming... >_<) Will fix in next commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fyi, I think that this part of the documentation is the most relevant: https://github.com/dotnet/runtime/blob/257e76dfe64cb5b347aba7bc5a31a50c3c8cc106/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/DynamicallyAccessedMembersAttribute.cs#L19-L21

I also noticed Inherited = false and questioned this behaviour, and had to verify myself. I also explored the alternative of using System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute but that one does not work for inherited types.

public abstract class ControlPoint : IComparable<ControlPoint>, IDeepCloneable<ControlPoint>, IEquatable<ControlPoint>, IControlPoint
{
[JsonIgnore]
Expand Down
2 changes: 2 additions & 0 deletions osu.Game/Rulesets/Mods/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Reflection;
Expand All @@ -21,6 +22,7 @@ namespace osu.Game.Rulesets.Mods
/// <summary>
/// The base class for gameplay modifiers.
/// </summary>
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
public abstract class Mod : IMod, IEquatable<Mod>, IDeepCloneable<Mod>
{
[JsonIgnore]
Expand Down
Loading