using System; using System.Reflection; using Semver; namespace Umbraco.Core.Configuration { /// /// Represents the version of the executing code. /// public class UmbracoVersion : IUmbracoVersion { public UmbracoVersion() { var umbracoCoreAssembly = typeof(SemVersion).Assembly; // gets the value indicated by the AssemblyVersion attribute AssemblyVersion = umbracoCoreAssembly.GetName().Version; // gets the value indicated by the AssemblyFileVersion attribute AssemblyFileVersion = System.Version.Parse(umbracoCoreAssembly.GetCustomAttribute().Version); // gets the value indicated by the AssemblyInformationalVersion attribute // this is the true semantic version of the Umbraco Cms SemanticVersion = SemVersion.Parse(umbracoCoreAssembly.GetCustomAttribute().InformationalVersion); // gets the non-semantic version Current = SemanticVersion.GetVersion(3); } /// /// Gets the non-semantic version of the Umbraco code. /// // TODO: rename to Version public Version Current { get; } /// /// Gets the semantic version comments of the Umbraco code. /// public string Comment => SemanticVersion.Prerelease; /// /// Gets the assembly version of the Umbraco code. /// /// /// The assembly version is the value of the . /// Is the one that the CLR checks for compatibility. Therefore, it changes only on /// hard-breaking changes (for instance, on new major versions). /// public Version AssemblyVersion { get; } /// /// Gets the assembly file version of the Umbraco code. /// /// /// The assembly version is the value of the . /// public Version AssemblyFileVersion { get; } /// /// Gets the semantic version of the Umbraco code. /// /// /// The semantic version is the value of the . /// It is the full version of Umbraco, including comments. /// public SemVersion SemanticVersion { get; } } }