Skip to content

Commit c3973e8

Browse files
authored
Use different extension Uid for MSTest.Sdk (#2648)
1 parent cc19ee3 commit c3973e8

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestExtension.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
#if !WINDOWS_UWP
5+
using System.Reflection;
6+
57
using Microsoft.Testing.Platform.Extensions;
68

79
namespace Microsoft.VisualStudio.TestTools.UnitTesting;
810

911
internal sealed class MSTestExtension : IExtension
1012
{
11-
public string Uid => nameof(MSTestExtension);
13+
public string Uid { get; } = GetExtensionUid();
1214

1315
public string DisplayName => "MSTest";
1416

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

1921
public Task<bool> IsEnabledAsync() => Task.FromResult(true);
22+
23+
private static string GetExtensionUid()
24+
{
25+
var assemblyMetadataAttributes = Assembly.GetEntryAssembly()?.GetCustomAttributes<AssemblyMetadataAttribute>();
26+
return assemblyMetadataAttributes?.FirstOrDefault(x => x.Key == "MSTest.Extension.Uid")?.Value ?? nameof(MSTestExtension);
27+
}
2028
}
2129
#endif

src/Package/MSTest.Sdk/Sdk/Runner/Common.targets

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,8 @@
2626
<MicrosoftTestingExtensionsCodeCoverageVersion Condition=" '$(MicrosoftTestingExtensionsCodeCoverageVersion)' == '' " >$(MicrosoftTestingExtensionsCodeCoverageVersion)</MicrosoftTestingExtensionsCodeCoverageVersion>
2727
</PropertyGroup>
2828

29+
<ItemGroup>
30+
<AssemblyMetadata Include="MSTest.Extension.Uid" Value="MSTest.Sdk" />
31+
</ItemGroup>
32+
2933
</Project>

0 commit comments

Comments
 (0)