diff --git a/ocaml/sdk-gen/csharp/autogen/src/Session.cs b/ocaml/sdk-gen/csharp/autogen/src/Session.cs index 5d999136833..8f2b363b7b3 100644 --- a/ocaml/sdk-gen/csharp/autogen/src/Session.cs +++ b/ocaml/sdk-gen/csharp/autogen/src/Session.cs @@ -48,7 +48,15 @@ public partial class Session : XenObject /// /// This string is used as the HTTP UserAgent for each request. /// - public static string UserAgent = $"XenAPI/{Helper.APIVersionString(API_Version.LATEST)}"; + public static string DefaultUserAgent => $"XenAPI/{Helper.APIVersionString(API_Version.LATEST)}"; + + private static string _userAgent = null; + + public static string UserAgent + { + get => _userAgent ?? DefaultUserAgent; + set => _userAgent = value; + } /// /// If null, no proxy is used, otherwise this proxy is used for each request. @@ -65,7 +73,7 @@ public Session(JsonRpcClient client) { client.Timeout = STANDARD_TIMEOUT; client.KeepAlive = true; - client.UserAgent = UserAgent; + UserAgent = !string.IsNullOrEmpty(client.UserAgent) ? client.UserAgent : UserAgent; client.WebProxy = Proxy; client.AllowAutoRedirect = true; JsonRpcClient = client;