json icon indicating copy to clipboard operation
json copied to clipboard

Writer get confused with calculated properties

Open jrmgx opened this issue 5 years ago • 0 comments

Given the current class

using System;
using UnityEngine;

[Serializable]
public class SzVector3
{
    public Vector3 Value => new Vector3(x, y, z); // Buggy

    public float x;
    public float y;
    public float z;

    public SzVector3(Vector3 v)
    {
        x = v.x;
        y = v.y;
        z = v.z;
    }
}

the writer will fail to build a json representation of this object with exception: TargetParameterCountException: Number of parameters specified does not match the expected number.

if you change the calculated propertie to a method like so public Vector3 Value() => new Vector3(x, y, z); it works.

I'm not a specialist so I can not help much more than that report

Thank you for that lib and for your time

jrmgx avatar Oct 27 '20 08:10 jrmgx