RSCG- AppVersion–part 2
name | ThisAssembly |
nuget | https://www.nuget.org/packages/ThisAssembly |
link | https://www.clarius.org/ThisAssembly/ |
author | Daniel Cazzulino |
The ThisAssembly.Info allows you access to the Assembly Information as constants, instead of going to reflection each time. I found useful to see the assembly version right away in any project that I have.
The code that you start with is in .csproj
<PropertyGroup>
<Version>2021.2.15.800</Version>
</PropertyGroup>
The code that you will use is
1 2 | var strVersion = ThisAssembly.Info.Version; Console.WriteLine(strVersion); |
The code that is generated is
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /// <summary> /// Provides access to the current assembly information as pure constants, /// without requiring reflection. /// </summary> partial class ThisAssembly { /// <summary> /// Gets the AssemblyInfo attributes. /// </summary> [GeneratedCode( "ThisAssembly.AssemblyInfo" , "1.0.0" )] [CompilerGenerated] public static partial class Info { public const string Company = @"RSCG_Version" ; public const string Configuration = @"Debug" ; public const string FileVersion = @"2021.2.15.800" ; public const string InformationalVersion = @"2021.2.15.800" ; public const string Product = @"RSCG_Version" ; public const string Title = @"RSCG_Version" ; public const string Version = @"2021.2.15.800" ; } } |
Example Code: https://github.com/ignatandrei/RSCG_Examples/tree/main/ApplicationVersion
Leave a Reply