Skip to content

Commit 86bb4d6

Browse files
Pass non mapping to base serializer
For PSObjects that are not dictionaries or PSCustomObjects, pass the object directly to the base serializer. Signed-off-by: Gabriel Adrian Samfira <[email protected]>
1 parent c4a5e9b commit 86bb4d6

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

src/PowerShellYamlSerializer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeseria
124124

125125
public void WriteYaml(IEmitter emitter, object value, Type type, ObjectSerializer serializer) {
126126
var psObj = (PSObject)value;
127+
if (!typeof(IDictionary).IsAssignableFrom(psObj.BaseObject.GetType()) && !typeof(PSCustomObject).IsAssignableFrom(psObj.BaseObject.GetType())) {
128+
serializer(psObj.BaseObject, psObj.BaseObject.GetType());
129+
return;
130+
}
127131
var mappingStyle = this.useFlowStyle ? MappingStyle.Flow : MappingStyle.Block;
128132
emitter.Emit(new MappingStart(AnchorName.Empty, TagName.Empty, true, mappingStyle));
129133
foreach (var prop in psObj.Properties) {

0 commit comments

Comments
 (0)