Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 2f0cf17

Browse files
committed
Added test of RuntimePropertyCache using properties with different attributes
1 parent 92b9b1e commit 2f0cf17

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/System.Text.Json/tests/Serialization/Object.WriteTests.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,28 @@ public int this[int index]
7777
}
7878

7979
[Fact]
80-
public static void WriteCollectionAsObject()
80+
public static void WritePolymorhicSimple()
8181
{
8282
string json = JsonSerializer.Serialize(new { Prop = (object)new[] { 0 } });
8383
Assert.Equal(@"{""Prop"":[0]}", json);
8484
}
85+
86+
[Fact]
87+
public static void WritePolymorphicDifferentAttributes()
88+
{
89+
string json = JsonSerializer.Serialize(new Polymorphic());
90+
Assert.Equal(@"{""P1"":"""",""p_3"":""""}", json);
91+
}
92+
93+
private class Polymorphic
94+
{
95+
public object P1 => "";
96+
97+
[JsonIgnore]
98+
public object P2 => "";
99+
100+
[JsonPropertyName("p_3")]
101+
public object P3 => "";
102+
}
85103
}
86104
}

0 commit comments

Comments
 (0)