Skip to content

Commit

Permalink
fix: include assembly version in user agent for netstandard1.3 (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzzerd authored Dec 24, 2024
1 parent 325bccb commit f1b2156
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/FMData.Rest/FileMakerRestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,17 @@ public FileMakerRestClient(
_targetVersion = "v1";
break;
}

#if NETSTANDARD1_3
var header = new System.Net.Http.Headers.ProductHeaderValue("FMData.Rest", "4");
var userAgent = new System.Net.Http.Headers.ProductInfoHeaderValue(header);
var assembly = typeof(FileMakerRestClient).GetTypeInfo().Assembly;
var version = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "5";
#else
var assembly = Assembly.GetExecutingAssembly();
var version = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location).ProductVersion;
var header = new System.Net.Http.Headers.ProductHeaderValue(assembly.GetName().Name, version);
var userAgent = new System.Net.Http.Headers.ProductInfoHeaderValue(header);
#endif
var header = new ProductHeaderValue(assembly.GetName().Name, version);
var userAgent = new ProductInfoHeaderValue(header);

Client.DefaultRequestHeaders.UserAgent.Add(userAgent);
}

Expand Down

0 comments on commit f1b2156

Please sign in to comment.