Skip to content
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

zero value can't parse #318

Closed
zxs1215 opened this issue Apr 21, 2018 · 2 comments
Closed

zero value can't parse #318

zxs1215 opened this issue Apr 21, 2018 · 2 comments

Comments

@zxs1215
Copy link

zxs1215 commented Apr 21, 2018

this is my UnitTest Code:
using UnityEngine;
using UnityEditor;
using UnityEngine.TestTools;
using NUnit.Framework;
using System.Collections;
using YamlDotNet.Serialization;
using YamlDotNet.Samples.Helpers;
using YamlDotNet.Serialization.NamingConventions;
public class YamlZeroTest {
[Test]
public void YamlZeroTestSimplePasses() {
Test test = new Test ();
test.x = 0;
test.y = 1;
var serialize = new SerializerBuilder ().Build ();
string s = serialize.Serialize (test);
string expect = @"
x: 0
y: 1
";
Assert.AreEqual(expect.Trim(),s);
}
}
class Test
{
public int x{get;set;}
public int y{get;set;}
}
test can't pass.
I found that ,when x is 0, x dissappeared in the yaml string .
Expected: "x: 0\ny: 1"
But was: "y: 1\n"

I am not sure if this is a bug.
What can I do to show x in the yaml string?

@aaubry
Copy link
Owner

aaubry commented Apr 23, 2018

By default the serializer does not emit default values. You can change that by calling EmitDefaults on the SerializerBuilder.

@aaubry
Copy link
Owner

aaubry commented Aug 15, 2019

I have opened issue #427 that is related to your question. Feel free to join the discussion and provide any feedback that might be relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants