From c3973e8f26f9451b7873295ed4e812f5871afcba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Wed, 3 Apr 2024 18:09:30 +0200 Subject: [PATCH] Use different extension Uid for MSTest.Sdk (#2648) --- .../TestingPlatformAdapter/MSTestExtension.cs | 10 +++++++++- src/Package/MSTest.Sdk/Sdk/Runner/Common.targets | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestExtension.cs b/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestExtension.cs index 986b890d49..0f354eeb9f 100644 --- a/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestExtension.cs +++ b/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestExtension.cs @@ -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"; @@ -17,5 +19,11 @@ internal sealed class MSTestExtension : IExtension public string Description => "MSTest Framework for Microsoft Testing Platform"; public Task IsEnabledAsync() => Task.FromResult(true); + + private static string GetExtensionUid() + { + var assemblyMetadataAttributes = Assembly.GetEntryAssembly()?.GetCustomAttributes(); + return assemblyMetadataAttributes?.FirstOrDefault(x => x.Key == "MSTest.Extension.Uid")?.Value ?? nameof(MSTestExtension); + } } #endif diff --git a/src/Package/MSTest.Sdk/Sdk/Runner/Common.targets b/src/Package/MSTest.Sdk/Sdk/Runner/Common.targets index 9dec46ae83..6ba232002f 100644 --- a/src/Package/MSTest.Sdk/Sdk/Runner/Common.targets +++ b/src/Package/MSTest.Sdk/Sdk/Runner/Common.targets @@ -26,4 +26,8 @@ $(MicrosoftTestingExtensionsCodeCoverageVersion) + + + +