MessagePack-CSharp / MessagePack-CSharp

Extremely Fast MessagePack Serializer for C#(.NET, .NET Core, Unity, Xamarin). / msgpack.org[C#]
Other
5.83k stars 701 forks source link

perform mpc.exe get error in Unity 2019.2.18f:Serialization Object must mark MessagePackObjectAttribute. type: global::CustomAssets.Scripts.Model.Common.Gds.ExchangeTimeLimits #1017

Closed waxnssg closed 3 years ago

waxnssg commented 4 years ago

ExchangeTimeLimits is a field of GdsExchangeShop.

this is my code

[MessagePackFormatter(typeof(ExchangeTimeLimitsFormatter))]
public class ExchangeTimeLimits
    {

        public List<Tuple<long, long>> TimeLimits = new List<Tuple<long, long>>();

        public ExchangeTimeLimits()
        {

        }

        public ExchangeTimeLimits(JArray jArray)
        {
            foreach (var jar in jArray)
            {

                    TimeLimits.Add(new Tuple<long, long>(jar["view_time_start"].Value<long>(),jar["view_time_end"] .Value<long>()));

            }
        }

    }

[MessagePackObject]
    public class GdsExchangeShop : GdsAbstractBase
    {
        #region Fields

        [Key(StartKeyIndex )]
        public string ExchangeShopName;

        [Key(StartKeyIndex + 1)]
        public string DisplayName;

        [Key(StartKeyIndex + 2)]
        public bool IsTimeLimited;

        [Key(StartKeyIndex + 3)]
        public ExchangeTimeLimits ExchangeTimeLimits;

        #endregion

        #region Methods

        public GdsExchangeShop()
        {

        }

        public GdsExchangeShop(JObject jObject) : base(jObject)
        {
            ExchangeShopName = jObject["name"].Value<string>();
            DisplayName = jObject["display_name"].Value<string>();
            IsTimeLimited = jObject["time_limited"].Value<int>() == 1;
            ExchangeTimeLimits=new ExchangeTimeLimits((JArray) jObject["schedule"]);
        }

        #endregion
    }

when perform mpc.exe generate formatter code in Unity, i get the following error:

process result:1,stdoutx=Project Compilation Start:/Users/shishaoguang/work/hap-unity/client/Unity/Assets/CustomAssets/Scripts/Model/Common/Gds Project Compilation Complete:00:00:02.1225221 Method Collect Start Fail in console app running on MessagepackCompiler.RunAsync MessagePackCompiler.CodeAnalysis.MessagePackGeneratorResolveFailedException: Serialization Object must mark MessagePackObjectAttribute. type: global::CustomAssets.Scripts.Model.Common.Gds.ExchangeTimeLimits at MessagePackCompiler.CodeAnalysis.TypeCollector.GetObjectInfo(INamedTypeSymbol type) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 589 at MessagePackCompiler.CodeAnalysis.TypeCollector.CollectObject(INamedTypeSymbol type) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 583 at MessagePackCompiler.CodeAnalysis.TypeCollector.CollectCore(ITypeSymbol typeSymbol) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 391 at MessagePackCompiler.CodeAnalysis.TypeCollector.GetObjectInfo(INamedTypeSymbol type) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 763 at MessagePackCompiler.CodeAnalysis.TypeCollector.CollectObject(INamedTypeSymbol type) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 583 at MessagePackCompiler.CodeAnalysis.TypeCollector.CollectCore(ITypeSymbol typeSymbol) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 391 at MessagePackCompiler.CodeAnalysis.TypeCollector.Collect() in D:\a\1\s\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 322 at MessagePackCompiler.CodeGenerator.GenerateFileAsync(String input, String output, String conditionalSymbol, String resolverName, String namespace, Boolean useMapMode, String multipleIfDirectiveOutputSymbols) in D:\a\1\s\src\MessagePack.GeneratorCore\CodeGenerator.cs:line 58 at MessagePack.Generator.MessagepackCompiler.RunAsync(String input, String output, String conditionalSymbol, String resolverName, String namespace, Boolean useMapMode, String multipleIfDirectiveOutputSymbols) in D:\a\1\s\src\MessagePack.Generator\MessagepackCompiler.cs:line 30 at ConsoleAppFramework.ConsoleAppEngine.RunCore(ConsoleAppContext ctx, Type type, MethodInfo methodInfo, String[] args, Int32 argsOffset) ,stderrx= UnityEngine.Debug:Log(Object)

why is this happen? Now i must manual writing CustomFormatter for GdsExchangeShop to avoid this error.

neuecc commented 4 years ago

Thanks, fixed at #1018

waxnssg commented 4 years ago

Thanks, fixed at #1018

ok. when publish a new version for dotnet tools ?

neuecc commented 4 years ago

now merged, release schedule is unknown:)

github-actions[bot] commented 4 years ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.