Skip to content

Commit

Permalink
- Added partial support for loading the Nifty Perforce extension in t…
Browse files Browse the repository at this point in the history
…he background (from jgvincen <[email protected]>)

- Add reference to Microsoft.VisualStudio.SDK.EmbedInteropTypes to fix the assemblies being referenced instead of linked
- Update VSSDK BuildTools reference version
- Bump to 2.0.9
  • Loading branch information
belkiss committed Oct 22, 2019
1 parent 5aa617f commit 3e27df8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
3 changes: 2 additions & 1 deletion NiftyPerforce/NiftyPerforce.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="15.9.3" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="16.1.46" />
<PackageReference Include="Microsoft.VisualStudio.SDK.EmbedInteropTypes" Version="15.0.27" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="16.4.1055" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
Expand Down
30 changes: 18 additions & 12 deletions NiftyPerforce/NiftyPerforcePackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
using Aurora;
using System.Windows.Forms;

using System.Threading;
using Task = System.Threading.Tasks.Task;

namespace NiftyPerforce
{
/// <summary>
Expand All @@ -39,12 +42,12 @@ namespace NiftyPerforce
/// To get loaded into VS, the package must be referred by &lt;Asset Type="Microsoft.VisualStudio.VsPackage" ...&gt; in .vsixmanifest file.
/// </para>
/// </remarks>
[PackageRegistration(UseManagedResourcesOnly = true)]
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] // Info on this package for Help/About
[ProvideAutoLoad(Microsoft.VisualStudio.VSConstants.UICONTEXT.NoSolution_string)] // Note: the package must be loaded on startup to create and bind commands
[ProvideAutoLoad(Microsoft.VisualStudio.VSConstants.UICONTEXT.NoSolution_string, PackageAutoLoadFlags.BackgroundLoad)] // Note: the package must be loaded on startup to create and bind commands
[Guid(NiftyPerforcePackage.PackageGuidString)]
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "pkgdef, VS and vsixmanifest are valid VS terms")]
public sealed class NiftyPerforcePackage : Package
public sealed class NiftyPerforcePackage : AsyncPackage
{
/// <summary>
/// Package GUID string.
Expand All @@ -69,19 +72,22 @@ public NiftyPerforcePackage()
/// Initialization of the package; this method is called right after the package is sited, so this is the place
/// where you can put all the initialization code that rely on services provided by VisualStudio.
/// </summary>
protected override void Initialize()
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
base.Initialize();
await base.InitializeAsync(cancellationToken, progress);

// Every plugin needs a command bar.
DTE2 application = await base.GetServiceAsync(typeof(DTE)).ConfigureAwait(false) as DTE2;
IVsProfferCommands3 profferCommands3 = await base.GetServiceAsync(typeof(SVsProfferCommands)) as IVsProfferCommands3;
OleMenuCommandService oleMenuCommandService = await GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;

// Switches to the UI thread in order to consume some services used in command initialization
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

// Load up the options from file.
string optionsFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "NiftyPerforce.xml");
Config options = Config.Load(optionsFileName);

// Every plugin needs a command bar.
DTE2 application = GetGlobalService(typeof(DTE)) as DTE2;
IVsProfferCommands3 profferCommands3 = base.GetService(typeof(SVsProfferCommands)) as IVsProfferCommands3;
OleMenuCommandService oleMenuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

ImageList icons = new ImageList();
icons.Images.AddStrip(Properties.Resources.Icons);
m_plugin = new Plugin(application, profferCommands3, icons, oleMenuCommandService, "NiftyPerforce", "Aurora.NiftyPerforce.Connect", options);
Expand Down Expand Up @@ -176,7 +182,7 @@ protected override void Initialize()
/// </summary>
private void Cleanup()
{
IVsProfferCommands3 profferCommands3 = base.GetService(typeof(SVsProfferCommands)) as IVsProfferCommands3;
IVsProfferCommands3 profferCommands3 = base.GetServiceAsync(typeof(SVsProfferCommands)) as IVsProfferCommands3;
RemoveCommandBar("NiftyPerforceCmdBar", profferCommands3);
RemoveCommandBar("NiftyPerforce", profferCommands3);

Expand Down Expand Up @@ -261,7 +267,7 @@ private void RemoveCommand(string name, IVsProfferCommands3 profferCommands3)
}
}
}

private void RemoveCommandBar(string name, IVsProfferCommands3 profferCommands3)
{
// Remove a command bar and contained controls
Expand Down
2 changes: 1 addition & 1 deletion NiftyPerforce/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="NiftyPerforce.Tilander.eb29cef1-a8b5-41b1-922d-6ba8cec91ef4" Version="2.0.8" Language="en-US" Publisher="Lambert Clara" />
<Identity Id="NiftyPerforce.Tilander.eb29cef1-a8b5-41b1-922d-6ba8cec91ef4" Version="2.0.9" Language="en-US" Publisher="Lambert Clara" />
<DisplayName>NiftyPerforce</DisplayName>
<Description xml:space="preserve">Simple Perforce integration for Visual Studio</Description>
<MoreInfo>https://github.com/belkiss/niftyplugins</MoreInfo>
Expand Down
1 change: 1 addition & 0 deletions Shared/AuroraCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="15.9.3" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.VisualStudio.SDK.EmbedInteropTypes" Version="15.0.27" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down

1 comment on commit 3e27df8

@gorlak
Copy link

@gorlak gorlak commented on 3e27df8 Aug 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for releasing this! 👍

Please sign in to comment.