From 4af1ab26d71de18d1597e2a8cdd842d707e59598 Mon Sep 17 00:00:00 2001 From: Jasmin Oster Date: Wed, 24 Jan 2024 09:43:32 +0100 Subject: [PATCH] SIANXSVC-1203: Ensure library_version has correct value We now use the assembly name, which seems to be the way forward. A test was also added to check whether the fallback value (1.0.0.0) is returned. Closes SIANXSVC-1203 --- src/Anexia.E5E.Tests/Serialization/SerializationTests.cs | 3 ++- src/Anexia.E5E/Runtime/E5ERuntimeMetadata.cs | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Anexia.E5E.Tests/Serialization/SerializationTests.cs b/src/Anexia.E5E.Tests/Serialization/SerializationTests.cs index 92ef913..9c3324b 100644 --- a/src/Anexia.E5E.Tests/Serialization/SerializationTests.cs +++ b/src/Anexia.E5E.Tests/Serialization/SerializationTests.cs @@ -136,7 +136,8 @@ public void MetadataIsProperSerialized() () => Assert.Contains("runtime", sut), () => Assert.Contains("features", sut), () => Assert.Contains("library_version", sut), - () => Assert.Equal(1, sut["features"].GetArrayLength()) + () => Assert.Equal(1, sut["features"].GetArrayLength()), + () => Assert.Equal("1.0.0.0", sut["library_version"].GetString()) ); } diff --git a/src/Anexia.E5E/Runtime/E5ERuntimeMetadata.cs b/src/Anexia.E5E/Runtime/E5ERuntimeMetadata.cs index f02ac1a..606af61 100644 --- a/src/Anexia.E5E/Runtime/E5ERuntimeMetadata.cs +++ b/src/Anexia.E5E/Runtime/E5ERuntimeMetadata.cs @@ -1,5 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using System.Reflection; namespace Anexia.E5E.Runtime; @@ -18,9 +17,9 @@ public record E5ERuntimeMetadata /// /// The installed version of this NuGet library. /// - public string LibraryVersion => - typeof(E5ERuntimeMetadata).Assembly.GetCustomAttribute()?.Version ?? - "0.0.0-unrecognized"; + // CC-BY-SA 4.0 lastlink: https://stackoverflow.com/a/57157323 + public string LibraryVersion => typeof(E5ERuntimeMetadata).Assembly.GetName().Version?.ToString() + ?? "0.0.0-unrecognized"; /// /// The runtime this function is running in.