Updated VS packages to use AsyncPackage.

This commit is contained in:
José Pedro 2018-06-13 23:19:59 +01:00
parent 123b14917f
commit 3fbd82d25c
No known key found for this signature in database
GPG key ID: B8247B9301707B83
6 changed files with 41 additions and 25 deletions

View file

@ -26,8 +26,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Debugger.Interop.15.0" Version="15.4.27004" />
<PackageReference Include="Microsoft.VisualStudio.Shell.15.0" Version="15.6.27413" />
<PackageReference Include="Microsoft.VisualStudio.Debugger.Interop.15.0" Version="15.7.27703" />
<PackageReference Include="Microsoft.VisualStudio.Shell.15.0" Version="15.7.27703" />
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop.11.0" Version="11.0.61031" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="1.1.10" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="4.4.1" />

View file

@ -1,7 +1,9 @@
using System;
using System.Runtime.InteropServices;
using System.Threading;
using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Shell;
using Task = System.Threading.Tasks.Task;
using Cosmos.VS.DebugEngine.Commands;
@ -32,24 +34,30 @@ using Cosmos.VS.DebugEngine.Commands;
namespace Cosmos.VS.DebugEngine
{
[Guid(Guids.guidPackageString)]
[PackageRegistration(UseManagedResourcesOnly = true)]
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
[ProvideMenuResource("Menus.ctmenu", 1)]
internal sealed class CosmosDebugEnginePackage : Package, IOleCommandTarget
internal sealed class CosmosDebugEnginePackage : AsyncPackage, IOleCommandTarget
{
private IOleCommandTarget packageCommandTarget;
private DebugCommandHandler packageCommandHandler;
protected override void Initialize()
protected override async Task InitializeAsync(
CancellationToken cancellationToken,
IProgress<ServiceProgressData> progress)
{
base.Initialize();
await base.InitializeAsync(cancellationToken, progress);
packageCommandTarget = GetService(typeof(IOleCommandTarget)) as IOleCommandTarget;
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
packageCommandTarget = await GetServiceAsync(typeof(IOleCommandTarget)).ConfigureAwait(true) as IOleCommandTarget;
packageCommandHandler = new DebugCommandHandler(this);
}
int IOleCommandTarget.Exec(ref Guid cmdGroup, uint nCmdID, uint nCmdExecOpt, IntPtr pvaIn, IntPtr pvaOut)
{
ThreadHelper.ThrowIfNotOnUIThread();
if (cmdGroup == Guids.DebugEngineCmdSetGuid)
{
return packageCommandHandler.Execute(nCmdID, nCmdExecOpt, pvaIn, pvaOut);
@ -60,6 +68,8 @@ namespace Cosmos.VS.DebugEngine
int IOleCommandTarget.QueryStatus(ref Guid cmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
{
ThreadHelper.ThrowIfNotOnUIThread();
if (cmdGroup == Guids.DebugEngineCmdSetGuid)
{
return packageCommandHandler.Query(cCmds, prgCmds, pCmdText);

View file

@ -62,12 +62,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.ImageCatalog" Version="15.6.27413" />
<PackageReference Include="Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime" Version="14.3.25408" />
<PackageReference Include="Microsoft.VisualStudio.ProjectSystem.Analyzers" Version="15.3.224" />
<PackageReference Include="Microsoft.VisualStudio.ProjectSystem.SDK" Version="15.3.224" />
<PackageReference Include="Microsoft.VisualStudio.Shell.15.0" Version="15.6.27413" />
<PackageReference Include="Microsoft.VisualStudio.Shell.Framework" Version="15.6.27413" />
<PackageReference Include="Microsoft.VisualStudio.Shell.15.0" Version="15.7.27703" />
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop.11.0" Version="11.0.61031" />
<PackageReference Include="Microsoft.Win32.Registry" Version="4.4.0" />
</ItemGroup>

View file

@ -1,18 +1,20 @@
using System;
using System.Runtime.InteropServices;
using System.Threading;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Task = System.Threading.Tasks.Task;
using Cosmos.VS.ProjectSystem.VS.PropertyPages;
namespace Cosmos.VS.ProjectSystem
{
[Guid(PackageGuid)]
[PackageRegistration(UseManagedResourcesOnly = true)]
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[ProvideObject(typeof(OldCosmosPropertyPage))]
[ProvideObject(typeof(CosmosPropertyPage))]
[ProvideProjectFactory(typeof(MigrateCosmosProjectFactory), null, "Cosmos Project Files (*.Cosmos);*.Cosmos", "Cosmos", "Cosmos", null)]
internal class CosmosProjectSystemPackage : Package
internal class CosmosProjectSystemPackage : AsyncPackage
{
/// <summary>
/// The GUID for this package.
@ -21,9 +23,13 @@ namespace Cosmos.VS.ProjectSystem
private IVsProjectFactory _factory;
protected override void Initialize()
protected override async Task InitializeAsync(
CancellationToken cancellationToken,
IProgress<ServiceProgressData> progress)
{
base.Initialize();
await base.InitializeAsync(cancellationToken, progress).ConfigureAwait(false);
await JoinableTaskFactory.SwitchToMainThreadAsync();
_factory = new MigrateCosmosProjectFactory();
RegisterProjectFactory(_factory);

View file

@ -51,10 +51,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.ImageCatalog" Version="15.6.27413" />
<PackageReference Include="Microsoft.VisualStudio.Imaging" Version="15.6.27413" />
<PackageReference Include="Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime" Version="14.3.25408" />
<PackageReference Include="Microsoft.VisualStudio.Shell.15.0" Version="15.6.27413" />
<PackageReference Include="Microsoft.VisualStudio.Shell.15.0" Version="15.7.27703" />
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop.10.0" Version="10.0.30320" />
</ItemGroup>

View file

@ -2,11 +2,13 @@
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Timers;
using System.Threading;
using System.Windows.Threading;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Task = System.Threading.Tasks.Task;
using Timer = System.Timers.Timer;
using Cosmos.Debug.Common;
using Cosmos.Debug.DebugConnectors;
@ -16,14 +18,14 @@ using Cosmos.VS.Windows.ToolWindows;
namespace Cosmos.VS.Windows
{
[Guid(Guids.PackageGuidString)]
[PackageRegistration(UseManagedResourcesOnly = true)]
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[ProvideMenuResource("Menus.ctmenu", 1)]
[ProvideToolWindow(typeof(AssemblyToolWindow))]
[ProvideToolWindow(typeof(RegistersToolWindow))]
[ProvideToolWindow(typeof(StackTW))]
[ProvideToolWindow(typeof(InternalTW))]
[ProvideToolWindow(typeof(ConsoleTW))]
public sealed class CosmosWindowsPackage: Package
public sealed class CosmosWindowsPackage: AsyncPackage
{
private readonly Queue<ushort> mCommand;
private readonly Queue<byte[]> mMessage;
@ -54,11 +56,15 @@ namespace Cosmos.VS.Windows
mPipeDown.Start();
}
protected override void Initialize()
protected override async Task InitializeAsync(
CancellationToken cancellationToken,
IProgress<ServiceProgressData> progress)
{
base.Initialize();
await base.InitializeAsync(cancellationToken, progress);
var xOutputWindow = (IVsOutputWindow)GetService(typeof(SVsOutputWindow));
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
var xOutputWindow = (IVsOutputWindow)await GetServiceAsync(typeof(SVsOutputWindow));
var xCosmosPaneGuid = Guid.NewGuid();
ErrorHandler.ThrowOnFailure(