This repository has been archived by the owner on May 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support base class private member deserialize #43
- Loading branch information
Showing
4 changed files
with
104 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Xunit; | ||
|
||
namespace Utf8Json.Tests | ||
{ | ||
public abstract class Base1 | ||
{ | ||
public int B1 { get { return _b1; } } | ||
private int _b1 = -1; | ||
} | ||
|
||
public abstract class Base2 : Base1 | ||
{ | ||
public int B2 { get { return _b2; } } | ||
private int _b2 = -2; | ||
} | ||
|
||
public class Impl1_2 : Base2 | ||
{ | ||
public string Name { get { return name; } } | ||
private string name = "none"; | ||
} | ||
|
||
public class BassClassDeserializeTest | ||
{ | ||
[Fact] | ||
public void Deserialize() | ||
{ | ||
var json = "{\"_b1\":10,\"_b2\":99,\"name\":\"foobar\"}"; | ||
|
||
var r = JsonSerializer.Deserialize<Impl1_2>(json, Utf8Json.Resolvers.StandardResolver.AllowPrivate); | ||
|
||
r.B1.Is(10); | ||
r.B2.Is(99); | ||
r.Name.Is("foobar"); | ||
} | ||
} | ||
} |