Skip to content

Commit

Permalink
Fix NUnit extension version
Browse files Browse the repository at this point in the history
Use AssemblyInformationalVersionAttribute version or fallback to
AssemblyVersion instead of using hardcoded version.
  • Loading branch information
Evangelink committed May 6, 2024
1 parent 4010a76 commit 2919fcf
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/NUnitTestAdapter/TestingPlatformAdapter/NUnitExtension.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System.Reflection;
using System.Threading.Tasks;

using Microsoft.Testing.Platform.Extensions;

Expand All @@ -10,11 +11,18 @@ internal sealed class NUnitExtension : IExtension

public string DisplayName => "NUnit";

// TODO: Decide whether to read from assembly or use hardcoded string.
public string Version => "4.5.0";
public string Version { get; } = GetAssemblyVersion();

public string Description => "NUnit adapter for Microsoft Testing Platform";

public Task<bool> IsEnabledAsync() => Task.FromResult(true);

private static string GetAssemblyVersion()
{
var assembly = typeof(NUnitExtension).Assembly;
var version = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion
?? assembly.GetName().Version?.ToString();
return version;
}
}
}

0 comments on commit 2919fcf

Please sign in to comment.