Initial commit (history squashed)
This commit is contained in:
28
src/StellaOps.Feedser.Exporter.Json/ExporterVersion.cs
Normal file
28
src/StellaOps.Feedser.Exporter.Json/ExporterVersion.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace StellaOps.Feedser.Exporter.Json;
|
||||
|
||||
public static class ExporterVersion
|
||||
{
|
||||
public static string GetVersion(Type anchor)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(anchor);
|
||||
var assembly = anchor.Assembly;
|
||||
|
||||
var informational = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
|
||||
if (!string.IsNullOrWhiteSpace(informational))
|
||||
{
|
||||
return informational;
|
||||
}
|
||||
|
||||
var fileVersion = assembly.GetCustomAttribute<AssemblyFileVersionAttribute>()?.Version;
|
||||
if (!string.IsNullOrWhiteSpace(fileVersion))
|
||||
{
|
||||
return fileVersion!;
|
||||
}
|
||||
|
||||
var version = assembly.GetName().Version;
|
||||
return version?.ToString() ?? "0.0.0";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user