Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialization framework ignores custom serialization methods of const instances. #878

Closed
japplegame opened this issue Oct 22, 2014 · 0 comments

Comments

@japplegame
Copy link
Contributor

import vibe.d;

struct Data {
    int a;
}

struct Foo {
    private Data m_data;

    this(Data data) { m_data = data; }

    Data toRepresentation() const { return m_data; }
    static Foo fromRepresentation(Data data) { return Foo(data); }
}

void main() {
    const Foo foo1 = Foo(Data(10));
    Foo foo2 = foo1.serializeToJson.deserializeJson!Foo;
    assert(foo1 == foo2);
}

It doesn't work:
Serializing composite type const(Foo) which has no serializable fields

s-ludwig added a commit that referenced this issue Oct 30, 2014
Allows custom serializable const class/struct instances. Fixes #878
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant