Serialization library candidate review request

user1234 user1234 at 12.de
Tue Aug 29 13:16:44 UTC 2023


On Monday, 28 August 2023 at 19:18:17 UTC, GrimMaple wrote:
> On Monday, 28 August 2023 at 19:07:39 UTC, user1234 wrote:
>> On Sunday, 27 August 2023 at 19:39:05 UTC, GrimMaple wrote:
>>> [...]
>>> I tried to make it as universal as I could, but any 
>>> suggestions are welcome for a discussion.
>>
>> I had a quick look yesterday. One thing I have noticed is that 
>> virtual setter/getters dont seem to be supported.
>
> I took a quick look and I don't think I fully understood what 
> you meant. Meanwhile, I made a small snippet of how I 
> understood your point, here's an example:
>
> ```d
> @safe unittest
> {
>     static class A
>     {
>         @serializable int b() @safe { return 0; }
>     }
>
>     static class B : A
>     {
>         override int b() @safe { return 1; }
>     }
>
>     B b = new B();
>
>     assert(serializeToJSONString(cast(A)b) == `{"b":1}`);
> }
> ```
>
> I don't know if it's what you expected, but this unittest 
> passes.

```d
@safe unittest
{
     static class A
     {
         @serializable int b() @safe { return 0; }
     }

     static class B : A
     {
         override int b() @safe { return 1; }
     }

     A o = new B(); // for o.b serialialize 1, not 0
}
```


More information about the Digitalmars-d mailing list