CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.
This problem was reported for my add-in, and since I used code from this repo (linked by Microsoft's documentation) likely it is affected too (I have not verified it).
The bug is the following:
You have a file with code and designer (such as Form1.vb and Form1.Designer.vb)
That method contains this call to get a window frame for a file in the desired view:
IVsWindowFrame windowFrame;
if (VsShellUtilities.IsDocumentOpen(
CodeMaidPackage.Instance,
filePath,
Guid.Empty,
out var _,
out var _,
out windowFrame))
That call uses the filePath for the code file (such as "(...)\Form1.vb") but for the logical view that you want to get it uses Guid.Empty (that is, any view).
It happens that if the designer window is opened, that call returns the window frame of the designer view for the file "(...)\Form1.Designer.vb". Since it is a designer view, the text buffer is returned null.
The fix would be to use the Guid for the Text logical view (Microsoft.VisualStudio.Shell.Interop.LogicalViewID.TextView) instead of Guid.Empty.
This problem was reported for my add-in, and since I used code from this repo (linked by Microsoft's documentation) likely it is affected too (I have not verified it).
The bug is the following:
Then the TextBuffer is returned null in the TryGetTextBufferAt method of the file TextDocumentHelper.cs file (https://github.com/codecadwallader/codemaid/blob/dev/CodeMaidShared/Helpers/TextDocumentHelper.cs).
That method contains this call to get a window frame for a file in the desired view:
That call uses the filePath for the code file (such as "(...)\Form1.vb") but for the logical view that you want to get it uses Guid.Empty (that is, any view).
It happens that if the designer window is opened, that call returns the window frame of the designer view for the file "(...)\Form1.Designer.vb". Since it is a designer view, the text buffer is returned null.
The fix would be to use the Guid for the Text logical view (Microsoft.VisualStudio.Shell.Interop.LogicalViewID.TextView) instead of Guid.Empty.