-
-
Notifications
You must be signed in to change notification settings - Fork 7
NativeAoT support #107
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
base: master
Are you sure you want to change the base?
NativeAoT support #107
Conversation
…e now properly annotated
I forgot i had to do it, but to make the Godot sample work with PublishAoT another necessary change is to the json serialization used to communicate with the lobby server, have it use JsonTypeInfos (or JsonSerializerContext source generation) instead of reflection. |
Hi, thanks for the contribution, I will get some time to review these changes |
My pleasure! |
I don’t mind; you are welcome to open issues and/or discussions. Regarding this pull request:
|
Sure, I won't have time to work on it this week but I think I'll manage for the next one. |
7cac1c1
to
a4f5aa8
Compare
I solved the conflicts and kept .net8.0 support, although I had to make a few compromises to do it:
|
Saw the build failing and realized I forgot to downgrade the sdk version in the global.json file, should build fine now. |
@@ -15,7 +16,7 @@ | |||
|
|||
namespace Backdash.Backends; | |||
|
|||
sealed class RemoteBackend<TInput> : INetcodeSession<TInput>, IProtocolNetworkEventHandler | |||
sealed class RemoteBackend<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] TInput> : INetcodeSession<TInput>, IProtocolNetworkEventHandler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why Interfaces
? usually, the input type is a raw unmanaged structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In BinarySerializerFactory.Get
there is a call to typeof(TInput).GetInterfaces()
, which requires the annotation, and it bubbles up from there.
The call is there to check whether the type can be serialized by an IntegerBinarySerializer
.
I agree it makes little sense for the whole backend's input to be something serializable as an integer and it's for sure an edge case, but removing the edge case would lead to restricting functionality, which I'm not comfortable doing as my first PR to a repo.
Especially when you consider that the SpaceWar demo uses an enum as TInput, which is close enough to an integer for me to consider that edge case not so "edge" after all.
In theory when TInput is a raw unmanaged struct without any interfaces that annotation does nothing but clutter the source code a bit, no performance or trimmed size impact. (I say in theory because I have not personally tested it to be true, just relying on documentation)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that I look at the latest changes, it seems like you removed BinarySerializerFactory.Get
, I'll update the branch and see if these annotations are at all necessary anymore.
JsonStateStringParser annotations
…nalyzers always on
Updated to the latest version, the NetcodeSessionBuilder change is great! The only place annotations were needed was JsonStateStringParser. There's more corollary fixes than anything else in this PR now, I can split it into multiple if you think it'd be cleaner. |
Hi, I will come back to these changes when |
Closes #56
Removing code when "AOT_ENABLED" is set is no longer necessary with .net9.0, thanks to Intrinsic APIs marked RequiresDynamicCode now including MethodInfo.MakeGenericMethod.
I annotated the entire library (and tests) with the required attributes and provided overloads that don't require dynamically accessed code to the few methods that still require it (mostly due to json serialization).
Also made Backdash.Analyzers compatible with visual studio on the way, for convenience.
Tests succeed both with and without PublishAoT, the Godot sample also exports and plays with PublishAoT with a single minimal change: the export setting "Embed Build Outputs" makes it crash on startup.