diff --git a/Backtrace.Tests/SerializationTests/SerializationTests.cs b/Backtrace.Tests/SerializationTests/SerializationTests.cs new file mode 100644 index 0000000..6fcee34 --- /dev/null +++ b/Backtrace.Tests/SerializationTests/SerializationTests.cs @@ -0,0 +1,70 @@ +using Backtrace.Model; +using Backtrace.Services; +using NUnit.Framework; +using RichardSzalay.MockHttp; +using System; +using System.Collections.Generic; + +namespace Backtrace.Tests.IntegrationTests +{ + [TestFixture(Author = "Konrad Dysput", Category = "IntegrationTests.SerializationTests", Description = "Should handle specific serialization errors")] + public class SerializationTests + { + /// + /// Backtrace client + /// + private BacktraceClient _backtraceClient; + + /// + /// Prepare basic setup of Backtrace client + /// + [SetUp] + public void Setup() + { + var credentials = new BacktraceCredentials("https://validurl.com/", "validToken"); + + //mock api + var serverUrl = $"{credentials.BacktraceHostUri.AbsoluteUri}post?format=json&token={credentials.Token}"; + var mockHttp = new MockHttpMessageHandler(); + mockHttp.When(serverUrl) + .Respond("application/json", "{'object' : 'aaa'}"); + var api = new BacktraceApi(credentials, 0) + { + HttpClient = mockHttp.ToHttpClient() + }; + + //setup new client + _backtraceClient = new BacktraceClient(credentials) + { + BacktraceApi = api + }; + } + + /// + /// Test Backtrace report serialization with self referenced objects in annotations + /// + [Test(Author = "Konrad Dysput", Description = "Test self referenced exception")] + public void TestReportContainerSerialization_ExceptionReferenceLoop_ShouldIgnoreReferenceLoopInSerialization() + { + var error = new Exception("test error"); + + var foo = new SelfReferencedClass() + { + ClassId = "foo1" + }; + var foo2 = new SelfReferencedClass() { ClassId = "foo2", Next = foo }; + foo.Next = foo2; + + var report = new BacktraceReport(error, new Dictionary() { { "annotation", foo } }); + Assert.DoesNotThrow(() => _backtraceClient.Send(report)); + } + + + private class SelfReferencedClass + { + public SelfReferencedClass Next { get; set; } + public string ClassId { get; set; } + } + + } +} diff --git a/Backtrace/Backtrace.csproj b/Backtrace/Backtrace.csproj index 95726ab..5478e53 100644 --- a/Backtrace/Backtrace.csproj +++ b/Backtrace/Backtrace.csproj @@ -1,25 +1,30 @@  Backtrace + Backtrace netstandard2.0;net45;net35 true Backtrace Error Diagnostic Tools Debug Bug Bugs StackTrace - 2.1.7 + Backtrace Error Diagnostic Tools Debug Bug Bugs StackTrace + 2.1.8 Backtrace https://github.com/backtrace-labs/backtrace-csharp/blob/master/LICENSE - https://github.com/backtrace-labs/backtrace-csharp + https://github.com/backtrace-labs/backtrace-csharp http://backtrace.io/images/icon.png + en-US + http://backtrace.io/images/icon.png Backtrace's integration with C# applications allows customers to capture and report handled and unhandled C# exceptions to their Backtrace instance, instantly offering the ability to prioritize and debug software errors. Backtrace's integration with C# app allows customers to catch and report handled and unhandled C# exceptions to their Backtrace instance, instantly offering the ability to prioritize and debug errors. https://github.com/backtrace-labs/backtrace-csharp en - 2.1.7 + 2.1.8 en-US Backtrace I/O Backtrace I/O + Backtrace I/O Backtrace I/O - 2.1.7.0 - 2.1.7.0 + 2.1.8.0 + 2.1.8.0 diff --git a/Backtrace/Services/BacktraceApi.cs b/Backtrace/Services/BacktraceApi.cs index 4989f7b..f2d1a1e 100644 --- a/Backtrace/Services/BacktraceApi.cs +++ b/Backtrace/Services/BacktraceApi.cs @@ -229,7 +229,8 @@ private BacktraceResult ReadServerResponse(HttpWebRequest request, BacktraceRepo private JsonSerializerSettings JsonSerializerSettings { get; } = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, - DefaultValueHandling = DefaultValueHandling.Ignore + DefaultValueHandling = DefaultValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Ignore }; #region dispose private bool _disposed = false; // To detect redundant calls diff --git a/CHANGELOG.md b/CHANGELOG.md index 02e522b..c40016f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Backtrace C# Release Notes +## Version 2.1.8 - 26.03.2020 + +- Fixed self referenced object serialization errors. + ## Version 2.1.7 - 02.03.2020 - Fixed nullable attributes - diff --git a/README.md b/README.md index ae077e8..79193c0 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ # Backtrace -[![Backtrace@release](https://img.shields.io/badge/Backtrace%40master-2.1.7-blue.svg)](https://www.nuget.org/packages/Backtrace) +[![Backtrace@release](https://img.shields.io/badge/Backtrace%40master-2.1.8-blue.svg)](https://www.nuget.org/packages/Backtrace) [![Build status](https://ci.appveyor.com/api/projects/status/o0n9sp0ydgxb3ktu?svg=true)](https://ci.appveyor.com/project/konraddysput/backtrace-csharp) -[![Backtrace@pre-release](https://img.shields.io/badge/Backtrace%40dev-2.1.8-blue.svg)](https://www.nuget.org/packages/Backtrace) -[![Build status](https://ci.appveyor.com/api/projects/status/o0n9sp0ydgxb3ktu/branch/dev?svg=true)](https://ci.appveyor.com/project/konraddysput/backtrace-csharp/branch/dev) [Backtrace](http://backtrace.io/)'s integration with C# applications allows customers to capture and report handled and unhandled C# exceptions to their Backtrace instance, instantly offering the ability to prioritize and debug software errors.