Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using Microsoft.VisualStudio.Utilities;
using Microsoft.VisualStudio.PlatformUI;
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.Editor.Internal;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using System.Windows.Media;
Expand All @@ -43,7 +44,11 @@
IVsTextLinesEvents,
IOleCommandTarget,
IVsCodeWindow, // support setting breakpoints
IVsCodeWindowEx
IVsCodeWindowEx,
IVsFindTarget, // find in the embedded editor
IVsFindTarget2,
IVsFindTarget3, // enables the quick find bar instead of only the find dialog
IVsFindTarget4
{
IVsTextLines textBuffer;
CodeEditorHost editor;
Expand Down Expand Up @@ -130,17 +135,17 @@
host.ProjectChanged += PreviewHost_ProjectChanged;
var designHost = new RemoteDesignPanel(async request =>
{
var result = await host.RenderAsync(request, await ProjectAssemblyPaths.GetAsync(fileName));

Check warning on line 138 in src/Eto.DevExtension.VisualStudio.Windows/Editor/EtoPreviewPane.cs

View workflow job for this annotation

GitHub Actions / build-windows (2022)

Accessing "Eto.DevExtension.VisualStudio.Intellisense.ProjectAssemblyPaths.GetAsync" should only be done on the main thread. Call Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread() first. (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD010.md)

Check warning on line 138 in src/Eto.DevExtension.VisualStudio.Windows/Editor/EtoPreviewPane.cs

View workflow job for this annotation

GitHub Actions / build-windows (2022)

Accessing "Eto.DevExtension.VisualStudio.Windows.Editor.PreviewHostClient.RenderAsync" should only be done on the main thread. Call Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread() first. (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD010.md)
if (result?.Platform != null && result.Platform != drawnPlatform)
{
drawnPlatform = result.Platform;
LoadPlatforms();

Check warning on line 142 in src/Eto.DevExtension.VisualStudio.Windows/Editor/EtoPreviewPane.cs

View workflow job for this annotation

GitHub Actions / build-windows (2022)

Accessing "Eto.DevExtension.VisualStudio.Windows.Editor.EtoPreviewPane.LoadPlatforms" should only be done on the main thread. Call Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread() first. (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD010.md)
}
if (result?.Themes != null && (result.Theme != drawnTheme || drawnThemes == null || !result.Themes.SequenceEqual(drawnThemes)))
{
drawnThemes = result.Themes;
drawnTheme = result.Theme;
LoadThemes();

Check warning on line 148 in src/Eto.DevExtension.VisualStudio.Windows/Editor/EtoPreviewPane.cs

View workflow job for this annotation

GitHub Actions / build-windows (2022)

Accessing "Eto.DevExtension.VisualStudio.Windows.Editor.EtoPreviewPane.LoadThemes" should only be done on the main thread. Call Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread() first. (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD010.md)
}
return result;
});
Expand All @@ -151,8 +156,8 @@
WpfTextView?.VisualElement?.Focus();
};
preview = previewSplitter.Preview;
PreviewLayoutSettings.Load(previewSplitter);

Check warning on line 159 in src/Eto.DevExtension.VisualStudio.Windows/Editor/EtoPreviewPane.cs

View workflow job for this annotation

GitHub Actions / build-windows (2022)

Accessing "Eto.DevExtension.VisualStudio.Windows.Editor.PreviewLayoutSettings.Load" should only be done on the main thread. Call Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread() first. (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD010.md)
previewSplitter.LayoutChanged += (sender, e) => PreviewLayoutSettings.Save(previewSplitter);

Check warning on line 160 in src/Eto.DevExtension.VisualStudio.Windows/Editor/EtoPreviewPane.cs

View workflow job for this annotation

GitHub Actions / build-windows (2022)

Accessing "Eto.DevExtension.VisualStudio.Windows.Editor.PreviewLayoutSettings.Save" should only be done on the main thread. Call Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread() first. (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD010.md)

platformDropDown = new DropDown { ToolTip = "Platform to draw the preview with" };
platformDropDown.SelectedKeyChanged += PlatformDropDown_SelectedKeyChanged;
Expand Down Expand Up @@ -271,7 +276,7 @@

// the document may not be registered yet while the frame is being created
if (!LockDocument())
ThreadHelper.JoinableTaskFactory.StartOnIdle(() => LockDocument());

Check warning on line 279 in src/Eto.DevExtension.VisualStudio.Windows/Editor/EtoPreviewPane.cs

View workflow job for this annotation

GitHub Actions / build-windows (2022)

Observe the awaitable result of this method call by awaiting it, assigning to a variable, or passing it to another method (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD110.md)

preview.Update();
}
Expand Down Expand Up @@ -541,10 +546,53 @@
public int GetViewClassID(out Guid pclsidView) => editor.codeWindow.GetViewClassID(out pclsidView);
public int SetBaseEditorCaption(string[] pszBaseEditorCaption) => editor.codeWindow.SetBaseEditorCaption(pszBaseEditorCaption);
public int GetEditorCaption(READONLYSTATUS dwReadOnly, out string pbstrEditorCaption) => editor.codeWindow.GetEditorCaption(dwReadOnly, out pbstrEditorCaption);
public int Close() => editor.Close();

Check warning on line 549 in src/Eto.DevExtension.VisualStudio.Windows/Editor/EtoPreviewPane.cs

View workflow job for this annotation

GitHub Actions / build-windows (2022)

Accessing "Eto.DevExtension.VisualStudio.Windows.Editor.CodeEditorHost.Close" should only be done on the main thread. Call Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread() first. (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD010.md)
public int GetLastActiveView(out IVsTextView ppView) => editor.codeWindow.GetLastActiveView(out ppView);

int IVsCodeWindowEx.Initialize(uint grfCodeWindowBehaviorFlags, VSUSERCONTEXTATTRIBUTEUSAGE usageAuxUserContext, string szNameAuxUserContext, string szValueAuxUserContext, uint InitViewFlags, INITVIEW[] pInitView) => ((IVsCodeWindowEx)editor.codeWindow).Initialize(grfCodeWindowBehaviorFlags, usageAuxUserContext, szNameAuxUserContext, szValueAuxUserContext, InitViewFlags, pInitView);
int IVsCodeWindowEx.IsReadOnly() => ((IVsCodeWindowEx)editor.codeWindow).IsReadOnly();

IVsFindTarget FindTarget => editor.viewAdapter as IVsFindTarget;

int IVsFindTarget.GetCapabilities(bool[] pfImage, uint[] pgrfOptions) => FindTarget?.GetCapabilities(pfImage, pgrfOptions) ?? VSConstants.E_FAIL;
int IVsFindTarget.GetProperty(uint propid, out object pvar)
{
pvar = null;
return FindTarget?.GetProperty(propid, out pvar) ?? VSConstants.E_FAIL;
}
int IVsFindTarget.GetSearchImage(uint grfOptions, IVsTextSpanSet[] ppSpans, out IVsTextImage ppTextImage)
{
ppTextImage = null;
return FindTarget?.GetSearchImage(grfOptions, ppSpans, out ppTextImage) ?? VSConstants.E_FAIL;
}
int IVsFindTarget.Find(string pszSearch, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out uint pResult)
{
pResult = 0;
return FindTarget?.Find(pszSearch, grfOptions, fResetStartPoint, pHelper, out pResult) ?? VSConstants.E_FAIL;
}
int IVsFindTarget.Replace(string pszSearch, string pszReplace, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out int pfReplaced)
{
pfReplaced = 0;
return FindTarget?.Replace(pszSearch, pszReplace, grfOptions, fResetStartPoint, pHelper, out pfReplaced) ?? VSConstants.E_FAIL;
}
int IVsFindTarget.GetMatchRect(RECT[] prc) => FindTarget?.GetMatchRect(prc) ?? VSConstants.E_FAIL;
int IVsFindTarget.NavigateTo(TextSpan[] pts) => FindTarget?.NavigateTo(pts) ?? VSConstants.E_FAIL;
int IVsFindTarget.GetCurrentSpan(TextSpan[] pts) => FindTarget?.GetCurrentSpan(pts) ?? VSConstants.E_FAIL;
int IVsFindTarget.SetFindState(object pUnk) => FindTarget?.SetFindState(pUnk) ?? VSConstants.E_FAIL;
int IVsFindTarget.GetFindState(out object ppunk)
{
ppunk = null;
return FindTarget?.GetFindState(out ppunk) ?? VSConstants.E_FAIL;
}
int IVsFindTarget.NotifyFindTarget(uint notification) => FindTarget?.NotifyFindTarget(notification) ?? VSConstants.E_FAIL;
int IVsFindTarget.MarkSpan(TextSpan[] pts) => FindTarget?.MarkSpan(pts) ?? VSConstants.E_FAIL;

int IVsFindTarget2.NavigateTo2(IVsTextSpanSet pSpans, TextSelMode iSelMode) => (editor.viewAdapter as IVsFindTarget2)?.NavigateTo2(pSpans, iSelMode) ?? VSConstants.E_FAIL;

int IVsFindTarget3.IsNewUISupported => (editor.viewAdapter as IVsFindTarget3)?.IsNewUISupported ?? 0;
int IVsFindTarget3.NotifyShowingNewUI() => (editor.viewAdapter as IVsFindTarget3)?.NotifyShowingNewUI() ?? VSConstants.E_FAIL;

int IVsFindTarget4.IsAutonomous => (editor.viewAdapter as IVsFindTarget4)?.IsAutonomous ?? 0;
int IVsFindTarget4.IsIncrementalSearchSupported => (editor.viewAdapter as IVsFindTarget4)?.IsIncrementalSearchSupported ?? 0;
}
}
23 changes: 23 additions & 0 deletions src/Eto.DevExtension.VisualStudio.Windows/Editor/IVsFindTarget3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Runtime.InteropServices;

// Not in the public SDK; VS asks a document for these to decide between the quick find bar and the find dialog.
// Namespace, names and TypeIdentifier must match VS's own declarations so casts to and from the editor's view succeed.
namespace Microsoft.VisualStudio.Editor.Internal
{
[ComImport, TypeIdentifier, Guid("A2F0D62B-D0DD-4C59-AAB8-79CD20785451"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IVsFindTarget3
{
int IsNewUISupported { [PreserveSig] get; }

[PreserveSig]
int NotifyShowingNewUI();
}

[ComImport, TypeIdentifier, Guid("47AB8522-6BB1-4C85-BA88-E4B4513F8BE1"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IVsFindTarget4
{
int IsAutonomous { [PreserveSig] get; }

int IsIncrementalSearchSupported { [PreserveSig] get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<Compile Include="Components.cs" />
<Compile Include="Editor\CodeEditorHost.cs" />
<Compile Include="Editor\EditorFactory.cs" />
<Compile Include="Editor\IVsFindTarget3.cs" />
<Compile Include="Editor\PreviewHostClient.cs" />
<Compile Include="Editor\PreviewLayoutSettings.cs" />
<Compile Include="Editor\PreviewPlatforms.cs" />
Expand Down
Loading