Skip to content

Commit

Permalink
Merge pull request #125 from Taschenbuch/Fixed_did_not_get_version_wh…
Browse files Browse the repository at this point in the history
…en_fody_costura_is_used

Fix: did not get version number when gw2sharp.dll was included into .…
  • Loading branch information
Archomeda authored Sep 11, 2022
2 parents b1c8adf + a6dce9b commit 574d18c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Gw2Sharp/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Linq;
using System.Net.Http.Headers;
using System.Reflection;
using Gw2Sharp.Mumble;
using Gw2Sharp.WebApi;
using Gw2Sharp.WebApi.Caching;
Expand Down Expand Up @@ -88,9 +90,10 @@ public Connection(
string userAgentProduct = "Gw2Sharp";
try
{
string? fileVersion = FileVersionInfo.GetVersionInfo(typeof(Gw2Client).Assembly.Location).FileVersion;
if (!string.IsNullOrWhiteSpace(fileVersion))
userAgentProduct = $"Gw2Sharp/{new Version(fileVersion).ToString(3)}";
var attribute = typeof(Gw2Client).Assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).FirstOrDefault();

if (attribute is AssemblyFileVersionAttribute assemblyFileVersionAttribute)
userAgentProduct = $"Gw2Sharp/{new Version(assemblyFileVersionAttribute.Version).ToString(3)}";
}
catch { /* Ignore */ }
this.UserAgent = $"{userAgent}{(!string.IsNullOrWhiteSpace(userAgent) ? " " : "")}" +
Expand Down

0 comments on commit 574d18c

Please sign in to comment.