- 
                Notifications
    
You must be signed in to change notification settings  - Fork 64
 
Added missing snapshot apis #1307
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: main
Are you sure you want to change the base?
Conversation
| [Register("getSnapshotsClient", "(Landroid/app/Activity;)Lcom/google/android/gms/games/SnapshotsClient;", "")] | ||
| public static unsafe global::Android.Gms.Games.SnapshotsClient GetSnapshotsClient(global::Android.App.Activity activity) | ||
| { | ||
| const string __id = "getSnapshotsClient.(Landroid/app/Activity;)Lcom/google/android/gms/games/SnapshotsClient;"; | ||
| try | ||
| { | ||
| JniArgumentValue* __args = stackalloc JniArgumentValue[1]; | ||
| __args[0] = new JniArgumentValue((activity == null) ? IntPtr.Zero : ((global::Java.Lang.Object)activity).Handle); | ||
| var __rm = _members.StaticMethods.InvokeObjectMethod(__id, __args); | ||
| return global::Java.Lang.Object.GetObject<global::Android.Gms.Games.SnapshotsClient>(__rm.Handle, JniHandleOwnership.TransferLocalRef)!; | ||
| } | ||
| finally | ||
| { | ||
| global::System.GC.KeepAlive(activity); | ||
| } | ||
| } | 
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.
Were these generated following .NET 10's generated code? or .NET 8/9?
.NET 10 has significate changes here to support NativeAOT.
Ideally, we could somehow make this work in Metadata.xml, as it would not need to be manually updated if we improve the generated code.
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.
this is generated only for .NET 8/9.
I tried different approaches to fix them with metadata.xml file but no luck, it just skips these Apis even if you write metadata.xml correctly, my guess is that there is a bug or limitation with Xamarin binding generator
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.
Does it print out a build warning? That could say why it skips them.
@moljac might have some suggestions?
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.
I triggered @copilot to see if it comes up with anything:
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.
for exmaple I tried this:
<attr path="/api/package[@name='com.google.android.gms.games.snapshot']/class[@name='Snapshot']" name="visibility" value="public" />
and  also this
<interface` path="/api/package[@name='com.google.android.gms.games.snapshot']/interface[@name='Snapshot']" name="Snapshot" managedName="ISnapshot" visibility="public" /> 
but none of them generated the snapshot class or interface and I didn't see any warning during build process
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.
for exmaple I tried this:
<attr path="/api/package[@name='com.google.android.gms.games.snapshot']/class[@name='Snapshot']" name="visibility" value="public" />
OK this looks OK.
and also this
<interface` path="/api/package[@name='com.google.android.gms.games.snapshot']/interface[@name='Snapshot']" name="Snapshot" managedName="ISnapshot" visibility="public" />
This does not make sense. This looks like api.xml snippet.
but none of them generated the snapshot class or interface and I didn't see any warning during build process
You must turn on all warnings to see what is going on. Yeah it is a bit unpractical, but 99% of those warnings will never (or optimistically not so soon) be fixed.
| 
          
 Generated code approach is really not recommended, because in future .NET versions tooling could generate different code and this might not work. It took me few months to clean all up. Historically we had to resort to that workaround, because of bugs in our tooling. Today it should be much much better.  | 
    
This pull request adds missing Snapshot APIs for Play Games Services V2, which are currently skipped in the Xamarin bindings (see issue #972). Attempts to expose them via Metadata.xml were unsuccessful, as the bindings ignored the relevant classes. I resolved this by manually adding bindings to the Additions folder. These APIs are actively used in my game and confirmed to be working.