Skip to content

Commit

Permalink
Added AssemblyExtensions
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaeldui committed Jan 13, 2022
1 parent c51ca21 commit 045d8cc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions DotNet.Extensions/DotNet.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<PackageLicenseExpression>Unlicense</PackageLicenseExpression>
<PackageIcon>Extensions-512x512.png</PackageIcon>
<AssemblyName>MikaelDui.Extensions</AssemblyName>
<Product>Mikael Dúi's .NET Extensions</Product>
</PropertyGroup>

<ItemGroup>
Expand Down
22 changes: 22 additions & 0 deletions DotNet.Extensions/Reflection/AssemblyExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

namespace System.Reflection
{
public static class AssemblyExtensions
{
/// <summary>
/// Like "1.2.3.0".
/// </summary>
public static string GetFileVersion(this Assembly assembly) =>
assembly.GetCustomAttribute<AssemblyFileVersionAttribute>().Version;

/// <summary>
/// Like "1.2.3+1a2b3c4d".
/// </summary>
public static string GetProductVersion(this Assembly assembly) =>
FileVersionInfo.GetVersionInfo(assembly.Location).ProductVersion;
}
}

0 comments on commit 045d8cc

Please sign in to comment.