Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Bugsnag/SimpleJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1548,6 +1548,11 @@ protected virtual bool TrySerializeKnownTypes(object input, out object output)
output = ((Guid)input).ToString("D");
else if (input is Uri)
output = input.ToString();
else if (typeof(System.Reflection.MethodBase).IsAssignableFrom(input.GetType()))
{
// MethodBase (i.e. TargetSite in Exceptions) cannot be serialized, so ignore
output = null;
}
else
{
Enum inputEnum = input as Enum;
Expand Down
14 changes: 14 additions & 0 deletions tests/Bugsnag.Tests/SerializerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ public void NullValueTest()
Assert.NotNull(json);
}

[Fact]
public void CanSerializeException()
{
try
{
throw new System.Exception("Serialize me");
}
catch (System.Exception exception)
{
var json = Serializer.SerializeObject(exception);
Assert.NotNull(json);
}
}

private class Circular
{
public string Name { get; set; }
Expand Down