Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserAgent: Removes direct version #3173

Merged
merged 4 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions Microsoft.Azure.Cosmos/src/EnvironmentInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Cosmos
internal sealed class EnvironmentInformation
{
private static readonly string clientSDKVersion;
private static readonly string directPackageVersion;
private static readonly string framework;
private static readonly string architecture;
private static readonly string os;
Expand All @@ -19,8 +18,6 @@ static EnvironmentInformation()
{
Version sdkVersion = Assembly.GetAssembly(typeof(CosmosClient)).GetName().Version;
EnvironmentInformation.clientSDKVersion = $"{sdkVersion.Major}.{sdkVersion.Minor}.{sdkVersion.Build}";
Version directVersion = Assembly.GetAssembly(typeof(Documents.UserAgentContainer)).GetName().Version;
EnvironmentInformation.directPackageVersion = $"{directVersion.Major}.{directVersion.Minor}.{directVersion.Build}";
EnvironmentInformation.framework = RuntimeInformation.FrameworkDescription;
EnvironmentInformation.architecture = RuntimeInformation.ProcessArchitecture.ToString();
EnvironmentInformation.os = RuntimeInformation.OSDescription;
Expand All @@ -30,11 +27,6 @@ public EnvironmentInformation()
{
}

/// <summary>
/// Version of the current direct package.
/// </summary>
public string DirectVersion => EnvironmentInformation.directPackageVersion;

/// <summary>
/// Version of the current client.
/// </summary>
Expand Down
5 changes: 1 addition & 4 deletions Microsoft.Azure.Cosmos/src/UserAgentContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@ public UserAgentContainer(

protected virtual void GetEnvironmentInformation(
out string clientVersion,
out string directVersion,
out string processArchitecture,
out string operatingSystem,
out string runtimeFramework)
{
EnvironmentInformation environmentInformation = new EnvironmentInformation();
clientVersion = environmentInformation.ClientVersion;
directVersion = environmentInformation.DirectVersion;
processArchitecture = environmentInformation.ProcessArchitecture;
operatingSystem = environmentInformation.OperatingSystem;
runtimeFramework = environmentInformation.RuntimeFramework;
Expand All @@ -52,7 +50,6 @@ private string CreateBaseUserAgentString(
{
this.GetEnvironmentInformation(
out string clientVersion,
out string directVersion,
out string processArchitecture,
out string operatingSystem,
out string runtimeFramework);
Expand All @@ -68,7 +65,7 @@ private string CreateBaseUserAgentString(
#if PREVIEW
previewFlag = "P";
#endif
string baseUserAgent = $"cosmos-netstandard-sdk/{clientVersion}" + previewFlag + Regex.Replace($"|{directVersion}|{this.clientId}|{processArchitecture}|{operatingSystem}|{runtimeFramework}|", @"[^0-9a-zA-Z\.\|\-]+", " ");
string baseUserAgent = $"cosmos-netstandard-sdk/{clientVersion}" + previewFlag + Regex.Replace($"|{this.clientId}|{processArchitecture}|{operatingSystem}|{runtimeFramework}|", @"[^0-9a-zA-Z\.\|\-]+", " ");
if (!string.IsNullOrEmpty(regionConfiguration))
{
baseUserAgent += $"{regionConfiguration}|";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public void VerifyUserAgentContent()
previewFlag = "P";
#endif
Assert.AreEqual($"cosmos-netstandard-sdk/{envInfo.ClientVersion}" + previewFlag, values[0]);
Assert.AreEqual(envInfo.DirectVersion, values[1]);
Assert.AreEqual("0", values[2]);
imanvt marked this conversation as resolved.
Show resolved Hide resolved
Assert.AreEqual(envInfo.ProcessArchitecture, values[3]);
Assert.AreEqual(envInfo.OperatingSystem, values[4]);
Expand Down Expand Up @@ -377,7 +376,6 @@ public MacOsUserAgentContainer(int clientId,

protected override void GetEnvironmentInformation(
out string clientVersion,
out string directVersion,
out string processArchitecture,
out string operatingSystem,
out string runtimeFramework)
Expand All @@ -387,7 +385,6 @@ protected override void GetEnvironmentInformation(

base.GetEnvironmentInformation(
clientVersion: out clientVersion,
directVersion: out directVersion,
processArchitecture: out processArchitecture,
operatingSystem: out _,
runtimeFramework: out runtimeFramework);
Expand Down