Skip to content

Commit

Permalink
Added debug asserts in the Initialize() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
PiotrKarczmarz committed Feb 13, 2025
1 parent 311addf commit 27fd547
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Cody.VisualStudio/Services/DocumentsSyncService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.VisualStudio.TextManager.Interop;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;

Expand Down Expand Up @@ -52,6 +53,7 @@ public void Initialize()
try
{
uint activeCookie = 0;
AssertThatNoOpenedDocuments();
foreach (var frame in GetOpenDocuments())
{
if (frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocCookie, out object cookie) != VSConstants.S_OK) continue;
Expand Down Expand Up @@ -83,6 +85,12 @@ public void Initialize()
});
}

private void AssertThatNoOpenedDocuments()
{
Debug.Assert(openNotificationSend.Count == 0, $"{nameof(openNotificationSend)} is {openNotificationSend}, but it should be ZERO!");
Debug.Assert(isSubscribed.Count == 0, $"{nameof(isSubscribed)} is {isSubscribed}, but it should be ZERO!");
}

private IVsTextView GetVsTextView(IVsWindowFrame windowFrame)
{
windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocView, out var pvar);
Expand Down

0 comments on commit 27fd547

Please sign in to comment.