Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added debug asserts in the Initialize() method. #234

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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