From 5887699f060411bdc6bcd915bf22723e5407073c Mon Sep 17 00:00:00 2001 From: Jakub Jares Date: Thu, 14 May 2026 14:07:19 +0200 Subject: [PATCH] Revert dependency tracking telemetry Cherry-pick of a74013a49 from main. The TrackProvidedDependency mechanism was proven unuseful - OnResolve never fires for the tracked assemblies because they load via normal CLR probing. This also removes the RequestingAssembly property that causes MissingMethodException with older xunit adapters (#15765). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Execution/TestRunRequest.cs | 37 --------- .../Resources/Resources.Designer.cs | 11 --- .../Resources/Resources.resx | 3 - .../Resources/xlf/Resources.cs.xlf | 7 +- .../Resources/xlf/Resources.de.xlf | 7 +- .../Resources/xlf/Resources.es.xlf | 7 +- .../Resources/xlf/Resources.fr.xlf | 7 +- .../Resources/xlf/Resources.it.xlf | 7 +- .../Resources/xlf/Resources.ja.xlf | 7 +- .../Resources/xlf/Resources.ko.xlf | 7 +- .../Resources/xlf/Resources.pl.xlf | 7 +- .../Resources/xlf/Resources.pt-BR.xlf | 7 +- .../Resources/xlf/Resources.ru.xlf | 7 +- .../Resources/xlf/Resources.tr.xlf | 7 +- .../Resources/xlf/Resources.zh-Hans.xlf | 7 +- .../Resources/xlf/Resources.zh-Hant.xlf | 7 +- .../Telemetry/TelemetryDataConstants.cs | 7 -- .../Utilities/AssemblyResolver.cs | 77 ------------------- .../FeatureFlag/FeatureFlag.cs | 8 -- .../Interfaces/Runtime/IAssemblyResolver.cs | 5 -- .../PublicAPI/PublicAPI.Unshipped.txt | 2 - .../Runtime/PlatformAssemblyResolver.cs | 2 +- .../NewtonSoftDependencyMissing.csproj | 26 ------- .../NewtonSoftDependencyMissing/UnitTest1.cs | 32 -------- 24 files changed, 14 insertions(+), 287 deletions(-) delete mode 100644 test/TestAssets/NewtonSoftDependencyMissing/NewtonSoftDependencyMissing.csproj delete mode 100644 test/TestAssets/NewtonSoftDependencyMissing/UnitTest1.cs diff --git a/src/Microsoft.TestPlatform.Client/Execution/TestRunRequest.cs b/src/Microsoft.TestPlatform.Client/Execution/TestRunRequest.cs index d6f71780ee..b7b65dc764 100644 --- a/src/Microsoft.TestPlatform.Client/Execution/TestRunRequest.cs +++ b/src/Microsoft.TestPlatform.Client/Execution/TestRunRequest.cs @@ -13,7 +13,6 @@ using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; -using Microsoft.VisualStudio.TestPlatform.Common.Utilities; using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; @@ -441,42 +440,6 @@ public void HandleTestRunComplete(TestRunCompleteEventArgs runCompleteArgs, Test // Fill in the time taken to complete the run _requestData.MetricsCollection.Add(TelemetryDataConstants.TimeTakenInSecForRun, executionTotalTimeTaken.TotalSeconds); - // Record assemblies that vstest provided from its search directories. - // Telemetry gets 2 properties: assemblies resolved for user code (count only, - // no user assembly names), and assemblies resolved for Microsoft/System code (names ok). - var (userAssemblies, userCount, msAssemblies, msCount) = AssemblyResolver.GetProvidedDependencySummary(); - if (userCount > 0) - { - _requestData.MetricsCollection.Add(TelemetryDataConstants.ProvidedDependenciesForUser, userAssemblies); - _requestData.MetricsCollection.Add(TelemetryDataConstants.ProvidedDependenciesForUserCount, userCount); - } - if (msCount > 0) - { - _requestData.MetricsCollection.Add(TelemetryDataConstants.ProvidedDependenciesForMicrosoft, msAssemblies); - _requestData.MetricsCollection.Add(TelemetryDataConstants.ProvidedDependenciesForMicrosoftCount, msCount); - } - - // Opt-in warning: show all provided assemblies in summary when feature flag is set. - // Disable flag takes precedence over opt-in. - if ((userCount > 0 || msCount > 0) - && !FeatureFlag.Instance.IsSet(FeatureFlag.VSTEST_DISABLE_WARN_MISSING_EXTENSIONS_DEPENDENCIES) - && FeatureFlag.Instance.IsSet(FeatureFlag.VSTEST_OPTIN_WARN_MISSING_EXTENSIONS_DEPENDENCIES)) - { - var allAssemblies = new HashSet(StringComparer.OrdinalIgnoreCase); - foreach (var kvp in AssemblyResolver.GetProvidedDependencies()) - { - allAssemblies.Add(kvp.Key); - } - - var message = string.Format( - CultureInfo.CurrentCulture, - ClientResources.ProvidedDependenciesWarning, - string.Join(", ", allAssemblies)); - - LoggerManager.HandleTestRunMessage( - new TestRunMessageEventArgs(TestMessageLevel.Warning, message)); - } - // Fill in the Metrics From Test Host Process var metrics = runCompleteArgs.Metrics; if (metrics != null && metrics.Count != 0) diff --git a/src/Microsoft.TestPlatform.Client/Resources/Resources.Designer.cs b/src/Microsoft.TestPlatform.Client/Resources/Resources.Designer.cs index 70f520de5f..f2a459c569 100644 --- a/src/Microsoft.TestPlatform.Client/Resources/Resources.Designer.cs +++ b/src/Microsoft.TestPlatform.Client/Resources/Resources.Designer.cs @@ -99,16 +99,5 @@ internal static string NoTestHostProviderFound return ResourceManager.GetString("NoTestHostProviderFound", resourceCulture); } } - - /// - /// Looks up a localized string similar to The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies.. - /// - internal static string ProvidedDependenciesWarning - { - get - { - return ResourceManager.GetString("ProvidedDependenciesWarning", resourceCulture); - } - } } } diff --git a/src/Microsoft.TestPlatform.Client/Resources/Resources.resx b/src/Microsoft.TestPlatform.Client/Resources/Resources.resx index 94f9fd8fb3..16df9c4cf7 100644 --- a/src/Microsoft.TestPlatform.Client/Resources/Resources.resx +++ b/src/Microsoft.TestPlatform.Client/Resources/Resources.resx @@ -129,7 +129,4 @@ Wait for completion operation is not allowed when there is no active test run. - - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.cs.xlf b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.cs.xlf index 3b6c96dac6..a6f5639990 100644 --- a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.cs.xlf +++ b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.cs.xlf @@ -1,4 +1,4 @@ - + @@ -7,11 +7,6 @@ Testovací běh nešlo spustit, protože byl neplatný počáteční stav. - - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - - Wait for completion operation is not allowed when there is no active test run. V případě, že nejsou aktivní žádné testovací běhy, se operace čekání na dokončení nepovoluje. diff --git a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.de.xlf b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.de.xlf index 976ea66979..738dcf18b8 100644 --- a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.de.xlf +++ b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.de.xlf @@ -1,4 +1,4 @@ - + @@ -7,11 +7,6 @@ Der Testlauf konnte nicht ausgeführt werden, weil der Anfangszustand ungültig war. - - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - - Wait for completion operation is not allowed when there is no active test run. Das Warten auf den Fertigstellungsvorgang ist unzulässig, wenn kein aktiver Testlauf vorhanden ist. diff --git a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.es.xlf b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.es.xlf index 683f309007..f62e1af154 100644 --- a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.es.xlf +++ b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.es.xlf @@ -1,4 +1,4 @@ - + @@ -7,11 +7,6 @@ No se pudo ejecutar la serie de pruebas porque el estado inicial no era válido. - - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - - Wait for completion operation is not allowed when there is no active test run. La operación “Esperar que termine” no se permite cuando no hay ninguna serie de pruebas activa. diff --git a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.fr.xlf b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.fr.xlf index d48c2349c8..385d2c0c98 100644 --- a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.fr.xlf +++ b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.fr.xlf @@ -1,4 +1,4 @@ - + @@ -7,11 +7,6 @@ Impossible d'exécuter la série de tests, car l'état initial est non valide. - - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - - Wait for completion operation is not allowed when there is no active test run. L'attente de la fin de l'exécution d'une opération n'est pas autorisée quand il n'existe aucune série de tests active. diff --git a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.it.xlf b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.it.xlf index 3afc655cc4..d412aadcaa 100644 --- a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.it.xlf +++ b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.it.xlf @@ -1,4 +1,4 @@ - + @@ -7,11 +7,6 @@ Non è stato possibile completare l'esecuzione dei test perché lo stato iniziale non era valido. - - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - - Wait for completion operation is not allowed when there is no active test run. L'operazione di attesa completamento non è consentita se non sono presenti esecuzioni dei test attive. diff --git a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.ja.xlf b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.ja.xlf index 0008162055..1765c355ed 100644 --- a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.ja.xlf +++ b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.ja.xlf @@ -1,4 +1,4 @@ - + @@ -7,11 +7,6 @@ 初期状態が無効なため、テストの実行を実行できませんでした。 - - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - - Wait for completion operation is not allowed when there is no active test run. アクティブなテストの実行がない場合、完了の待機操作は許可されません。 diff --git a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.ko.xlf b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.ko.xlf index a5ac1c5a18..13daa6986b 100644 --- a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.ko.xlf +++ b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.ko.xlf @@ -1,4 +1,4 @@ - + @@ -7,11 +7,6 @@ 초기 상태가 잘못되어 테스트 실행을 실행할 수 없습니다. - - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - - Wait for completion operation is not allowed when there is no active test run. 활성 테스트 실행이 없으면 완료 작업을 대기할 수 없습니다. diff --git a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.pl.xlf b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.pl.xlf index f15748c08d..af1327bc6c 100644 --- a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.pl.xlf +++ b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.pl.xlf @@ -1,4 +1,4 @@ - + @@ -7,11 +7,6 @@ Nie można wykonać przebiegu testu, ponieważ stan początkowy jest nieprawidłowy. - - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - - Wait for completion operation is not allowed when there is no active test run. Oczekiwanie na operację zakończenia nie jest dozwolone, gdy nie ma aktywnego przebiegu testu. diff --git a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.pt-BR.xlf b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.pt-BR.xlf index 0619c7d3c6..9c03089380 100644 --- a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.pt-BR.xlf +++ b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.pt-BR.xlf @@ -1,4 +1,4 @@ - + @@ -7,11 +7,6 @@ A execução de teste não pôde ser realizada porque o estado inicial era inválido. - - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - - Wait for completion operation is not allowed when there is no active test run. A operação esperar conclusão não é permitida quando não há nenhuma execução de teste ativa. diff --git a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.ru.xlf b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.ru.xlf index f9a2796788..15eea1c74c 100644 --- a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.ru.xlf +++ b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.ru.xlf @@ -1,4 +1,4 @@ - + @@ -7,11 +7,6 @@ Не удалось выполнить тестовый запуск из-за недопустимого начального состояния. - - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - - Wait for completion operation is not allowed when there is no active test run. Операция "Ожидать завершения" запрещена, если нет активного тестового запуска. diff --git a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.tr.xlf b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.tr.xlf index 8fdcc4b524..038b50e60d 100644 --- a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.tr.xlf +++ b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.tr.xlf @@ -1,4 +1,4 @@ - + @@ -7,11 +7,6 @@ İlk durum geçersiz olduğundan test çalıştırması yürütülemedi. - - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - - Wait for completion operation is not allowed when there is no active test run. Etkin bir test çalıştırması olmadığında tamamlanmasını bekleme işlemine izin verilmez. diff --git a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.zh-Hans.xlf b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.zh-Hans.xlf index 36e3cb06d4..9d11a82f1e 100644 --- a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.zh-Hans.xlf @@ -1,4 +1,4 @@ - + @@ -7,11 +7,6 @@ 由于初始状态无效,无法执行测试运行。 - - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - - Wait for completion operation is not allowed when there is no active test run. 没有活动的测试运行时不允许等待完成操作。 diff --git a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.zh-Hant.xlf b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.zh-Hant.xlf index bc5b6b5e41..0b66e40635 100644 --- a/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/Microsoft.TestPlatform.Client/Resources/xlf/Resources.zh-Hant.xlf @@ -1,4 +1,4 @@ - + @@ -7,11 +7,6 @@ 因為初始狀態無效,所以無法執行測試回合。 - - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - The test platform provided the following assemblies to resolve dependencies of test extensions that did not ship their own copy: {0}. Test extensions should ship all their dependencies. - - Wait for completion operation is not allowed when there is no active test run. 沒有使用中的測試回合時,不允許等候完成作業。 diff --git a/src/Microsoft.TestPlatform.Common/Telemetry/TelemetryDataConstants.cs b/src/Microsoft.TestPlatform.Common/Telemetry/TelemetryDataConstants.cs index f10565dbee..a864b79b3b 100644 --- a/src/Microsoft.TestPlatform.Common/Telemetry/TelemetryDataConstants.cs +++ b/src/Microsoft.TestPlatform.Common/Telemetry/TelemetryDataConstants.cs @@ -11,13 +11,6 @@ internal static class TelemetryDataConstants // ******************** General *********************** public static readonly string DiscoveredExtensions = "VS.TestPlatform.DiscoveredExtensions"; - // Tracks assemblies that vstest provided from its search directories to resolve - // extension dependencies. Separated by requester type for privacy. - public static readonly string ProvidedDependenciesForUser = "VS.TestPlatform.ProvidedDeps.User"; - public static readonly string ProvidedDependenciesForUserCount = "VS.TestPlatform.ProvidedDeps.User.Count"; - public static readonly string ProvidedDependenciesForMicrosoft = "VS.TestPlatform.ProvidedDeps.Microsoft"; - public static readonly string ProvidedDependenciesForMicrosoftCount = "VS.TestPlatform.ProvidedDeps.Microsoft.Count"; - // ******************** Execution *********************** public static readonly string ParallelEnabledDuringExecution = "VS.TestRun.ParallelEnabled"; diff --git a/src/Microsoft.TestPlatform.Common/Utilities/AssemblyResolver.cs b/src/Microsoft.TestPlatform.Common/Utilities/AssemblyResolver.cs index 08544e23aa..6682231730 100644 --- a/src/Microsoft.TestPlatform.Common/Utilities/AssemblyResolver.cs +++ b/src/Microsoft.TestPlatform.Common/Utilities/AssemblyResolver.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -43,54 +42,6 @@ internal class AssemblyResolver : IDisposable private static readonly string[] SupportedFileExtensions = [".dll", ".exe"]; - /// - /// Tracks all assemblies that vstest resolved from its own search directories on behalf of - /// external code. Each entry: assembly name → list of requesting assembly names. - /// - private static readonly ConcurrentDictionary> ProvidedDependencies = new(StringComparer.OrdinalIgnoreCase); - - /// - /// Gets the assemblies that vstest provided from its search directories to resolve - /// dependencies of other assemblies. - /// - internal static IReadOnlyDictionary> GetProvidedDependencies() => ProvidedDependencies; - - /// - /// Builds telemetry-safe summary of provided dependencies. - /// Splits into user-requested (count only) and Microsoft/System-requested (names). - /// - internal static (string assembliesForUser, int userRequestCount, string assembliesForMicrosoft, int microsoftRequestCount) GetProvidedDependencySummary() - { - var userAssemblies = new HashSet(StringComparer.OrdinalIgnoreCase); - int userCount = 0; - var msAssemblies = new HashSet(StringComparer.OrdinalIgnoreCase); - int msCount = 0; - - foreach (var kvp in ProvidedDependencies) - { - foreach (var requester in kvp.Value) - { - if (requester.StartsWith("Microsoft.", StringComparison.OrdinalIgnoreCase) - || requester.StartsWith("System.", StringComparison.OrdinalIgnoreCase)) - { - msAssemblies.Add(kvp.Key); - msCount++; - } - else - { - userAssemblies.Add(kvp.Key); - userCount++; - } - } - } - - return ( - string.Join("|", userAssemblies), - userCount, - string.Join("|", msAssemblies), - msCount); - } - /// /// Initializes a new instance of the class. /// @@ -228,8 +179,6 @@ internal void AddSearchDirectories(IEnumerable directories) assembly = _platformAssemblyLoadContext.LoadAssemblyFromPath(assemblyPath); _resolvedAssemblies[args.Name] = assembly; - TrackProvidedDependency(requestedName, assemblyPath, args.RequestingAssembly); - EqtTrace.Info("AssemblyResolver.OnResolve: Resolved assembly: {0}, from path: {1}", args.Name, assemblyPath); return assembly; @@ -267,32 +216,6 @@ internal void AddSearchDirectories(IEnumerable directories) } } - /// - /// When we resolve an assembly from vstest's search directories for an external requester, - /// record it so telemetry can report which dependencies vstest is providing. - /// - private void TrackProvidedDependency(AssemblyName requestedName, string resolvedPath, Assembly? requestingAssembly) - { - if (requestedName.Name is null) - { - return; - } - - // Only track if we resolved from one of OUR search directories. - var resolvedDir = Path.GetDirectoryName(resolvedPath); - if (resolvedDir is null || !_searchDirectories.Contains(resolvedDir)) - { - return; - } - - var requester = requestingAssembly?.GetName().Name ?? "unknown"; - var bag = ProvidedDependencies.GetOrAdd(requestedName.Name, _ => new ConcurrentBag()); - bag.Add(requester); - - EqtTrace.Info("AssemblyResolver.TrackProvidedDependency: Resolved '{0}' from '{1}' for '{2}'.", - requestedName.Name, resolvedDir, requester); - } - /// /// Verifies that found assembly name matches requested to avoid security issues. /// Looks only at PublicKeyToken and Version, empty matches anything. diff --git a/src/Microsoft.TestPlatform.CoreUtilities/FeatureFlag/FeatureFlag.cs b/src/Microsoft.TestPlatform.CoreUtilities/FeatureFlag/FeatureFlag.cs index d7c7403f74..6479267683 100644 --- a/src/Microsoft.TestPlatform.CoreUtilities/FeatureFlag/FeatureFlag.cs +++ b/src/Microsoft.TestPlatform.CoreUtilities/FeatureFlag/FeatureFlag.cs @@ -78,14 +78,6 @@ private FeatureFlag() { } // Disable turning dynamic code coverage for native code to OFF by default. Setting this to 1 will skip adding the setting. public const string VSTEST_DISABLE_DYNAMICNATIVE_CODECOVERAGE_DEFAULT_SETTING = nameof(VSTEST_DISABLE_DYNAMICNATIVE_CODECOVERAGE_DEFAULT_SETTING); - // When set, warns when vstest provides its own copy of a tracked assembly (e.g. Newtonsoft.Json) - // to resolve a dependency of an extension that did not ship its own copy. - // Set VSTEST_OPTIN_WARN_MISSING_EXTENSIONS_DEPENDENCIES=1 to opt into warnings before enforcement. - public const string VSTEST_OPTIN_WARN_MISSING_EXTENSIONS_DEPENDENCIES = nameof(VSTEST_OPTIN_WARN_MISSING_EXTENSIONS_DEPENDENCIES); - - // Disables the warning about missing extension dependencies, even after enforcement. - public const string VSTEST_DISABLE_WARN_MISSING_EXTENSIONS_DEPENDENCIES = nameof(VSTEST_DISABLE_WARN_MISSING_EXTENSIONS_DEPENDENCIES); - [Obsolete("Only use this in tests.")] diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Runtime/IAssemblyResolver.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Runtime/IAssemblyResolver.cs index d5222e79e5..10ab276d2b 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Runtime/IAssemblyResolver.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Runtime/IAssemblyResolver.cs @@ -46,9 +46,4 @@ public AssemblyResolveEventArgs(string? name) /// Gets or sets the name of the item to resolve. /// public string? Name { get; set; } - - /// - /// Gets or sets the assembly that requested the resolution, if available. - /// - public Assembly? RequestingAssembly { get; set; } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/PublicAPI/PublicAPI.Unshipped.txt b/src/Microsoft.TestPlatform.PlatformAbstractions/PublicAPI/PublicAPI.Unshipped.txt index 76ce48e577..ab058de62d 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/PublicAPI/PublicAPI.Unshipped.txt +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/PublicAPI/PublicAPI.Unshipped.txt @@ -1,3 +1 @@ #nullable enable -Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces.AssemblyResolveEventArgs.RequestingAssembly.get -> System.Reflection.Assembly? -Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces.AssemblyResolveEventArgs.RequestingAssembly.set -> void diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/net462/Runtime/PlatformAssemblyResolver.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/net462/Runtime/PlatformAssemblyResolver.cs index 78db3c5241..4b581d0ef0 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/net462/Runtime/PlatformAssemblyResolver.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/net462/Runtime/PlatformAssemblyResolver.cs @@ -69,7 +69,7 @@ protected virtual void Dispose(bool disposing) /// private Assembly? AssemblyResolverEvent(object sender, object eventArgs) { - return eventArgs is not ResolveEventArgs args ? null : AssemblyResolve?.Invoke(this, new AssemblyResolveEventArgs(args.Name) { RequestingAssembly = args.RequestingAssembly }); + return eventArgs is not ResolveEventArgs args ? null : AssemblyResolve?.Invoke(this, new AssemblyResolveEventArgs(args.Name)); } } diff --git a/test/TestAssets/NewtonSoftDependencyMissing/NewtonSoftDependencyMissing.csproj b/test/TestAssets/NewtonSoftDependencyMissing/NewtonSoftDependencyMissing.csproj deleted file mode 100644 index 3a1f9440a1..0000000000 --- a/test/TestAssets/NewtonSoftDependencyMissing/NewtonSoftDependencyMissing.csproj +++ /dev/null @@ -1,26 +0,0 @@ - - - - - true - true - - - - NewtonSoftDependencyMissing - $(NetFrameworkTargetFrameworks) - Exe - - - - - - - - runtime - - - - diff --git a/test/TestAssets/NewtonSoftDependencyMissing/UnitTest1.cs b/test/TestAssets/NewtonSoftDependencyMissing/UnitTest1.cs deleted file mode 100644 index 0b760a7e9b..0000000000 --- a/test/TestAssets/NewtonSoftDependencyMissing/UnitTest1.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.VisualStudio.TestTools.UnitTesting; - -using Newtonsoft.Json; - -namespace NewtonSoftDependencyMissing; - -public class Account -{ - public string Email { get; set; } - public bool Active { get; set; } -} - -[TestClass] -public class UnitTest1 -{ - [TestMethod] - public void TestUsingNewtonsoftWithoutShippingDll() - { - // This test uses Newtonsoft.Json but the project excludes the runtime asset. - // At runtime, Newtonsoft.Json.dll is NOT present next to this assembly, - // so vstest's own copy is used. This should be tracked in telemetry. - string json = @"{""Email"": ""john@example.com"", ""Active"": true}"; - - Account account = JsonConvert.DeserializeObject(json); - - Assert.IsNotNull(account); - Assert.AreEqual("john@example.com", account.Email); - } -}