diff --git a/src/NUnitTestAdapter/TestingPlatformAdapter/NUnitExtension.cs b/src/NUnitTestAdapter/TestingPlatformAdapter/NUnitExtension.cs index d5b1f35c..945db332 100644 --- a/src/NUnitTestAdapter/TestingPlatformAdapter/NUnitExtension.cs +++ b/src/NUnitTestAdapter/TestingPlatformAdapter/NUnitExtension.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.Reflection; +using System.Threading.Tasks; using Microsoft.Testing.Platform.Extensions; @@ -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 IsEnabledAsync() => Task.FromResult(true); + + private static string GetAssemblyVersion() + { + var assembly = typeof(NUnitExtension).Assembly; + var version = assembly.GetCustomAttribute()?.InformationalVersion + ?? assembly.GetName().Version?.ToString(); + return version; + } } }