Coder Social home page Coder Social logo

Comments (10)

GeertvanHorrik avatar GeertvanHorrik commented on June 10, 2024

Could it be because it's actually called "Property"? There is an "OnPropertyChanged" virtual method and the property is called OnPropertyChanged. Or does it happen to any sort of property name?

from catel.fody.

Green7 avatar Green7 commented on June 10, 2024

the name of the property does not matter.

from catel.fody.

GeertvanHorrik avatar GeertvanHorrik commented on June 10, 2024

I've written reproducable unit tests. Will investigate why this happens.

from catel.fody.

GeertvanHorrik avatar GeertvanHorrik commented on June 10, 2024

Generated code:

public object MyProperty
{
	[CompilerGenerated]
	get
	{
		return <MyProperty>k__BackingField;
	}
	[CompilerGenerated]
	set
	{
		<MyProperty>k__BackingField = value;
		OnMyPropertyChanged();
		RaisePropertyChanged("MyProperty");
	}
}

from catel.fody.

GeertvanHorrik avatar GeertvanHorrik commented on June 10, 2024

It also seems to happen to Catel 5 (according to the unit tests). It's probably because the ObservableObject does not do a equality check before raising the property.

There could be 2 solutions here (but I think both need to be fixed in Catel itself):

  1. Get value before assigning in the model (but it will be "more expensive")
  2. Add equality checks in ObservableObject setters (bonus)

from catel.fody.

Green7 avatar Green7 commented on June 10, 2024

Yes, ObservableObject does not check the old value before setting it again.
But I don't understand why the line: Model.Property = "test"; causes the value to be set twice?

from catel.fody.

GeertvanHorrik avatar GeertvanHorrik commented on June 10, 2024

It only happens to ObservableObject (not ModelBase) because the ModelBase does equality checks under the hood. I think the best way to solve this is in the ViewModelBase since we can never rely on any model handling this correctly.

from catel.fody.

GeertvanHorrik avatar GeertvanHorrik commented on June 10, 2024

Closing this ticket in favor of the Catel one (this will be (is actually) fixed in Catel itself).

from catel.fody.

GeertvanHorrik avatar GeertvanHorrik commented on June 10, 2024

btw the other request is covered by #357 , but that will only solve this issue when using the Catel one. If you use any others, it would still fail (hence the fix in Catel itself).

from catel.fody.

Green7 avatar Green7 commented on June 10, 2024

Ok, I'm waiting for a fix in Catel.

from catel.fody.

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.