diff --git a/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs b/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs index 0193c4ebb4..89c9c66ab6 100644 --- a/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs +++ b/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs @@ -97,11 +97,7 @@ private static bool TryAddFakesDataCollectorSettings( IEnumerable sources, FrameworkVersion framework) { - // A new Fakes Configurator API makes the decision to add the right datacollector uri to the configuration - // There now exist two data collector URIs to support two different scenarios. The new scenario involves - // using the CLRIE profiler, and the old involves using the Intellitrace profiler (which isn't supported in - // .NET Core scenarios). The old API still exists for fallback measures. - + // Only cross-platform (v2) Fakes is supported. Fallback to v1 is removed. var crossPlatformConfigurator = TryGetFakesCrossPlatformDataCollectorConfigurator(); if (crossPlatformConfigurator != null) { @@ -118,7 +114,8 @@ private static bool TryAddFakesDataCollectorSettings( return true; } - return AddFallbackFakesSettings(runSettings, sources, framework); + // Fakes v1 fallback support removed. + return false; } internal static void InsertOrReplaceFakesDataCollectorNode(XmlDocument runSettings, DataCollectorSettings settings) @@ -157,55 +154,6 @@ private static IDictionary CreateDictionary(IEnumerabl return dict; } - private static bool AddFallbackFakesSettings( - XmlDocument runSettings, - IEnumerable sources, - FrameworkVersion framework) - { - - // The fallback settings is for the old implementation of fakes - // that only supports .Net Framework versions - if (framework - is not FrameworkVersion.Framework35 - and not FrameworkVersion.Framework40 - and not FrameworkVersion.Framework45) - { - return false; - } - - Func, string>? netFrameworkConfigurator = TryGetNetFrameworkFakesDataCollectorConfigurator(); - if (netFrameworkConfigurator == null) - { - return false; - } - - // if no fakes, return settings unchanged - var fakesConfiguration = netFrameworkConfigurator(sources); - if (fakesConfiguration == null) - { - return false; - } - - // integrate fakes settings in configuration - // if the settings don't have any data collector settings, populate with empty settings - EnsureSettingsNode(runSettings, new DataCollectionRunSettings()); - - // embed fakes settings - var fakesSettings = CreateFakesDataCollectorSettings(); - var doc = new XmlDocument(); - using (var xmlReader = XmlReader.Create( - new StringReader(fakesConfiguration), - new XmlReaderSettings() { CloseInput = true })) - { - doc.Load(xmlReader); - } - - fakesSettings.Configuration = doc.DocumentElement; - XmlRunSettingsUtilities.InsertDataCollectorsNode(runSettings.CreateNavigator()!, fakesSettings); - - return true; - } - /// /// Ensures that an xml element corresponding to the test run settings exists in the setting document. /// @@ -225,27 +173,6 @@ private static void EnsureSettingsNode(XmlDocument settings, TestRunSettings set } } - private static Func, string>? TryGetNetFrameworkFakesDataCollectorConfigurator() - { -#if NETFRAMEWORK - try - { - var assembly = LoadTestPlatformAssembly(); - var type = assembly?.GetType(ConfiguratorAssemblyQualifiedName, false); - var method = type?.GetMethod(NetFrameworkConfiguratorMethodName, [typeof(IEnumerable)]); - if (method != null) - { - return (Func, string>)method.CreateDelegate(typeof(Func, string>)); - } - } - catch (Exception ex) - { - EqtTrace.Info("Failed to create Fakes Configurator. Reason:{0} ", ex); - } -#endif - return null; - } - private static Func, DataCollectorSettings>? TryGetFakesCrossPlatformDataCollectorConfigurator() { try @@ -279,25 +206,6 @@ private static void EnsureSettingsNode(XmlDocument settings, TestRunSettings set return null; } - /// - /// Adds the Fakes data collector settings in the run settings document. - /// - /// - /// The . - /// - private static DataCollectorSettings CreateFakesDataCollectorSettings() - { - // embed the fakes run settings - var settings = new DataCollectorSettings - { - AssemblyQualifiedName = FakesMetadata.DataCollectorAssemblyQualifiedName, - FriendlyName = FakesMetadata.FriendlyName, - IsEnabled = true, - Uri = new Uri(FakesMetadata.DataCollectorUriV1) - }; - return settings; - } - internal static class FakesMetadata { /// @@ -306,12 +214,12 @@ internal static class FakesMetadata public const string FriendlyName = "UnitTestIsolation"; /// - /// Gets the URI of the data collector + /// Gets the URI of the data collector (V1, deprecated and removed) /// public const string DataCollectorUriV1 = "datacollector://microsoft/unittestisolation/1.0"; /// - /// Gets the URI of the data collector + /// Gets the URI of the data collector (V2) /// public const string DataCollectorUriV2 = "datacollector://microsoft/unittestisolation/2.0";