Skip to content

Commit

Permalink
Version returns "Unknown" if the AssemblyFileVersionAttribute is not …
Browse files Browse the repository at this point in the history
…found.
  • Loading branch information
Patrick committed Mar 2, 2022
1 parent 9bbf685 commit 653c9d7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Markdig/Markdown.cs
Expand Up @@ -4,6 +4,7 @@

using System;
using System.IO;
using System.Linq;
using System.Reflection;
using Markdig.Extensions.SelfPipeline;
using Markdig.Helpers;
Expand All @@ -19,7 +20,16 @@ namespace Markdig
/// </summary>
public static partial class Markdown
{
public static readonly string Version = ((AssemblyFileVersionAttribute) typeof(Markdown).Assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false)[0]).Version;
public static string Version
{
get
{
if (_Version == null)
_Version = ((AssemblyFileVersionAttribute)typeof(Markdown).Assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false).FirstOrDefault())?.Version ?? "Unknown";
return _Version;
}
}
private static string? _Version;

internal static readonly MarkdownPipeline DefaultPipeline = new MarkdownPipelineBuilder().Build();
private static readonly MarkdownPipeline _defaultTrackTriviaPipeline = new MarkdownPipelineBuilder().EnableTrackTrivia().Build();
Expand Down

0 comments on commit 653c9d7

Please sign in to comment.