Giter Site home page Giter Site logo

Comments (5)

Catalan-1ap avatar Catalan-1ap commented on June 15, 2024 1

Description Stylet/PropertyChangedBase.cs is missing the attribute [System.Text.Json.Serialization.JsonIgnore] to make classes serializable and deserializable.

To Reproduce

public class Test : Stylet.PropertyChangedBase
{
 public string TestString {get; set; }
}

can be serialized, but has a "PropertyChangedDispatcher": {} object which can't be deserialized.

Version Info

  • Stylet version: 1.3.6
  • Runtime version: 6.0.1

**Solution **

[System.Xml.Serialization.XmlIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public virtual Action<Action> PropertyChangedDispatcher
{
    get { return this._propertyChangedDispatcher; }
    set { this._propertyChangedDispatcher = value; }
}

You could serialize only what you want. Just mark your class with [JsonObject(MemberSerialization.OptIn)] and properties to serialize with [JsonProperty].

For more info see docs

from stylet.

phamilton4321 avatar phamilton4321 commented on June 15, 2024

That would also solve it, but in my opinion is more like a workaround. Especially because the xaml ignore attribute exist in your code.

from stylet.

canton7 avatar canton7 commented on June 15, 2024

Scheduled for the next release.

Note that I strongly recommend against serializing ViewModels. They're not meant to be serialized. Create a dedicated model that's meant to be serialized instead.

from stylet.

phamilton4321 avatar phamilton4321 commented on June 15, 2024

Thanks a lot!
I know and normally I'm against it too. But when I found this, I had to use the VM...

from stylet.

canton7 avatar canton7 commented on June 15, 2024

(this will be closed when the next release is merged)

from stylet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.