Files
speckle-sharp-connectors/Sdk/Speckle.Connectors.Logging/Consts.cs
T
Jedd Morgan f84c4b2d31 Bump SDK and enforce msbuild warnings (#379)
* Bump SDK

* Updated Tekla structures nugets

* Tekla architecture targeting

* Fixed remaining warnings
2024-11-14 21:16:46 +00:00

38 lines
1.6 KiB
C#

using System.Reflection;
namespace Speckle.Connectors.Logging;
public static class Consts
{
public const string SERVICE_NAME = "connector.name";
public const string SERVICE_SLUG = "connector.slug";
public const string OS_NAME = "os.name";
public const string OS_TYPE = "os.type";
public const string OS_SLUG = "os.slug";
public const string RUNTIME_NAME = "runtime.name";
public const string USER_ID = "user.id";
public const string TRACING_SOURCE = "speckle";
public static string GetPackageVersion(Assembly assembly)
{
// MinVer https://github.com/adamralph/minver?tab=readme-ov-file#version-numbers
// together with Microsoft.SourceLink.GitHub https://github.com/dotnet/sourcelink
// fills AssemblyInformationalVersionAttribute by
// {majorVersion}.{minorVersion}.{patchVersion}.{pre-release label}.{pre-release version}.{gitHeight}+{Git SHA of current commit}
// Ex: 1.5.0-alpha.1.40+807f703e1b4d9874a92bd86d9f2d4ebe5b5d52e4
// The following parts are optional: pre-release label, pre-release version, git height, Git SHA of current commit
// For package version, value of AssemblyInformationalVersionAttribute without commit hash is returned.
var informationalVersion = assembly
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
?.InformationalVersion;
if (informationalVersion is null)
{
return string.Empty;
}
var indexOfPlusSign = informationalVersion.IndexOf('+');
return indexOfPlusSign > 0 ? informationalVersion.Substring(0, indexOfPlusSign) : informationalVersion;
}
}