Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 51b33ed

Browse files
committed
Moved package version info to ApplicationInfo.
1 parent a5df893 commit 51b33ed

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

src/GitHub.Logging/Info/ApplicationInfo.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
namespace GitHub.Info
1+
using System;
2+
using System.Diagnostics;
3+
4+
namespace GitHub.Info
25
{
36
public static class ApplicationInfo
47
{
@@ -11,5 +14,27 @@ public static class ApplicationInfo
1114
#endif
1215
public const string ApplicationSafeName = "GitHubVisualStudio";
1316
public const string ApplicationDescription = "GitHub Extension for Visual Studio";
17+
18+
/// <summary>
19+
/// Gets the version information for the host process.
20+
/// </summary>
21+
/// <returns>The version of the host process.</returns>
22+
public static FileVersionInfo GetHostVersionInfo()
23+
{
24+
return Process.GetCurrentProcess().MainModule.FileVersionInfo;
25+
}
26+
27+
/// <summary>
28+
/// Gets the version of a Visual Studio package.
29+
/// </summary>
30+
/// <param name="package">
31+
/// The VS Package object. This is untyped here as this assembly does not depend on
32+
/// any VS assemblies.
33+
/// </param>
34+
/// <returns>The version of the package.</returns>
35+
public static Version GetPackageVersion(object package)
36+
{
37+
return package.GetType().Assembly.GetName().Version;
38+
}
1439
}
1540
}

src/GitHub.VisualStudio/GitHubPackage.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using Serilog;
2121
using Task = System.Threading.Tasks.Task;
2222
using EnvDTE;
23+
using GitHub.Info;
2324

2425
namespace GitHub.VisualStudio
2526
{
@@ -60,9 +61,8 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
6061

6162
void LogVersionInformation()
6263
{
63-
// Show extension and host process version information
64-
var packageVersion = GetType().Assembly.GetName().Version;
65-
var hostVersionInfo = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileVersionInfo;
64+
var packageVersion = ApplicationInfo.GetPackageVersion(this);
65+
var hostVersionInfo = ApplicationInfo.GetHostVersionInfo();
6666
log.Information("Initializing GitHub Extension v{PackageVersion} in {$FileDescription} ({$ProductVersion})",
6767
packageVersion, hostVersionInfo.FileDescription, hostVersionInfo.ProductVersion);
6868
}

0 commit comments

Comments
 (0)