Skip to content

Commit

Permalink
Update connector client code to return and log the right assembly ver…
Browse files Browse the repository at this point in the history
…sion. (#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.
  • Loading branch information
gabog authored Dec 27, 2021
1 parent 93c4288 commit ea3199e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<LocalPackageVersion>4.11.0-local</LocalPackageVersion>
<LocalPackageVersion>0.0.0.0</LocalPackageVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion libraries/Microsoft.Bot.Connector/ConnectorClientEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public static void AddDefaultRequestHeaders(HttpClient httpClient)
/// <returns>The assembly version for this Bot Connector client.</returns>
private static string GetClientVersion()
{
var type = typeof(ConnectorClient).GetType();
var type = typeof(ConnectorClient);
var assembly = type.GetTypeInfo().Assembly;
return assembly.GetName().Version.ToString();
}
Expand Down
3 changes: 2 additions & 1 deletion tests/Microsoft.Bot.Builder.AI.LUIS.Tests/LuisOracleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 4 additions & 1 deletion tests/Microsoft.Bot.Builder.AI.QnA.Tests/QnAMakerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit ea3199e

Please sign in to comment.