Skip to content

Commit 2996f3d

Browse files
committed
Fixed a bug where multiword exclusions wouldn't be applied
1 parent bf376d1 commit 2996f3d

File tree

8 files changed

+37
-13
lines changed

8 files changed

+37
-13
lines changed

src/Exceptionless.Tests/Serializer/SerializerTests.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,26 @@ public void CanExcludeNestedProperties() {
6666
Assert.Equal(@"{""message"":""Testing"",""nested"":{""message"":""Nested""}}", json);
6767
}
6868

69+
[Fact]
70+
public void CanExcludeMultiwordProperties() {
71+
var user = new User {
72+
FirstName = "John",
73+
LastName = "Doe",
74+
PasswordHash = "1234567890",
75+
Billing = new BillingInfo {
76+
ExpirationMonth = 10,
77+
ExpirationYear = 2020,
78+
CardNumberRedacted = "1xxxxxxxx89",
79+
EncryptedCardNumber = "9876543210"
80+
}
81+
};
82+
83+
var exclusions = new[] { nameof(user.PasswordHash), nameof(user.Billing.CardNumberRedacted), nameof(user.Billing.EncryptedCardNumber) };
84+
IJsonSerializer serializer = GetSerializer();
85+
string json = serializer.Serialize(user, exclusions, maxDepth: 2);
86+
Assert.Equal(@"{""first_name"":""John"",""last_name"":""Doe"",""billing"":{""expiration_month"":10,""expiration_year"":2020}}", json);
87+
}
88+
6989
[Fact]
7090
public void WillIgnoreDefaultValues() {
7191
var data = new SampleModel {
@@ -183,4 +203,18 @@ public class SampleModel {
183203
public ICollection<string> Collection { get; set; }
184204
public SampleModel Nested { get; set; }
185205
}
206+
207+
public class User {
208+
public string FirstName { get; set; }
209+
public string LastName { get; set; }
210+
public string PasswordHash { get; set; }
211+
public BillingInfo Billing { get; set; }
212+
}
213+
214+
public class BillingInfo {
215+
public string CardNumberRedacted { get; set; }
216+
public string EncryptedCardNumber { get; set; }
217+
public int ExpirationMonth { get; set; }
218+
public int ExpirationYear { get; set; }
219+
}
186220
}

src/Exceptionless.Tests/project.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"target": "project"
1414
},
1515
"Moq": "4.6.25-alpha",
16-
"NLog": "4.4.0-beta12",
1716
"dotnet-test-xunit": "2.2.0-preview2-build1029",
1817
"xunit": "2.2.0-beta2-build3300",
1918
"xunit.extensibility.core": "2.2.0-beta2-build3300",

src/Exceptionless/Serializer/DefaultJsonSerializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public virtual object Deserialize(string json, Type type) {
6060

6161
private bool ShouldSerialize(JsonTextWriterWithDepth jw, JsonProperty property, object obj, int maxDepth, IEnumerable<string> excludedPropertyNames) {
6262
try {
63-
if (excludedPropertyNames != null && property.PropertyName.AnyWildcardMatches(excludedPropertyNames, true))
63+
if (excludedPropertyNames != null && (property.UnderlyingName.AnyWildcardMatches(excludedPropertyNames, true) || property.PropertyName.AnyWildcardMatches(excludedPropertyNames, true)))
6464
return false;
6565

6666
bool isPrimitiveType = DefaultContractResolver.IsJsonPrimitiveType(property.PropertyType);

src/Exceptionless/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@
271271
"System.Threading": "4.0.11",
272272
"System.Threading.AccessControl": "4.0.0",
273273
"System.Threading.Tasks": "4.0.11",
274-
"System.Threading.Timer": "4.0.1",
275274
"System.Threading.Thread": "4.0.0",
275+
"System.Threading.Timer": "4.0.1",
276276
"System.Xml.ReaderWriter": "4.0.11",
277277
"System.Xml.XDocument": "4.0.11",
278278
"System.Xml.XmlDocument": "4.0.1",

src/Platforms/Exceptionless.NLog/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"define": [ "NET45" ]
4949
},
5050
"dependencies": {
51-
"NLog": "4.3.5"
51+
"NLog": "4.3.6"
5252
}
5353
}
5454
}

src/Samples/Exceptionless.SampleMvc/Exceptionless.SampleMvc.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@
5555
<HintPath>..\..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
5656
<Private>True</Private>
5757
</Reference>
58-
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
59-
<HintPath>..\..\..\packages\NLog.4.4.0-beta12\lib\net45\NLog.dll</HintPath>
60-
<Private>True</Private>
61-
</Reference>
6258
<Reference Include="System" />
6359
<Reference Include="System.Data" />
6460
<Reference Include="System.Data.DataSetExtensions" />

src/Samples/Exceptionless.SampleMvc/Global.asax.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
using System;
2-
using System.Diagnostics;
32
using System.Web;
43
using System.Web.Http;
54
using System.Web.Mvc;
65
using System.Web.Routing;
76
using Exceptionless.SampleMvc.App_Start;
8-
using NLog;
97

108
namespace Exceptionless.SampleMvc {
119
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
1210
// visit http://go.microsoft.com/?LinkId=9394801
1311

1412
public class MvcApplication : HttpApplication {
1513
protected void Application_Start() {
16-
Trace.Listeners.Add(new NLogTraceListener());
17-
//ExceptionlessClient.Default.Log = new NLogExceptionlessLog();
1814
ExceptionlessClient.Default.Configuration.DefaultData["FirstName"] = "Blake";
1915
ExceptionlessClient.Default.Configuration.DefaultData["IgnoredProperty"] = "Some random data";
2016

src/Samples/Exceptionless.SampleMvc/packages.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@
1414
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net452" />
1515
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net452" />
1616
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
17-
<package id="NLog" version="4.4.0-beta12" targetFramework="net45" />
1817
</packages>

0 commit comments

Comments
 (0)