From edd456094c96cea77e673e4c770e14089d3b0c3d Mon Sep 17 00:00:00 2001 From: Christopher Granade Date: Thu, 1 Jul 2021 15:06:44 -0700 Subject: [PATCH 1/2] Prevent circular references when serializing Qubit values. --- src/Simulation/Core/Qubit.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Simulation/Core/Qubit.cs b/src/Simulation/Core/Qubit.cs index 3ed1d618dec..8fe12a89062 100644 --- a/src/Simulation/Core/Qubit.cs +++ b/src/Simulation/Core/Qubit.cs @@ -1,10 +1,11 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using Newtonsoft.Json; namespace Microsoft.Quantum.Simulation.Core { @@ -36,6 +37,7 @@ public Qubit(int id) public int Id { get; private set; } [DebuggerBrowsable(DebuggerBrowsableState.Never)] + [JsonIgnore] public virtual object Value => this; [DebuggerBrowsable(DebuggerBrowsableState.Never)] From 0bc8719df8d8fe8d6511f630fefc4f76448060a2 Mon Sep 17 00:00:00 2001 From: Christopher Granade Date: Thu, 1 Jul 2021 18:16:06 -0700 Subject: [PATCH 2/2] Ignore Qubits property as well. --- src/Simulation/Core/Qubit.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Simulation/Core/Qubit.cs b/src/Simulation/Core/Qubit.cs index 8fe12a89062..30997f5f8e7 100644 --- a/src/Simulation/Core/Qubit.cs +++ b/src/Simulation/Core/Qubit.cs @@ -41,6 +41,7 @@ public Qubit(int id) public virtual object Value => this; [DebuggerBrowsable(DebuggerBrowsableState.Never)] + [JsonIgnore] public virtual IEnumerable Qubits => new Qubit[] { this }; public override bool Equals(object obj)