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

Serializing auto-generated properties but not calling regular properties getters. #98

Open
laloutre87 opened this issue Nov 19, 2021 · 0 comments
Assignees

Comments

@laloutre87
Copy link

laloutre87 commented Nov 19, 2021

Serializing object defined like that is long :

`
public class MyObject {
private object _SuperLongToCalculateField = null;

public object SuperLongToCalculateField {
	get {
		if (_SuperLongToCalculateField  == null) {
			Thread.Sleep(200000); // long calculation done here. 
                            _SuperLongToCalculateField   = "some value";
		}
		
		return _SuperLongToCalculateField;
	}
	set {
		_SuperLongToCalculateField = value;
	}
}

public int AnotherProperty { get; set; }

}
`

Because it seems like the getter of SuperLongToCalculateField is called.

Putting the SerializerConfig "DefaultTargets" value to "TargetMember.AllFields", solve the speed problem, but then "AnotherProperty" isn't serialized.

Would it be possible to have a DefaultTargets settings to save all fields + auto-generated properties ( " get; set; " ) only ?
Or is it already there and I am missing something ?

Thanks.

@laloutre87 laloutre87 changed the title Serializing auto-generated properties but not callign regular properties getter. Serializing auto-generated properties but not calling regular properties getters. Nov 19, 2021
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

2 participants