Cysharp / MagicOnion

Unified Realtime/API framework for .NET platform and Unity.
MIT License
3.68k stars 417 forks source link

The type or namespace name 'MessagePack' does not exist in the namespace 'MagicOnion.Serialization' #756

Closed Nickmiste closed 2 months ago

Nickmiste commented 2 months ago

The Problem

I've been working with MagicOnion in Unity for a while, and I recently updated my project setup to move off of the deprecated version of gRPC. However, I am now seeing the following compiler errors related to source generation. Note that all three errors are identical apart from the line numbers.

Screenshot 2024-04-11 at 10 54 53 AM

Project Setup

The following packages are installed via the Unity package manager:

The following packages are installed via NuGetForUnity:

I am running this on an Apple Silicon Mac.

In player settings, the scripting backend is set to IL2CPP and the api compatibility level is set to .NET Framework.

I have the source generator setup using MagicOnionClientGenerationAttribute. This file, as well as all of my other code, is contained within its own asmdef. As I understand it, this source generation takes the place of moc, but MessagePack still requires its own manual generation step using mpc. The error above is shown regardless of whether the file generated with mpc exists.

I should also mention that the shared service interfaces are stored in the server directory outside of the Unity project, and then the Unity project symlinks to them.

Nickmiste commented 2 months ago

Removing all asmdefs from my project fixes the compiler errors, but this isn't ideal. Still looking for a more permanent fix.

Nickmiste commented 2 months ago

Turns out the issue was that I was missing a reference to MagicOnion.Serialization.MessagePack in the asmdef that contained my code. Closing this as resolved!