Skip to content

Commit

Permalink
## Version 2.1.8 - 26.03.2020
Browse files Browse the repository at this point in the history
- Fixed self referenced object serialization errors.
  • Loading branch information
konraddysput committed Mar 26, 2020
1 parent 273cfd2 commit 8357571
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 9 deletions.
70 changes: 70 additions & 0 deletions Backtrace.Tests/SerializationTests/SerializationTests.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Backtrace client
/// </summary>
private BacktraceClient _backtraceClient;

/// <summary>
/// Prepare basic setup of Backtrace client
/// </summary>
[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
};
}

/// <summary>
/// Test Backtrace report serialization with self referenced objects in annotations
/// </summary>
[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<string, object>() { { "annotation", foo } });
Assert.DoesNotThrow(() => _backtraceClient.Send(report));
}


private class SelfReferencedClass
{
public SelfReferencedClass Next { get; set; }
public string ClassId { get; set; }
}

}
}
15 changes: 10 additions & 5 deletions Backtrace/Backtrace.csproj
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Backtrace</PackageId>
<Title>Backtrace</Title>
<TargetFrameworks>netstandard2.0;net45;net35</TargetFrameworks>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageTags>Backtrace Error Diagnostic Tools Debug Bug Bugs StackTrace</PackageTags>
<PackageVersion>2.1.7</PackageVersion>
<tags>Backtrace Error Diagnostic Tools Debug Bug Bugs StackTrace</tags>
<PackageVersion>2.1.8</PackageVersion>
<Product>Backtrace</Product>
<PackageLicenseUrl>https://github.com/backtrace-labs/backtrace-csharp/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/backtrace-labs/backtrace-csharp</PackageProjectUrl>
<projectUrl>https://github.com/backtrace-labs/backtrace-csharp</projectUrl>
<PackageIconUrl>http://backtrace.io/images/icon.png</PackageIconUrl>
<language>en-US</language>
<iconUrl>http://backtrace.io/images/icon.png</iconUrl>
<Description>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.</Description>
<Summary>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.</Summary>
<RepositoryUrl>https://github.com/backtrace-labs/backtrace-csharp</RepositoryUrl>
<NeutralLanguage>en</NeutralLanguage>
<Version>2.1.7</Version>
<Version>2.1.8</Version>
<PackageLanguage>en-US</PackageLanguage>
<Copyright>Backtrace I/O</Copyright>
<Authors>Backtrace I/O</Authors>
<Owners>Backtrace I/O</Owners>
<Company>Backtrace I/O</Company>
<AssemblyVersion>2.1.7.0</AssemblyVersion>
<FileVersion>2.1.7.0</FileVersion>
<AssemblyVersion>2.1.8.0</AssemblyVersion>
<FileVersion>2.1.8.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion Backtrace/Services/BacktraceApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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 -
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down

0 comments on commit 8357571

Please sign in to comment.