Skip to content

Commit 46c001a

Browse files
Updated to latest toolkit versions
1 parent 29ba480 commit 46c001a

File tree

6 files changed

+17
-11
lines changed

6 files changed

+17
-11
lines changed

InsertGuid/Commands/MyCommand.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Community.VisualStudio.Toolkit;
33
using EnvDTE;
44
using Microsoft.VisualStudio.Shell;
5+
using Microsoft.VisualStudio.Text.Editor;
56
using Task = System.Threading.Tasks.Task;
67

78
namespace InsertGuid
@@ -11,10 +12,10 @@ internal sealed class MyCommand : BaseCommand<MyCommand>
1112
{
1213
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
1314
{
14-
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
15-
TextDocument doc = await VS.Editor.GetActiveTextDocumentAsync();
15+
IWpfTextView view = await VS.Documents.GetCurrentTextViewAsync();
16+
var position = view.Selection.Start.Position.Position;
1617

17-
doc?.Selection.Insert(Guid.NewGuid().ToString());
18+
view.TextBuffer.Insert(position, Guid.NewGuid().ToString());
1819
}
1920
}
2021
}

InsertGuid/InsertGuid.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<Reference Include="System.Design" />
8484
</ItemGroup>
8585
<ItemGroup>
86-
<PackageReference Include="Community.VisualStudio.Toolkit" Version="16.0.75.81" ExcludeAssets="runtime">
86+
<PackageReference Include="Community.VisualStudio.Toolkit" Version="16.0.75.152-pre" ExcludeAssets="runtime">
8787
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
8888
</PackageReference>
8989
<PackageReference Include="Community.VisualStudio.VSCT" Version="16.0.29.6" PrivateAssets="all" />

Options/Options.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@
8484
<Reference Include="System.Design" />
8585
</ItemGroup>
8686
<ItemGroup>
87-
<PackageReference Include="Community.VisualStudio.Toolkit" Version="16.0.75.81" ExcludeAssets="Runtime" />
87+
<PackageReference Include="Community.VisualStudio.Toolkit" Version="16.0.75.152-pre" ExcludeAssets="Runtime">
88+
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
89+
</PackageReference>
8890
<PackageReference Include="Community.VisualStudio.VSCT" Version="16.0.29.6" PrivateAssets="all" />
8991
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="16.10.11" />
9092
</ItemGroup>

ToolWindow/ToolWindow.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@
9696
<Reference Include="WindowsBase" />
9797
</ItemGroup>
9898
<ItemGroup>
99-
<PackageReference Include="Community.VisualStudio.Toolkit" Version="16.0.75.81" ExcludeAssets="Runtime" />
99+
<PackageReference Include="Community.VisualStudio.Toolkit" Version="16.0.75.152-pre" ExcludeAssets="Runtime">
100+
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
101+
</PackageReference>
100102
<PackageReference Include="Community.VisualStudio.VSCT" Version="16.0.29.6" PrivateAssets="all" />
101103
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="16.10.11" />
102104
</ItemGroup>

ToolWindow/ToolWindows/MyToolWindow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public class MyToolWindow : BaseToolWindow<MyToolWindow>
1616

1717
public override async Task<FrameworkElement> CreateAsync(int toolWindowId, CancellationToken cancellationToken)
1818
{
19-
EnvDTE80.DTE2 dte = await VS.GetDTEAsync();
20-
return new MyToolWindowControl(dte);
19+
Version vsVersion = await VS.Shell.GetVsVersionAsync();
20+
return new MyToolWindowControl(vsVersion);
2121
}
2222

2323
[Guid("03030460-e1a2-49ab-a4c5-b7b9cfc2a4df")]
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
using Community.VisualStudio.Toolkit;
2+
using System;
23
using System.Windows;
34
using System.Windows.Controls;
45

56
namespace ToolWindow
67
{
78
public partial class MyToolWindowControl : UserControl
89
{
9-
public MyToolWindowControl(EnvDTE80.DTE2 dte)
10+
public MyToolWindowControl(Version vsVersion)
1011
{
1112
InitializeComponent();
1213

13-
lblHeadline.Content = $"Visual Studio v{dte.Version}";
14+
lblHeadline.Content = $"Visual Studio v{vsVersion}";
1415
}
1516

1617
private void button1_Click(object sender, RoutedEventArgs e)
1718
{
18-
VS.Notifications.ShowMessage("ToolWindow", "Button clicked");
19+
VS.MessageBox.Show("ToolWindow", "Button clicked");
1920
}
2021
}
2122
}

0 commit comments

Comments
 (0)