public static void NestedSameTypeWorks()
        {
            MyType myType = new() { Type = new() };
            string json   = JsonSerializer.Serialize(myType, JsonContext.Default.MyType);

            myType = JsonSerializer.Deserialize(json, JsonContext.Default.MyType);
            Assert.Equal(json, JsonSerializer.Serialize(myType, JsonContext.Default.MyType));

            MyType2 myType2 = new() { Type = new MyIntermediateType()
                                      {
                                          Type = myType
                                      } };

            json    = JsonSerializer.Serialize(myType2, JsonContext.Default.MyType2);
            myType2 = JsonSerializer.Deserialize(json, JsonContext.Default.MyType2);
            Assert.Equal(json, JsonSerializer.Serialize(myType2, JsonContext.Default.MyType2));
        }

        [Fact]
Exemple #2
0
        public override void NestedSameTypeWorks()
        {
            MyType myType = new() { Type = new() };
            string json   = JsonSerializer.Serialize(myType, DefaultContext.MyType);

            myType = JsonSerializer.Deserialize(json, ((ITestContext)MetadataWithPerTypeAttributeContext.Default).MyType);
            AssertFastPathLogicCorrect(json, myType, DefaultContext.MyType);

            MyType2 myType2 = new() { Type = new MyIntermediateType()
                                      {
                                          Type = myType
                                      } };

            json    = JsonSerializer.Serialize(myType2, DefaultContext.MyType2);
            myType2 = JsonSerializer.Deserialize(json, ((ITestContext)MetadataWithPerTypeAttributeContext.Default).MyType2);
            AssertFastPathLogicCorrect(json, myType2, DefaultContext.MyType2);
        }

        [Fact]