Skip to content

Commit

Permalink
correction in automatic fetch and added automatic initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ViniciusAlberkovics committed Jun 30, 2019
1 parent c8d4d95 commit 023464c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
4 changes: 1 addition & 3 deletions GitAutoFetch/AutoFetch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ namespace GitAutoFetch
/// </summary>
internal sealed class AutoFetch
{
/// <summary>
/// Command ID.
/// </summary>
public const int CommandId = 0x0100;
/// <summary>
/// Command menu group (command set GUID).
Expand Down Expand Up @@ -71,6 +68,7 @@ public static async Task InitializeAsync(AsyncPackage package, Config conf)
OleMenuCommandService commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;
Instance = new AutoFetch(package, commandService);
Config = conf;
Instance.Execute(null, null);
}

/// <summary>
Expand Down
42 changes: 28 additions & 14 deletions GitAutoFetch/GitAutoFetchPackage.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Threading;
using EnvDTE;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Task = System.Threading.Tasks.Task;
Expand Down Expand Up @@ -37,6 +36,21 @@ public sealed class GitAutoFetchPackage : AsyncPackage
public const string PackageGuidString = "a0b3344d-e011-4159-8052-c8eed06bc3ab";
#region Package Members

public GitAutoFetchPackage()
{
try
{
JoinableTaskFactory.RunAsync(async () =>
{
await InitializeAsync(this.DisposalToken, null);
});
}
catch (Exception ex)
{
throw ex;
}
}

/// <summary>
/// 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.
Expand All @@ -56,23 +70,23 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
throw ex;
}
}

protected override void Dispose(bool disposing)
{
AutoFetch.Dispose();
base.Dispose(disposing);
}

public void Opened()
{
Config config = new Config(0);
Task.Run(async () =>
try
{
await Config.VerifyConfigAsync(config);
await AutoFetch.InitializeAsync(this, config);
await OpenConfig.InitializeAsync(this, config);
});
Config config = new Config(0);
JoinableTaskFactory.RunAsync(async () =>
{
await Config.VerifyConfigAsync(config);
await AutoFetch.InitializeAsync(this, config);
await OpenConfig.InitializeAsync(this, config);
});
}
catch (Exception ex)
{
throw ex;
}
}

#endregion
Expand Down
6 changes: 3 additions & 3 deletions GitAutoFetch/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<DisplayName>GitAutoFetch</DisplayName>
<Description xml:space="preserve">Auto fetch in Git, menu location in solution explorer (Git AutoFetch and Configure Fetching)Auto fetch in Git, menu location in solution explorer (Git AutoFetch and Configure Fetching)</Description>
<Icon>Logo.png</Icon>
<Tags>git, autofetch, git-autofetch</Tags>
<Tags>git, autofetch, git-autofetch, fetch</Tags>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[16.0, 17.0)" />
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
<Dependency Id="Microsoft.VisualStudio.MPF.16.0" DisplayName="Visual Studio MPF 16.0" d:Source="Installed" Version="[16.0,17.0)" />
</Dependencies>
<Dependency Id="Microsoft.VisualStudio.MPF.16.0" DisplayName="Visual Studio MPF 16.0" d:Source="Installed" Version="[16.0,17.0)" />
</Dependencies>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[16.0,17.0)" DisplayName="Visual Studio core editor" />
</Prerequisites>
Expand Down

0 comments on commit 023464c

Please sign in to comment.