Last active
August 9, 2023 19:06
-
-
Save pwelter34/d9487e5acfcede62a58c9c70a07dc7bd to your computer and use it in GitHub Desktop.
Assembly Metadata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class AssemblyMetadata | |
{ | |
private static readonly Lazy<string> _fileVersion = new(() => | |
{ | |
var assembly = typeof(AssemblyMetadata).Assembly; | |
var attribute = assembly.GetCustomAttribute<AssemblyFileVersionAttribute>(); | |
return attribute?.Version; | |
}); | |
private static readonly Lazy<string> _assemblyVersion = new(() => | |
{ | |
var assembly = typeof(AssemblyMetadata).Assembly; | |
var attribute = assembly.GetCustomAttribute<AssemblyVersionAttribute>(); | |
return attribute?.Version; | |
}); | |
private static readonly Lazy<string> _informationVersion = new(() => | |
{ | |
var assembly = typeof(AssemblyMetadata).Assembly; | |
var attribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>(); | |
return attribute?.InformationalVersion; | |
}); | |
private static readonly Lazy<string> _assemblyDescription = new(() => | |
{ | |
var assembly = typeof(AssemblyMetadata).Assembly; | |
var attribute = assembly.GetCustomAttribute<AssemblyDescriptionAttribute>(); | |
return attribute?.Description; | |
}); | |
private static readonly Lazy<string> _assemblyName = new(() => | |
{ | |
var assembly = typeof(AssemblyMetadata).Assembly; | |
return assembly.GetName().Name; | |
}); | |
public static string FileVersion => _fileVersion.Value; | |
public static string AssemblyVersion => _assemblyVersion.Value; | |
public static string AssemblyDescription => _assemblyDescription.Value; | |
public static string AssemblyName => _assemblyName.Value; | |
public static string InformationalVersion => _informationVersion.Value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment