Skip to content

Commit

Permalink
Use different extension Uid for MSTest.Sdk (#2648)
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelink committed Apr 3, 2024
1 parent cc19ee3 commit c3973e8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !WINDOWS_UWP
using System.Reflection;

using Microsoft.Testing.Platform.Extensions;

namespace Microsoft.VisualStudio.TestTools.UnitTesting;

internal sealed class MSTestExtension : IExtension
{
public string Uid => nameof(MSTestExtension);
public string Uid { get; } = GetExtensionUid();

public string DisplayName => "MSTest";

Expand All @@ -17,5 +19,11 @@ internal sealed class MSTestExtension : IExtension
public string Description => "MSTest Framework for Microsoft Testing Platform";

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

private static string GetExtensionUid()
{
var assemblyMetadataAttributes = Assembly.GetEntryAssembly()?.GetCustomAttributes<AssemblyMetadataAttribute>();
return assemblyMetadataAttributes?.FirstOrDefault(x => x.Key == "MSTest.Extension.Uid")?.Value ?? nameof(MSTestExtension);
}
}
#endif
4 changes: 4 additions & 0 deletions src/Package/MSTest.Sdk/Sdk/Runner/Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@
<MicrosoftTestingExtensionsCodeCoverageVersion Condition=" '$(MicrosoftTestingExtensionsCodeCoverageVersion)' == '' " >$(MicrosoftTestingExtensionsCodeCoverageVersion)</MicrosoftTestingExtensionsCodeCoverageVersion>
</PropertyGroup>

<ItemGroup>
<AssemblyMetadata Include="MSTest.Extension.Uid" Value="MSTest.Sdk" />
</ItemGroup>

</Project>

0 comments on commit c3973e8

Please sign in to comment.