Add extension method to use automatic application version

This commit is contained in:
Patrik Svensson 2024-04-25 19:51:05 +02:00 committed by Patrik Svensson
parent 3acc90e47c
commit 5d4b2c88e5

View File

@ -82,7 +82,7 @@ public static class ConfiguratorExtensions
}
/// <summary>
/// Overrides the auto-detected version of the application.
/// Sets the version of the application.
/// </summary>
/// <param name="configurator">The configurator.</param>
/// <param name="version">The version of application.</param>
@ -98,6 +98,25 @@ public static class ConfiguratorExtensions
return configurator;
}
/// <summary>
/// Uses the version retrieved from the <see cref="AssemblyInformationalVersionAttribute"/>
/// as the application's version.
/// </summary>
/// <param name="configurator">The configurator.</param>
/// <returns>A configurator that can be used to configure the application further.</returns>
public static IConfigurator UseAssemblyInformationalVersion(this IConfigurator configurator)
{
if (configurator == null)
{
throw new ArgumentNullException(nameof(configurator));
}
configurator.Settings.ApplicationVersion =
VersionHelper.GetVersion(Assembly.GetEntryAssembly());
return configurator;
}
/// <summary>
/// Hides the <c>DEFAULT</c> column that lists default values coming from the
/// <see cref="DefaultValueAttribute"/> in the options help text.