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

Commit dda24be

Browse files
committed
Move IVSGitExt null check to top
Don't initialize this service if IVSGitExt isn't available.
1 parent 38c65da commit dda24be

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/GitHub.TeamFoundation.14/Base/TeamExplorerServiceHolder.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,20 @@ public class TeamExplorerServiceHolder : ITeamExplorerServiceHolder
4242
/// <param name="joinableTaskFactory">Used for switching to the Main thread.</param>
4343
public TeamExplorerServiceHolder(IVSGitExt gitService, JoinableTaskContext joinableTaskContext)
4444
{
45+
if (gitService == null)
46+
{
47+
// This might be null in Blend or SafeMode
48+
return;
49+
}
50+
4551
JoinableTaskCollection = joinableTaskContext.CreateCollection();
4652
JoinableTaskCollection.DisplayName = nameof(TeamExplorerServiceHolder);
4753
JoinableTaskFactory = joinableTaskContext.CreateFactory(JoinableTaskCollection);
4854

4955
this.gitService = gitService;
5056

5157
UpdateActiveRepo();
52-
if (gitService != null)
53-
{
54-
gitService.ActiveRepositoriesChanged += UpdateActiveRepo;
55-
}
58+
gitService.ActiveRepositoriesChanged += UpdateActiveRepo;
5659
}
5760

5861
// set by the sections when they get initialized
@@ -151,8 +154,7 @@ void NotifyActiveRepo()
151154

152155
void UpdateActiveRepo()
153156
{
154-
// NOTE: gitService might be null in Blend or Safe Mode
155-
var repo = gitService?.ActiveRepositories.FirstOrDefault();
157+
var repo = gitService.ActiveRepositories.FirstOrDefault();
156158

157159
if (!Equals(repo, ActiveRepo))
158160
{

0 commit comments

Comments
 (0)