Giter VIP home page Giter VIP logo

Comments (9)

aaubry avatar aaubry commented on May 18, 2024

Hi,

You need to use the "Roundtrip" option when serializing if you want the tag
to be emitted.
On Sep 29, 2013 12:00 AM, "xoofx" [email protected] wrote:

Hi,
Not sure I'm using the library correctly, but when trying to serialize a
simple class like this:

namespace TestYamlDotNet
{
public class Fruit
{
public string Name { get; set; }
}

class Program
{
    static void Main(string[] args)
    {
        var serializer = new Serializer(SerializationOptions.Roundtrip);
        var orange = new Fruit() { Name = "Orange" };
        serializer.Serialize(Console.Out, orange);
    }
}

It is outputing only the Name: Orange property instead of outputing
something like:

!TestYamlDotNet.Fruit
Name: Orange

Is this a correct behavior? I don't see how I can deserialize a node that
doesn't output any tag information.


Reply to this email directly or view it on GitHubhttps://github.com//issues/49
.

from yamldotnet.

xoofx avatar xoofx commented on May 18, 2024

This is what I have used in the samples above, but I don't get any !TestYamlDotNet.Fruit. I'm using latest git.

from yamldotnet.

xoofx avatar xoofx commented on May 18, 2024

Hm, it seems that this is not really handled by current code. Wondering if this part of the code has been really used so far? How are you using YamlDotNet for serializing a complex graph of C# objects to YAML?

I just made a dirty fix to spot where the problem is. TypeAssigningEventEmitter.cs seems to only handle scalars but not mapping nor sequences. I will have to add support for all other cases (sequences, arrays, Dictionary<,>, ICollection<>...etc.)

Edit: Ough, just noticed that YamlDotNet is using tabs instead of spaces, first time discovering that a C# project is using tabs instead of spaces (in VisualStudio it is default to spaces). I will try to keep tabs in my fork

from yamldotnet.

icalvo avatar icalvo commented on May 18, 2024

Very interesting because right now you can't roundtrip with properties with an abstract type or interface type, and it would be possible just adding the concrete type tag for those cases.

from yamldotnet.

roji avatar roji commented on May 18, 2024

@icalvo, please take a look at the discussion at #26. There is some work waiting to be merged that would take care of this issue.

from yamldotnet.

vasily-kirichenko avatar vasily-kirichenko commented on May 18, 2024

@xoofx Is it possible to turn off the tags in your fork? I'd like to get clean Yaml.

from yamldotnet.

xoofx avatar xoofx commented on May 18, 2024

@vasily-kirichenko you can turn-off them using latest version of SharpYaml (SerializerSettings.EmitTags = false). Please report issue/usage pb directly on SharpYaml instead of this old discussion, thanks.

from yamldotnet.

vasily-kirichenko avatar vasily-kirichenko commented on May 18, 2024

@xoofx OK, I'll try that setting. What about your fork - I cannot find any way to add an issue there. The "Issues" link is absent.

from yamldotnet.

xoofx avatar xoofx commented on May 18, 2024

@vasily-kirichenko, oops sorry, issues should be opened now

from yamldotnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.