Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 44938c4

Browse files
committed
Guard against nulls and things
1 parent 8a889c6 commit 44938c4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/GitHub.Exports/Helpers/SettingsStore.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.IO;
22
using Microsoft.VisualStudio.Settings;
3+
using GitHub.Extensions;
34

45
namespace GitHub.Helpers
56
{
@@ -9,6 +10,9 @@ internal class SettingsStore
910
readonly string root;
1011
public SettingsStore(WritableSettingsStore store, string root)
1112
{
13+
Guard.ArgumentNotNull(store, nameof(store));
14+
Guard.ArgumentNotNull(root, nameof(root));
15+
Guard.ArgumentNotEmptyString(root, nameof(root));
1216
this.store = store;
1317
this.root = root;
1418
}
@@ -30,6 +34,9 @@ public object Read(string property, object defaultValue)
3034
/// <returns></returns>
3135
public object Read(string subpath, string property, object defaultValue)
3236
{
37+
Guard.ArgumentNotNull(property, nameof(property));
38+
Guard.ArgumentNotEmptyString(property, nameof(property));
39+
3340
var collection = subpath != null ? Path.Combine(root, subpath) : root;
3441
store.CreateCollection(collection);
3542

@@ -53,6 +60,9 @@ public void Write(string property, object value)
5360

5461
public void Write(string subpath, string property, object value)
5562
{
63+
Guard.ArgumentNotNull(property, nameof(property));
64+
Guard.ArgumentNotEmptyString(property, nameof(property));
65+
5666
var collection = subpath != null ? Path.Combine(root, subpath) : root;
5767
store.CreateCollection(collection);
5868

0 commit comments

Comments
 (0)