diff --git a/Src/PChecker/CheckerCore/SystematicTesting/TestingEngine.cs b/Src/PChecker/CheckerCore/SystematicTesting/TestingEngine.cs index a72cfbdd8..b86a3852a 100644 --- a/Src/PChecker/CheckerCore/SystematicTesting/TestingEngine.cs +++ b/Src/PChecker/CheckerCore/SystematicTesting/TestingEngine.cs @@ -591,6 +591,36 @@ public string GetReport() return TestReport.GetText(_checkerConfiguration, "..."); } + /// + /// Returns an object where the value null is replaced with "null" + /// + public object RecursivelyReplaceNullWithString(object obj) { + if (obj == null) { + return "null"; + } + if (obj is Dictionary dictionary) { + var newDictionary = new Dictionary(); + foreach (var item in dictionary) { + var newVal = RecursivelyReplaceNullWithString(item.Value); + if (newVal != null) + newDictionary[item.Key] = newVal; + } + return newDictionary; + } + else if (obj is List list) { + var newList = new List(); + foreach (var item in list) { + var newItem = RecursivelyReplaceNullWithString(item); + if (newItem != null) + newList.Add(newItem); + } + return newList; + } + else { + return obj; + } + } + /// /// Tries to emit the testing traces, if any. /// @@ -640,6 +670,11 @@ public void TryEmitTraces(string directory, string file) var jsonPath = directory + file + "_" + index + ".trace.json"; Logger.WriteLine($"..... Writing {jsonPath}"); + // Remove the null objects from payload recursively for each log event + for(int i=0; i