forked from microsoft/vstest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1) microsoft#706 2) microsoft#618 Fix: Don’t serialize the type if that have self-referencing loop
- Loading branch information
1 parent
93a3a92
commit 6d07f2a
Showing
4 changed files
with
53 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
40 changes: 40 additions & 0 deletions
40
test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/JsonDataSerializerTests.cs
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 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.TestPlatform.CommunicationUtilities.UnitTests | ||
{ | ||
using System; | ||
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
[TestClass] | ||
public class JsonDataSerializerTests | ||
{ | ||
[TestMethod] | ||
public void SerializePayloadShouldSerializeAnObjectWithSelfReferencingLoop() | ||
{ | ||
var classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(null); | ||
classWithSelfReferencingLoop = new ClassWithSelfReferencingLoop(classWithSelfReferencingLoop); | ||
classWithSelfReferencingLoop.InfiniteRefernce.InfiniteRefernce = classWithSelfReferencingLoop; | ||
|
||
var sut = JsonDataSerializer.Instance; | ||
|
||
// this line should not throw exception | ||
sut.SerializePayload("dummy", classWithSelfReferencingLoop); | ||
} | ||
|
||
public class ClassWithSelfReferencingLoop | ||
{ | ||
public ClassWithSelfReferencingLoop(ClassWithSelfReferencingLoop ir) | ||
{ | ||
this.InfiniteRefernce = ir; | ||
} | ||
|
||
public ClassWithSelfReferencingLoop InfiniteRefernce | ||
{ | ||
get; | ||
set; | ||
} | ||
} | ||
} | ||
} |