Properties with [YamlIgnore] being accessed during serialization #90

Closed
roji opened this Issue Mar 3, 2014 · 3 comments

Comments

Projects
None yet
2 participants
Contributor

roji commented Mar 3, 2014

[YamlIgnore] doesn't exactly work - properties having it are still invoked, and their results are discarded only afterwards.

For example, if a property with [YamlIgnore] throws an exception, this will make the serialization process abort.

Repro in this commit: https://github.com/roji/YamlDotNet/tree/yamlignore_issue

@roji roji pushed a commit to roji/YamlDotNet that referenced this issue Mar 3, 2014

Shay Rojansky Test case for [YamlIgnore] issue
See #90
648463e
Owner

aaubry commented Mar 3, 2014

You're right, this is a bug. This is caused by the way property descriptors are implemented. I had already identified the need to refactor that interface in two so that the property metadata is not mixed with the accessors. Let me take another look at it and I will get back to you.

Owner

aaubry commented Mar 5, 2014

I have started a branch to address this issue and added commit 292c780 as an initial approach to fix this error.

The bug was that when a property's metadata is gathered, the value of that property was read because in some cases it was needed later to get the actual type of the value. I have changed the behavior so that the property value is read only when needed.

I am still not happy with this part of the code, mostly because part of IPropertyDescriptor (TypeOverride) is mutable while another part (Name) is immutable and altered through composition. This should be revisited, but maybe we could release this fix as-is so that anyone can benefit from it.

Please let me know if you see any problem with this fix.

Owner

aaubry commented Mar 18, 2014

I have merged the current fix into the main branch and released an update.

aaubry closed this Mar 18, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment