From f1b2156327a4fcb92f64c0640cb314404249e4f7 Mon Sep 17 00:00:00 2001 From: Nate Bross Date: Tue, 24 Dec 2024 12:11:47 -0600 Subject: [PATCH] fix: include assembly version in user agent for netstandard1.3 (#373) --- src/FMData.Rest/FileMakerRestClient.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/FMData.Rest/FileMakerRestClient.cs b/src/FMData.Rest/FileMakerRestClient.cs index ec75a79..c61ab58 100644 --- a/src/FMData.Rest/FileMakerRestClient.cs +++ b/src/FMData.Rest/FileMakerRestClient.cs @@ -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()?.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); }