Skip to content

Commit

Permalink
removing OS description from User agent - making sure to scrub the ru…
Browse files Browse the repository at this point in the history
…ntimeVersion of any parentheses that could cause an error to propogate from the runtime.
  • Loading branch information
slorello89 committed Feb 7, 2020
1 parent dae26d6 commit 597873a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Nexmo.Api/Request/VersionedApiRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,19 @@ internal static void SetUserAgent(ref HttpRequestMessage request, Credentials cr
{
if (string.IsNullOrEmpty(_userAgent))
{
#if NETSTANDARD1_6 || NETSTANDARD2_0
#if NETSTANDARD1_6 || NETSTANDARD2_0 || NETSTANDARD2_1
// TODO: watch the next core release; may have functionality to make this cleaner
var runtimeVersion = (System.Runtime.InteropServices.RuntimeInformation.OSDescription + System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription)
var languageVersion = (System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription)
.Replace(" ", "")
.Replace("/", "")
.Replace(":", "")
.Replace(";", "")
.Replace("_", "")
.Replace("(", "")
.Replace(")", "")
;
#else
var runtimeVersion = System.Diagnostics.FileVersionInfo
var languageVersion = System.Diagnostics.FileVersionInfo
.GetVersionInfo(typeof(int).Assembly.Location)
.ProductVersion;
#endif
Expand All @@ -116,7 +118,7 @@ internal static void SetUserAgent(ref HttpRequestMessage request, Credentials cr
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
.InformationalVersion;

_userAgent = $"nexmo-dotnet/{libraryVersion} dotnet/{runtimeVersion}";
_userAgent = $"nexmo-dotnet/{libraryVersion} dotnet/{languageVersion}";

var appVersion = creds?.AppUserAgent ?? Configuration.Instance.Settings["appSettings:Nexmo.UserAgent"];
if (!string.IsNullOrWhiteSpace(appVersion))
Expand Down

0 comments on commit 597873a

Please # to comment.