Cysharp / MemoryPack

Zero encoding extreme performance binary serializer for C# and Unity.
MIT License
3.29k stars 193 forks source link

Variable name starting with UnderScore is not recognized correctly in Unity #244

Closed harayuu9 closed 7 months ago

harayuu9 commented 7 months ago

A partial class is correctly generated in a .NET7 application using the code below, but when brought to Unity, a MEMPACK006 error is output.

Environment that does not work properly Unity 2022.3.8f1 MemoryPack 1.10.0

Environment that works properly net7.0 MemoryPack 1.10.0

[MemoryPackable]
public partial class Example
{
    [MemoryPackConstructor]
    private Example(string defaultLocale)
    {
        _defaultLocale = defaultLocale;
    }

    [MemoryPackInclude] private readonly string _defaultLocale;
}
harayuu9 commented 7 months ago

When I checked, it seems that the content fixed in #156 is not included in Unity's Generator. Looking at the History, it seems that the version of the Generator included in Unity is quite old.

https://github.com/Cysharp/MemoryPack/commits/main/src/MemoryPack.Unity/Assets/Plugins/MemoryPack/Runtime/MemoryPack.Generator/MemoryPack.Generator.Roslyn3.dll

harayuu9 commented 7 months ago

219 The same issue has already been raised as an issue.

hadashiA commented 7 months ago

Hello. Thanks for your report. 1.20.0 has been released and support in Unity has changed to via NuGet. So I believe this issue has been resolved.

Please check the release notes for more information. Thanks!