Comments (9)
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: OrangeIs 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.
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.
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.
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.
@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.
@xoofx Is it possible to turn off the tags in your fork? I'd like to get clean Yaml.
from yamldotnet.
@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.
@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.
@vasily-kirichenko, oops sorry, issues should be opened now
from yamldotnet.
Related Issues (20)
- Deserializing multiple documents does not work HOT 2
- Problem Deserializing a list of player HOT 5
- Serialize/Deserialize an array of different derived types HOT 3
- How to serialize the !include Directive in YamlDotNet HOT 8
- Getting Following Error for YamlDotNet.NetCore HOT 3
- IEnumerable support in StaticGenerator
- `Yaml.Text(...)` fumbles without trailing whitespace HOT 1
- `WithDuplicateChecking()` conflicts with `MergingParser` operation HOT 3
- `ExampleFromSpecificationIsHandledCorrectlyWithLateDefine()` test should fail
- Questions about Custom Serialization HOT 2
- Invalid date format used in serialized JSON HOT 2
- YamlDotNet does not write accurately equal to yaml being loaded HOT 1
- JsonCompatible serializer is not Json compatible HOT 4
- Is the IDeserializer thread safe? HOT 2
- Update benchmark file
- 15.1.0 EnsureRoundTrip no longer works without tag mapping and protected default constructors HOT 4
- yamldotnet is missing NuGet package README file
- Json Compatible Serialization does not produce JSON for nodes.
- Including (parts of) another YAML file HOT 11
- Serilizing an object with tags similar to AWS Cloudformation HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yamldotnet.