Skip to content

Commit f97e774

Browse files
committed
Loaded the package on solution load.
1 parent 9cfc8c4 commit f97e774

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

src/GtmExtension/GtmPackage.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
using System;
2-
using System.ComponentModel.Design;
3-
using System.Diagnostics;
4-
using System.Diagnostics.CodeAnalysis;
5-
using System.Globalization;
6-
using System.Runtime.InteropServices;
7-
using System.Threading;
8-
using System.Threading.Tasks;
91
using Microsoft.VisualStudio;
10-
using Microsoft.VisualStudio.OLE.Interop;
112
using Microsoft.VisualStudio.Shell;
123
using Microsoft.VisualStudio.Shell.Interop;
13-
using Microsoft.Win32;
4+
using System;
5+
using System.Diagnostics.CodeAnalysis;
6+
using System.Runtime.InteropServices;
7+
using System.Threading;
148
using Task = System.Threading.Tasks.Task;
159

1610
namespace GtmExtension
@@ -36,6 +30,7 @@ namespace GtmExtension
3630
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] // Info on this package for Help/About
3731
[Guid(GtmPackage.PackageGuidString)]
3832
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "pkgdef, VS and vsixmanifest are valid VS terms")]
33+
[ProvideAutoLoad(UIContextGuids80.SolutionExists, PackageAutoLoadFlags.BackgroundLoad)] // Load the extension when a solution is open.
3934
public sealed class GtmPackage : AsyncPackage
4035
{
4136
/// <summary>
@@ -68,6 +63,14 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
6863
// When initialized asynchronously, the current thread may be a background thread at this point.
6964
// Do any initialization that requires the UI thread after switching to the UI thread.
7065
await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
66+
67+
// Show test message box.
68+
var uiShell = (IVsUIShell)await GetServiceAsync(typeof(SVsUIShell));
69+
if (uiShell == null) { return; }
70+
Guid clsid = Guid.Empty;
71+
int result;
72+
ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox(0, ref clsid, "GtmPackage", "Initializing.", string.Empty, 0,
73+
OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, OLEMSGICON.OLEMSGICON_INFO, 0, out result));
7174
}
7275

7376
#endregion

0 commit comments

Comments
 (0)