-
Notifications
You must be signed in to change notification settings - Fork 8
Fix XML flatten serialization: namespace loss, primitive formatting, document-root validity, and converter ordering #153
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
Changes from all commits
96d5d31
c013dbc
3de9f86
bc5e7bc
09ad4a9
5d863a3
9cb7018
53c6a54
587651e
124ee90
3a125d6
22f0d1c
5ddc879
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,9 +129,14 @@ internal XmlSerializerOptions RefreshWithConverterDependencies() | |
| _refreshed = true; | ||
| if (Settings.FlattenCollectionItems) | ||
| { | ||
| var existing = Decorator.Enclose(Settings.Converters).FirstOrDefaultWriterConverter(typeof(IEnumerable)); | ||
| if (existing != null) { Settings.Converters.Remove(existing); } | ||
| Decorator.Enclose(Settings.Converters).AddEnumerableConverter(flattenItems: true); | ||
| var converters = Decorator.Enclose(Settings.Converters); | ||
| while (true) | ||
| { | ||
| var existing = converters.FirstOrDefaultWriterConverter(typeof(IEnumerable)); | ||
| if (existing == null) { break; } | ||
| Settings.Converters.Remove(existing); | ||
| } | ||
| converters.AddEnumerableConverter(flattenItems: true); | ||
|
Comment on lines
+132
to
+139
|
||
| } | ||
| Decorator.Enclose(Settings.Converters) | ||
| .AddExceptionConverter(SensitivityDetails.HasFlag(FaultSensitivityDetails.StackTrace), SensitivityDetails.HasFlag(FaultSensitivityDetails.Data)) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updated flatten-items writer logic (namespace/prefix propagation, WriteValue formatting, and document-root wrapping) is not currently covered by unit tests. Please add tests that exercise: (1) FlattenCollectionItems=true with a root IEnumerable where Settings.RootName is set (ensuring the output is well-formed XML with a single document element), (2) primitive formatting (e.g., bool emits "true/false"), and (3) namespace/prefix preservation on the emitted elements.