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

Commit 64fdc91

Browse files
committed
Assert and use null propagation
1 parent 078366b commit 64fdc91

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/GitHub.Exports/Services/VSServices.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using Microsoft.VisualStudio.Shell.Interop;
1414
using Microsoft.VisualStudio.TeamFoundation.Git.Extensibility;
1515
using Microsoft.Win32;
16+
using System.Diagnostics;
1617

1718
namespace GitHub.Services
1819
{
@@ -150,15 +151,15 @@ public string SetDefaultProjectPath(string path)
150151
var old = String.Empty;
151152
try
152153
{
153-
var newProjectKey = Registry.CurrentUser.OpenSubKey(NewProjectDialogKeyPath, true);
154-
if (newProjectKey == null)
155-
newProjectKey = Registry.CurrentUser.CreateSubKey(NewProjectDialogKeyPath);
154+
var newProjectKey = Registry.CurrentUser.OpenSubKey(NewProjectDialogKeyPath, true) ??
155+
Registry.CurrentUser.CreateSubKey(NewProjectDialogKeyPath);
156+
Debug.Assert(newProjectKey != null, string.Format(CultureInfo.CurrentCulture, "Could not open or create registry key '{0}'", NewProjectDialogKeyPath));
156157

157158
using (newProjectKey)
158159
{
159-
var mruKey = newProjectKey.OpenSubKey(MRUKeyPath, true);
160-
if (mruKey == null)
161-
mruKey = Registry.CurrentUser.CreateSubKey(MRUKeyPath);
160+
var mruKey = newProjectKey.OpenSubKey(MRUKeyPath, true) ??
161+
Registry.CurrentUser.CreateSubKey(MRUKeyPath);
162+
Debug.Assert(mruKey != null, string.Format(CultureInfo.CurrentCulture, "Could not open or create registry key '{0}'", MRUKeyPath));
162163

163164
using (mruKey)
164165
{

0 commit comments

Comments
 (0)