PowerApps-Tooling
PowerApps-Tooling copied to clipboard
Proof of Concept - YamlDotNet serialization and deserializaiton
Proof of concept for using YamlDotNet for our serialization & deserialization needs.
- Handles writing multiline strings in our preffered
|
style instead of YamlDotNet's default>
viaMultilineStyleEmitter.cs
- Serialized YAML writes properties in the order defined by
[YamlMember(Order = N)]
- Allows overriding default proper names via
[YamlMember(Alias = "example")]
- Prevent serialization and deserialization of specific properties with
[YamlIgnore]
- Serialization includes quotes on values when those values could be mistaken for another type
- strings containing numbers like
1
serialize to"1"
- strings with bools or special values like
true
/false
/no
/null
serialize to"true"
/"false"
/"no"
/"null"
- strings containing numbers like
- Deserialization uses provided type information, so typically resolves ambiguous types by using the provided type.
-
.Deserialize<string>(...)
or deserializing an object with string or string collection properties will correctly handle reading1
,true
,false
,no
without quotes as strings - Note:
.Deserialize<string>(...)
will however readnull
without quotes asnull
, as that is a valid value for the destinationstring
type
-
- Deserialization a polymorphic collection is doable, but requires more work. It is not currently included in the
YamlPocoConverter.cs
, but examples are provided with tests inControlInfoPoC.cs
- E.g., deserializing a
List<Control>
containing objects of inheriting types likeButton
orTextInput
need to contain a mapping type line (ControlType
in the included PoC), and the deserializer needs to be provided with that key-to-type mapping
- E.g., deserializing a
- Versioning of objects can also be handled by that same mapping, also included in the
ControlInfoPoC.cs
example