From ea3199e98b619ba46b5492899e80c5e2d42e714a Mon Sep 17 00:00:00 2001 From: Gabo Gilabert Date: Mon, 27 Dec 2021 14:42:31 -0500 Subject: [PATCH] Update connector client code to return and log the right assembly version. (#6073) * Updated connector client code to return the right assembly version. Updated LocalPackageVersion to use 0.0.0.0 so dev assembly vesions can be easily identified in the logs. * Fixed unit tests to work with new localversion. --- Directory.Build.props | 2 +- libraries/Microsoft.Bot.Connector/ConnectorClientEx.cs | 2 +- tests/Microsoft.Bot.Builder.AI.LUIS.Tests/LuisOracleTests.cs | 3 ++- .../Microsoft.Bot.Builder.AI.LUIS.Tests/LuisV3OracleTests.cs | 3 ++- tests/Microsoft.Bot.Builder.AI.QnA.Tests/QnAMakerTests.cs | 5 ++++- .../LuisV3OracleTests.cs | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index ce0ae11cc0..453e5ba145 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 4.11.0-local + 0.0.0.0 diff --git a/libraries/Microsoft.Bot.Connector/ConnectorClientEx.cs b/libraries/Microsoft.Bot.Connector/ConnectorClientEx.cs index f4123f4dee..40062fe64b 100644 --- a/libraries/Microsoft.Bot.Connector/ConnectorClientEx.cs +++ b/libraries/Microsoft.Bot.Connector/ConnectorClientEx.cs @@ -266,7 +266,7 @@ public static void AddDefaultRequestHeaders(HttpClient httpClient) /// The assembly version for this Bot Connector client. private static string GetClientVersion() { - var type = typeof(ConnectorClient).GetType(); + var type = typeof(ConnectorClient); var assembly = type.GetTypeInfo().Assembly; return assembly.GetName().Version.ToString(); } diff --git a/tests/Microsoft.Bot.Builder.AI.LUIS.Tests/LuisOracleTests.cs b/tests/Microsoft.Bot.Builder.AI.LUIS.Tests/LuisOracleTests.cs index 7452373d40..d1d843c187 100644 --- a/tests/Microsoft.Bot.Builder.AI.LUIS.Tests/LuisOracleTests.cs +++ b/tests/Microsoft.Bot.Builder.AI.LUIS.Tests/LuisOracleTests.cs @@ -337,7 +337,8 @@ public void UserAgentContainsProductVersion() Assert.Contains("Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.LUISRuntimeClient", userAgent); // And that we added the bot.builder package details. - Assert.Contains("microsoft.bot.builder.ai.luis/4", userAgent.ToLower()); + var majorVersion = typeof(ConnectorClient).GetTypeInfo().Assembly.GetName().Version.Major; + Assert.Contains($"microsoft.bot.builder.ai.luis/{majorVersion}", userAgent.ToLower()); } [Fact] diff --git a/tests/Microsoft.Bot.Builder.AI.LUIS.Tests/LuisV3OracleTests.cs b/tests/Microsoft.Bot.Builder.AI.LUIS.Tests/LuisV3OracleTests.cs index 3005534755..3d31cb5d44 100644 --- a/tests/Microsoft.Bot.Builder.AI.LUIS.Tests/LuisV3OracleTests.cs +++ b/tests/Microsoft.Bot.Builder.AI.LUIS.Tests/LuisV3OracleTests.cs @@ -311,7 +311,8 @@ public void UserAgentContainsProductVersion() var userAgent = clientHandler.UserAgent; // And that we added the bot.builder package details. - Assert.Contains("Microsoft.Bot.Builder.AI.Luis/4", userAgent); + var majorVersion = typeof(ConnectorClient).GetTypeInfo().Assembly.GetName().Version.Major; + Assert.Contains($"Microsoft.Bot.Builder.AI.Luis/{majorVersion}", userAgent); } [Fact] diff --git a/tests/Microsoft.Bot.Builder.AI.QnA.Tests/QnAMakerTests.cs b/tests/Microsoft.Bot.Builder.AI.QnA.Tests/QnAMakerTests.cs index baa05df212..c13f95af9b 100644 --- a/tests/Microsoft.Bot.Builder.AI.QnA.Tests/QnAMakerTests.cs +++ b/tests/Microsoft.Bot.Builder.AI.QnA.Tests/QnAMakerTests.cs @@ -7,6 +7,7 @@ using System.IO; using System.Net; using System.Net.Http; +using System.Reflection; using System.Threading; using System.Threading.Tasks; using Microsoft.Bot.Builder.Adapters; @@ -19,6 +20,7 @@ using Microsoft.Bot.Builder.Dialogs.Adaptive.Conditions; using Microsoft.Bot.Builder.Dialogs.Adaptive.Templates; using Microsoft.Bot.Configuration; +using Microsoft.Bot.Connector; using Microsoft.Bot.Schema; using Moq; using Newtonsoft.Json; @@ -810,7 +812,8 @@ public async Task QnaMaker_UserAgent() Assert.StartsWith("BaseCamp: You can use a damp rag to clean around the Power Pack", results[0].Answer); // Verify that we added the bot.builder package details. - Assert.Contains("Microsoft.Bot.Builder.AI.QnA/4", interceptHttp.UserAgent); + var majorVersion = typeof(ConnectorClient).GetTypeInfo().Assembly.GetName().Version.Major; + Assert.Contains($"Microsoft.Bot.Builder.AI.QnA/{majorVersion}", interceptHttp.UserAgent); } [Fact] diff --git a/tests/Microsoft.Bot.Builder.Ai.LUISV3.tests/LuisV3OracleTests.cs b/tests/Microsoft.Bot.Builder.Ai.LUISV3.tests/LuisV3OracleTests.cs index 639d3643e4..48717bd340 100644 --- a/tests/Microsoft.Bot.Builder.Ai.LUISV3.tests/LuisV3OracleTests.cs +++ b/tests/Microsoft.Bot.Builder.Ai.LUISV3.tests/LuisV3OracleTests.cs @@ -299,7 +299,8 @@ public void UserAgentContainsProductVersion() var userAgent = clientHandler.UserAgent; // And that we added the bot.builder package details. - Assert.Contains("Microsoft.Bot.Builder.AI.Luis/4", userAgent); + var majorVersion = typeof(ConnectorClient).GetTypeInfo().Assembly.GetName().Version.Major; + Assert.Contains($"Microsoft.Bot.Builder.AI.Luis/{majorVersion}", userAgent); } [Fact]