Files
speckle-sharp-connectors/Sdk/Speckle.Connectors.Common/Common/AssemblyExtensions.cs
T
Adam Hathcock 3227d09958 Simplify DI/assembly structure part deux (#270)
* Rename utils to common

* fix namespaces

* Rhino kind of works

* Fix converter registration

* Fixed circular referece with lazy resolving

* Fixed Rhino8

* Revit 2022 builds

* revit 2023 compiles

* working on revit

* use speckle app for info instead of statics

* lazy init bindings

* Rhino compiles

* Revit compiles

* Autocad 2022 builds

* Autocad/Civil builds

* ArcGIS compiles

* Remove Autofac completely

* format

* React to SDK renames

* fixes for merge

* Update nuget and official sln

* Remove extra projects

* AutoActivate IBrowserBridge and rename it

* add extra null check

* Merge fixes

* Fix convertermanager problem and add tests

* Add new test project to local sln

* Use recursion

* formatting

* resolve circular dep with lazy get
2024-09-24 16:15:01 +03:00

29 lines
1.2 KiB
C#

using System.Reflection;
namespace Speckle.Connectors.Common.Common;
public static class AssemblyExtensions
{
public static string GetVersion(this 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[..indexOfPlusSign] : informationalVersion;
}
}