Skip to content

Commit 3b6047c

Browse files
authored
Closes #294: [BREAKING] Preserving custom object property names sent to SetProperty and AddObject (#304)
* Use decimal float parse handling so accuracy is never lost * Added missing test cases for serialization * Added test cases for all existing models * Use JSON.NET SnakeCase Naming Strategy and respect all property names for unknown types * Fixed a deserialization bug where the DataDictionaryConverter was applying indented formatting and not respecting serializer settings * Fixed build * Allow empty collections to be serialized * Reworked Tests
1 parent a683cf6 commit 3b6047c

23 files changed

+473
-121
lines changed

src/Exceptionless/Extensions/StringExtensions.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,6 @@
55

66
namespace Exceptionless.Extensions {
77
public static class StringExtensions {
8-
internal static string ToLowerUnderscoredWords(this string value) {
9-
var builder = new StringBuilder(value.Length + 10);
10-
for (int index = 0; index < value.Length; index++) {
11-
char c = value[index];
12-
if (Char.IsUpper(c)) {
13-
if (index > 0 && value[index - 1] != '_')
14-
builder.Append('_');
15-
16-
builder.Append(Char.ToLower(c));
17-
} else {
18-
builder.Append(c);
19-
}
20-
}
21-
22-
return builder.ToString();
23-
}
24-
258
public static bool AnyWildcardMatches(this string value, IEnumerable<string> patternsToMatch, bool ignoreCase = true) {
269
if (patternsToMatch == null || value == null)
2710
return false;

src/Exceptionless/Models/Client/ClientConfiguration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
namespace Exceptionless.Models {
2+
[Json.JsonObject(NamingStrategyType = typeof(Json.Serialization.SnakeCaseNamingStrategy))]
23
public class ClientConfiguration {
34
public ClientConfiguration() {
45
Settings = new SettingsDictionary();

src/Exceptionless/Models/Client/Data/EnvironmentInfo.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
namespace Exceptionless.Models.Data {
2+
[Json.JsonObject(NamingStrategyType = typeof(Json.Serialization.SnakeCaseNamingStrategy))]
23
public class EnvironmentInfo : IData {
34
public EnvironmentInfo() {
45
Data = new DataDictionary();
@@ -66,11 +67,13 @@ public EnvironmentInfo() {
6667
/// <summary>
6768
/// The OS name that the error occurred on.
6869
/// </summary>
70+
[Json.JsonProperty("o_s_name")]
6971
public string OSName { get; set; }
7072

7173
/// <summary>
7274
/// The OS version that the error occurred on.
7375
/// </summary>
76+
[Json.JsonProperty("o_s_version")]
7477
public string OSVersion { get; set; }
7578

7679
/// <summary>

src/Exceptionless/Models/Client/Data/Error.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
namespace Exceptionless.Models.Data {
2+
[Json.JsonObject(NamingStrategyType = typeof(Json.Serialization.SnakeCaseNamingStrategy))]
23
public class Error : InnerError {
34
public Error() {
45
Modules = new ModuleCollection();

src/Exceptionless/Models/Client/Data/InnerError.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
namespace Exceptionless.Models.Data {
2+
[Json.JsonObject(NamingStrategyType = typeof(Json.Serialization.SnakeCaseNamingStrategy))]
23
public class InnerError : IData {
34
public InnerError() {
45
Data = new DataDictionary();

src/Exceptionless/Models/Client/Data/ManualStackingInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Exceptionless.Extensions;
44

55
namespace Exceptionless.Models.Data {
6+
[Json.JsonObject(NamingStrategyType = typeof(Json.Serialization.SnakeCaseNamingStrategy))]
67
public class ManualStackingInfo {
78
public ManualStackingInfo() {
89
SignatureData = new Dictionary<string, string>();

src/Exceptionless/Models/Client/Data/Method.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33

44
namespace Exceptionless.Models.Data {
5+
[Json.JsonObject(NamingStrategyType = typeof(Json.Serialization.SnakeCaseNamingStrategy))]
56
public class Method : IData {
67
public Method() {
78
Data = new DataDictionary();

src/Exceptionless/Models/Client/Data/Module.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Text;
33

44
namespace Exceptionless.Models.Data {
5+
[Json.JsonObject(NamingStrategyType = typeof(Json.Serialization.SnakeCaseNamingStrategy))]
56
public class Module : IData {
67
public Module() {
78
Data = new DataDictionary();

src/Exceptionless/Models/Client/Data/Parameter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
namespace Exceptionless.Models.Data {
2+
[Json.JsonObject(NamingStrategyType = typeof(Json.Serialization.SnakeCaseNamingStrategy))]
23
public class Parameter : IData {
34
public Parameter() {
45
Data = new DataDictionary();

src/Exceptionless/Models/Client/Data/RequestInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33

44
namespace Exceptionless.Models.Data {
5+
[Json.JsonObject(NamingStrategyType = typeof(Json.Serialization.SnakeCaseNamingStrategy))]
56
public class RequestInfo : IData {
67
public RequestInfo() {
78
Data = new DataDictionary();

0 commit comments

Comments
 (0)