Skip to content

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

@laloutre87

Description

@laloutre87

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions