Skip to content

Commit be72b62

Browse files
Updates version detection (#256)
1 parent 700c76c commit be72b62

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

msgraph-developer-proxy-abstractions/msgraph-developer-proxy-abstractions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<RootNamespace>Microsoft.Graph.DeveloperProxy.Abstractions</RootNamespace>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8-
<Version>0.6.0</Version>
8+
<Version>0.7.0</Version>
99
</PropertyGroup>
1010

1111
<ItemGroup>

msgraph-developer-proxy-plugins/msgraph-developer-proxy-plugins.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Nullable>enable</Nullable>
77
<EnableDynamicLoading>true</EnableDynamicLoading>
88
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
9-
<Version>0.6.0</Version>
9+
<Version>0.7.0</Version>
1010
</PropertyGroup>
1111
<ItemGroup>
1212
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0">

msgraph-developer-proxy/ProxyEngine.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Microsoft.Graph.DeveloperProxy.Abstractions;
55
using System.Diagnostics;
66
using System.Net;
7+
using System.Reflection;
78
using System.Text.RegularExpressions;
89
using Titanium.Web.Proxy;
910
using Titanium.Web.Proxy.EventArguments;
@@ -24,14 +25,27 @@ public class ProxyEngine {
2425
// lists of hosts to watch extracted from urlsToWatch,
2526
// used for deciding which URLs to decrypt for further inspection
2627
private ISet<UrlToWatch> _hostsToWatch = new HashSet<UrlToWatch>();
28+
private static Assembly? _assembly;
29+
30+
internal static Assembly GetAssembly()
31+
=> _assembly ??= (Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly());
2732

2833
private static string _productVersion = string.Empty;
2934
public static string ProductVersion {
3035
get {
31-
// product version to display in the terminal and used for
32-
// new version notification. Added here because .net doesn't
33-
// stamp version on assemblies on non-Windows OSes
34-
return "0.7.0";
36+
if (_productVersion == string.Empty) {
37+
var assembly = GetAssembly();
38+
var assemblyVersionAttribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
39+
40+
if (assemblyVersionAttribute is null) {
41+
_productVersion = assembly.GetName().Version?.ToString() ?? "";
42+
}
43+
else {
44+
_productVersion = assemblyVersionAttribute.InformationalVersion;
45+
}
46+
}
47+
48+
return _productVersion;
3549
}
3650
}
3751

msgraph-developer-proxy/msgraph-developer-proxy.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Nullable>enable</Nullable>
99
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1010
<Title>Microsoft Graph Developer Proxy</Title>
11-
<Version>0.6.0</Version>
11+
<Version>0.7.0</Version>
1212
<Company>Microsoft</Company>
1313
<Product>Microsoft Graph Developer Proxy</Product>
1414
<AssemblyName>mgdp</AssemblyName>

0 commit comments

Comments
 (0)