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

Add support for deserializing fields in addition to properties #306

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions YamlDotNet.Test/Serialization/SerializationTestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ public class Simple
public string aaa { get; set; }
}

public class SimpleField
{
public string theField;
}

public class SimpleScratch
{
public string Scratch { get; set; }
Expand Down
11 changes: 11 additions & 0 deletions YamlDotNet.Test/Serialization/SerializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,17 @@ public void RoundtripDerivedClass()
.Subject.As<Derived>().ShouldBeEquivalentTo(new { ChildProp = "bar" }, o => o.ExcludingMissingMembers());
}

[Fact]
public void DeserializeField()
{
var text = @"theField: Howdy
...";

var result = Deserializer.Deserialize<SimpleField>(UsingReaderFor(text));

result.theField.Should().Be("Howdy");
}

[Fact]
public void RoundtripDerivedClassWithSerializeAs()
{
Expand Down
Loading