Skip to content

Commit

Permalink
SIANXSVC-1203: Ensure library_version has correct value
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nachtjasmin committed Jan 24, 2024
1 parent 7bd1753 commit 8c8b3fc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Anexia.E5E.Tests/Serialization/SerializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
);
}

Expand Down
7 changes: 3 additions & 4 deletions src/Anexia.E5E/Runtime/E5ERuntimeMetadata.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Reflection;

namespace Anexia.E5E.Runtime;

Expand All @@ -18,9 +17,9 @@ public record E5ERuntimeMetadata
/// <summary>
/// The installed version of this NuGet library.
/// </summary>
public string LibraryVersion =>
typeof(E5ERuntimeMetadata).Assembly.GetCustomAttribute<AssemblyVersionAttribute>()?.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";

/// <summary>
/// The runtime this function is running in.
Expand Down

0 comments on commit 8c8b3fc

Please sign in to comment.