Skip to content

Commit 70f4e06

Browse files
committed
Update ProductInfo to use semver-compliant AssemblyInformationalVersion
ProductInfo.ToString() was recently updated to get the assembly version programmatically, instead of using a hard-coded string. But the particular API used--`Assembly.GetName().Version.ToString(3)`--isn't fully compatible with semver. Specifically, it doesn't handle pre-release labels which can extend the MAJOR.MINOR.PATCH format. This change updates ToString() to use `Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion`. The InformationalVersion on the assembly holds the semver-compatible version string.
1 parent 9f7269f commit 70f4e06

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

iothub/device/src/ProductInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal class ProductInfo
1414
public override string ToString()
1515
{
1616
const string Name = "Microsoft.Azure.Devices.Client";
17-
string version = typeof(DeviceClient).GetTypeInfo().Assembly.GetName().Version.ToString(3);
17+
string version = typeof(DeviceClient).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
1818
string runtime = RuntimeInformation.FrameworkDescription.Trim();
1919
string operatingSystem = RuntimeInformation.OSDescription.Trim();
2020
string processorArchitecture = RuntimeInformation.ProcessArchitecture.ToString().Trim();

0 commit comments

Comments
 (0)