C
C#2mo ago
Trixxtar

C# Yaml error

using System.Windows.Forms;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;

namespace HWScreen
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

var yaml = @"config:
sourceFolder: /home
destinationFolder: /home/billy/my-test-case";


var deserializer = new DeserializerBuilder()
.WithNamingConvention(CamelCaseNamingConvention.Instance)
.Build();

var obj = deserializer.Deserialize<MyModel>(yaml);
//obj.Dump();

textBox1.Text += (obj.config.sourceFolder);
}
}

public class MyModel
{
[YamlMember(Alias = "config", ApplyNamingConventions = false)]
public config config { get; set; }
}

public class config
{
public string sourceFolder { get; set; }
public string DestinationFolder { get; set; }
}
}
using System.Windows.Forms;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;

namespace HWScreen
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

var yaml = @"config:
sourceFolder: /home
destinationFolder: /home/billy/my-test-case";


var deserializer = new DeserializerBuilder()
.WithNamingConvention(CamelCaseNamingConvention.Instance)
.Build();

var obj = deserializer.Deserialize<MyModel>(yaml);
//obj.Dump();

textBox1.Text += (obj.config.sourceFolder);
}
}

public class MyModel
{
[YamlMember(Alias = "config", ApplyNamingConventions = false)]
public config config { get; set; }
}

public class config
{
public string sourceFolder { get; set; }
public string DestinationFolder { get; set; }
}
}
Then i change the sourceFolder: /home to COM_PORT: AUTO -> C# cannot find this item, but i cannot find the error here
6 Replies
viceroypenguin
viceroypenguin2mo ago
1. $codegif 2. COM_PORT: AUTO won't parse properly in yaml, because : are separators. you have to use 'COM_PORT: AUTO'
Trixxtar
Trixxtar2mo ago
i check this, thanks but the sourceFolder: /home works without problems, why? com: test -> OK com: AUTO -> OK com_port -> Error
viceroypenguin
viceroypenguin2mo ago
because /home does not have a :. COM_PORT: AUTO contains a :. you need to understand the spec of the yaml language you did source: 'com_port'?
Trixxtar
Trixxtar2mo ago
source: com_port does not work but source: com_port works i think i uderstand ok fuuu ^^ 'COM_PORT': AUTO does not work
Trixxtar
Trixxtar2mo ago
No description
Want results from more Discord servers?
Add your server
More Posts