How to set meaningful names for anchor tags during Yaml serialization using YamlDotNet library in C#?

115 views Asked by At

Set anchor tag name during serialization using YamlDotNet library.

I am using YAMLDotNet to serialize object to Yaml. I am using XML file and generating YAML out of it using YamlDotNet. The YAML that gets generated has anchor tags however, the name of the tags is odd. I want to control the name given to anchor tag and give a more meaningful name to it. Below is the example of what I am getting as a result and what I expect.

For e.g. Yaml that gets generated is [

SystemDefaults:
  DatabaseSpecs: &o0
    Server: 10.0.0.1
    Name: EBC
  EmailInfo: &o1
    SMTP: jcemail.mailhost.smtp.net
    Port: 25   
RoutingEntry:
  PUB1:
    Type: Group
    DatabaseSpecs: *o0
    EmailInfo: *o1

However, I want output as,

SystemDefaults:
  DatabaseSpecs: &Db1
    Server: 10.0.0.1
    Name: EBC
  EmailInfo: &SM1
    SMTP: jcemail.mailhost.smtp.net
    Port: 25   
RoutingEntry:
  PUB1:
    Type: Group
    DatabaseSpecs: *Db1
    EmailInfo: *SM1

If you have any solution/workaround for this issue then please give your suggestions. In case if you need more details please

0

There are 0 answers