Cloud Code Generate Bindings fail

I want to use AdminApiClient in CloudCode (config.Dependencies.AddSingleton(AdminApiClient.Create());)
But i realized its only avaliable in Unity.Services.CloudCode.Core.Admin which is not avaliable in CloudCode.Core (0.0.1).
So i updated it with NuGet to version (Com.Unity.Services.CloudCode.Core to 0.0.2). The code compiles and works properly when deployed but when generating bindings with updated module im having following error and no code is being generated (only assembly definition file is generated).
The error is not printed in console nor in deployment window, only in .ccmr file in inspector.

I need to access admin data & methods for matchmaking which im unable to do so (with generated bindings)

BTW i filed bug report IN-85351

1 Like

I also would like to point out another uncomfortable fact that:

  • When generating bindings no overloaded constructors are being transferred to generated code which makes it cumbersome to use transferred data structures - workaround is to write partial class that has overloaded constructors

Hi, we’re aware of this issue and have an SDK update coming soon to fix it. Apologies for the inconvenience.

Regarding the constructors, I can’t promise anything right now but I’ll bring it up with the team. Thanks for the feedback.

Thank you for fast reply, i would also like to add that it would be super helpful for bindings:

  • to be generated as static class/methods
  • transferring class & method comments (<summary></summary> etc.)
  • transferring methods from classes
  • properly serializing Enums and Tuples

These are inconvinient bits i encountered when working on it, i believe it will be improved & developed in future, appreciate the work anyway <3 :smile:

Hey!
Will bring feedback to the team.

  • to be generated as static class/methods

This is not likely to happen, as static methods/classes are much harder to test, and it would add an additional branching path to the generation. Instances are the way to go for this kind of stuff. (specially if you need to mock them in your code.

  • transferring class & method comments

This info is a bit harder to acquire, but I know we wanted to look at it ineventually.

  • transferring methods from classes

Technical feasibility is very limited. Unity is running C#8, whereas you can run up to C#13 on CloudCode. This doesnt even take into account the .NET version you are running, or the dependencies you might be running on the CloudCode side. However, if you are intent on doing this, you can do this easily manually by keeping your DTOs in Unity and sharing them with the C# side using a Compile item group on the CloudCode side:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>net8.0</TargetFramework>
        <ImplicitUsings>disable</ImplicitUsings>
        <OutputType>Library</OutputType>
    </PropertyGroup>

    <ItemGroup>
        <Compile Include="../Assets/DTOs/**/*.cs" />
    </ItemGroup>
</Project>
  • properly serializing Enums and Tuples

Enums should be fixed in the next iteration, though we have to look at tuples.

Hope this helps!

Cheers

1 Like

Is there an update to the binding bug?
I’m having the exact same problem

Hey,
Do you mind specifying which bug? If it is enum generation, its on the backlog, planned for later.

If it’s the specific crash, that is fixed in 2.8, what version of the Cloud-code package / Deployment package are you using?

2.8 and 2.9 had a number of fixes and improvements to cloud-code, I recommend latest.

## [2.8.0] - 2024-10-18

### Added
- View in Deployment Window button in `.ccmr` and `.js` files, dependent on Deployment package version 1.4.0.
- View in Dashboard button in inspector for `.ccmr` and `.js` files.
- View in Dashboard context menu in Deployment Window for `.ccmr` and `.js` files.
- Add `Open Solution` button to `.ccmr` inspector.
- Add Enum support for Cloud Code Bindings generation.

### Fixed
- Fixed support for various primitive types in Cloud Code Modules binding generation
- In-script parameters analysis throws an exception in Unity 6
- `Browse...` button in `.ccmr` inspector now opens the current solution folder properly.
- Fixed Cloud Code Binding generation of primitive types
- Binding Generation will attempt to run in the latest available runtime.
  - This can be disabled with CLOUD_CODE_AUTHORING_DISABLE_VERSION_DETECT flag

Cheers!

1 Like

I got the same error as XamverGames at the top of this thread; whenever I tried to generate bindings for a module containing: “config.Dependencies.AddSingleton(AdminApiClient.Create());”

But as I kept poking around it turned out that Visual Studio automagically installed v9 of Microsoft.Extensions.Logging.Abstractions. I downgraded to v7 and now everything is working.

Thanks!

1 Like

Im glad that worked out. To help with the feedback, what version of the com.unity.services.cloudcode package were you using, what .NET versions do you have installed (dotnet --list-runtimes, dotnet --list-sdks), and was the project compiling?
I wanna see if there’s something we can improve in the feedback.

The cloud code module was indeed compiling even though creating bindings failed. My first workaround was to comment out “config.Dependencies.AddSingleton(AdminApiClient.Create());”
and create the bindings, then reactivate the above code, before compiling/deploying. Which worked, with a bit of tweaks to the bindings script.

It would definitely have been great to get a note in the Console that the Microsoft.Extensions.Logging.Abstractions version wasn’t supported. The DotNet error code wasn’t exactly helpful :smiley:

Unity 2022.3.50f1, Windows 11

  • Cloud Code 2.9.0
  • Deployment 1.4.1

Microsoft.AspNetCore.App 7.0.20
Microsoft.AspNetCore.App 8.0.12
Microsoft.AspNetCore.App 9.0.1
Microsoft.NETCore.App 6.0.36
Microsoft.NETCore.App 7.0.20
Microsoft.NETCore.App 8.0.12
Microsoft.NETCore.App 9.0.1
Microsoft.WindowsDesktop.App 6.0.36
Microsoft.WindowsDesktop.App 7.0.20
Microsoft.WindowsDesktop.App 8.0.12
Microsoft.WindowsDesktop.App 9.0.1

SDKs:
7.0.410
9.0.102

1 Like

Hi

As mentioned in the first post. I also need to access AdminApiClient to perform matchmaking.

Finding documentation for the Cloud Code modules has been really difficult.

Do I really need AdminApiClient for matchmaking?

I saw that the GameApiClient interface has access to IMatchmakerTicketsApi. Would it be possible to perform matchmaking through this interface?

How do I see which version of Com.Unity.Services.CloudCode.Core I am using?

How do I update?

Thanks for your help.

Hi, the AdminApiClient isn’t necessary for matchmaking in Cloud Code, the IMatchmakerTicketsApi on the GameApiClient is what you need. You would first call CreateTicketAsyc, then poll its status using GetTicketStatusAsync (alternatively you can call MatchmakerService.Instance.GetTicketAsync directly from the client).

You can check/update your version of the Core package through the Nuget package manager in your IDE. There are a few ways to access this, but probably the simplest is to right click on your project in the solution view and choose “Manage Nuget Packages” (I believe this is an option on both Visual Studio and Rider). You can then choose the package from the list, choose the version you want from the dropdown (it should default to the latest version) and hit the install/upgrade button.

1 Like