Skip to content

Commit b9d4685

Browse files
committed
Throw ANE when SetProperty is called null property name
1 parent b9478d7 commit b9d4685

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Exceptionless/Extensions/DataDictionaryExtensions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using Exceptionless.Dependency;
@@ -40,6 +40,9 @@ public static T GetValue<T>(this DataDictionary items, string key, IJsonSerializ
4040
/// ExceptionlessClient.Default.
4141
/// </param>
4242
public static void SetProperty(this IData target, string name, object value, int? maxDepth = null, IEnumerable<string> excludedPropertyNames = null, bool ignoreSerializationErrors = false, ExceptionlessClient client = null) {
43+
if (String.IsNullOrEmpty(name))
44+
throw new ArgumentNullException(nameof(name));
45+
4346
AddObject(target, value, name, maxDepth, excludedPropertyNames, ignoreSerializationErrors, client);
4447
}
4548

test/Exceptionless.Tests/Configuration/DataExclusionTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
namespace Exceptionless.Tests.Configuration {
88
public class DataExclusionTests {
99
[Fact]
10-
public void WillIgnoreNullKey() {
10+
public void WillHandleNullKey() {
1111
var ev = new Event();
12-
ev.SetProperty(null, "test");
13-
Assert.Empty(ev.Data);
12+
Assert.Throws<ArgumentNullException>(() => ev.SetProperty(null, "test"));
1413
}
1514

1615
[Fact]

0 commit comments

Comments
 (0)