From 49372652e45312d205d3da89da879129cc564418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Fri, 5 Aug 2022 17:31:36 +0900 Subject: [PATCH 1/5] [NativeAot] Triage another 14 libs tests --- .../tests/MemoryCacheSetAndRemoveTests.cs | 5 +++- .../tests/XmlConfigurationTest.cs | 1 + .../ConsoleLoggerExtensionsTests.cs | 1 + .../SimpleConsoleFormatterTests.cs | 1 + .../tests/EventSourceLoggerTest.cs | 3 +++ .../tests/EventLogMessagesTests.cs | 2 +- .../System.Diagnostics.EventLog.Tests.csproj | 1 + .../tests/ProcessModuleTests.Windows.cs | 2 +- .../tests/ProcessTests.cs | 2 +- .../System.Diagnostics.Process.Tests.csproj | 5 +++- .../tests/SortRequestControlTests.cs | 2 +- .../tests/Dataflow/DebugAttributeTests.cs | 4 +++- src/libraries/tests.proj | 23 ++++++++----------- 13 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Caching.Memory/tests/MemoryCacheSetAndRemoveTests.cs b/src/libraries/Microsoft.Extensions.Caching.Memory/tests/MemoryCacheSetAndRemoveTests.cs index 15ff4a158bd5fd..e7ac1edb71ece7 100644 --- a/src/libraries/Microsoft.Extensions.Caching.Memory/tests/MemoryCacheSetAndRemoveTests.cs +++ b/src/libraries/Microsoft.Extensions.Caching.Memory/tests/MemoryCacheSetAndRemoveTests.cs @@ -219,7 +219,10 @@ public void DisposingCacheEntryReleasesScope(bool trackLinkedCacheEntries) { object GetScope(ICacheEntry entry) { - return entry.GetType() + // Use Type.GetType so that trimming can know what type we operate on + Type cacheEntryType = Type.GetType("Microsoft.Extensions.Caching.Memory.CacheEntry, Microsoft.Extensions.Caching.Memory"); + Assert.Equal(cacheEntryType, entry.GetType()); + return cacheEntryType .GetField("_previous", BindingFlags.NonPublic | BindingFlags.Instance) .GetValue(entry); } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/tests/XmlConfigurationTest.cs b/src/libraries/Microsoft.Extensions.Configuration.Xml/tests/XmlConfigurationTest.cs index 96550f57d07789..9efd7cd087351d 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/tests/XmlConfigurationTest.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/tests/XmlConfigurationTest.cs @@ -704,6 +704,7 @@ public void XmlConfiguration_Does_Not_Throw_On_Optional_Configuration() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/73432", typeof(PlatformDetection), nameof(PlatformDetection.IsBuiltWithAggressiveTrimming))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public void LoadKeyValuePairsFromValidEncryptedXml() { diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerExtensionsTests.cs b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerExtensionsTests.cs index a89c53f5322a88..8f8dfd1e7d33c2 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerExtensionsTests.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerExtensionsTests.cs @@ -271,6 +271,7 @@ public void AddSystemdConsole_OutsideConfig_TakesProperty() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [ActiveIssue("https://github.com/dotnet/runtime/issues/73432", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public void AddJsonConsole_ChangeProperties_IsReadFromLoggingConfiguration() { var configuration = new ConfigurationBuilder().AddInMemoryCollection(new[] { diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/SimpleConsoleFormatterTests.cs b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/SimpleConsoleFormatterTests.cs index 46c88511870324..b27b5b519e0674 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/SimpleConsoleFormatterTests.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/SimpleConsoleFormatterTests.cs @@ -15,6 +15,7 @@ public class SimpleConsoleFormatterTests : ConsoleFormatterTests [InlineData(LoggerColorBehavior.Disabled)] [ActiveIssue("https://github.com/dotnet/runtime/issues/50575", TestPlatforms.Android)] [ActiveIssue("https://github.com/dotnet/runtime/issues/51398", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/73432", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public void Log_WritingScopes_LogsWithCorrectColorsWhenColorEnabled(LoggerColorBehavior colorBehavior) { // Arrange diff --git a/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs b/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs index 6a54f4f5e43b23..343036cca5b5ce 100644 --- a/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs +++ b/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs @@ -162,6 +162,7 @@ public void FilterSpecs_IncreaseLoggingLevelForOneCategory_DisablesExistingRules } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/73438", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public void Logs_AsExpected_WithDefaults() { using (var testListener = new TestEventListener()) @@ -195,6 +196,7 @@ public void Logs_AsExpected_WithDefaults() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/73438", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public void Logs_AsExpected_WithDefaults_EnabledEarly() { using (var testListener = new TestEventListener()) @@ -301,6 +303,7 @@ public void Logs_OnlyJson_IfKeywordSet() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/73438", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public void Logs_OnlyMessage_IfKeywordSet() { using (var testListener = new TestEventListener()) diff --git a/src/libraries/System.Diagnostics.EventLog/tests/EventLogMessagesTests.cs b/src/libraries/System.Diagnostics.EventLog/tests/EventLogMessagesTests.cs index ad205ced6c2f6b..a29dbc0dd17f08 100644 --- a/src/libraries/System.Diagnostics.EventLog/tests/EventLogMessagesTests.cs +++ b/src/libraries/System.Diagnostics.EventLog/tests/EventLogMessagesTests.cs @@ -20,7 +20,7 @@ public void EventLogMessagesContainsNoTypes() Assert.Empty(messageAssembly.GetTypes()); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.HasAssemblyFiles))] [InlineData(0)] [InlineData(1)] [InlineData(65535)] diff --git a/src/libraries/System.Diagnostics.EventLog/tests/System.Diagnostics.EventLog.Tests.csproj b/src/libraries/System.Diagnostics.EventLog/tests/System.Diagnostics.EventLog.Tests.csproj index f96d3e38fa1a36..6b2270e38c71eb 100644 --- a/src/libraries/System.Diagnostics.EventLog/tests/System.Diagnostics.EventLog.Tests.csproj +++ b/src/libraries/System.Diagnostics.EventLog/tests/System.Diagnostics.EventLog.Tests.csproj @@ -44,5 +44,6 @@ + diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.Windows.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.Windows.cs index 5e3a8cc45f806c..0b4796c5048a31 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.Windows.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.Windows.cs @@ -20,7 +20,7 @@ public void LongModuleFileNamesAreSupported() const string libraryName = "LongPath.dll"; const int minPathLength = 261; - string testBinPath = Path.GetDirectoryName(typeof(ProcessModuleTests).Assembly.Location); + string testBinPath = AppContext.BaseDirectory; string libraryToCopy = Path.Combine(testBinPath, libraryName); Assert.True(File.Exists(libraryToCopy), $"{libraryName} was not present in bin folder '{testBinPath}'"); diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs index a13d097bd671a8..28da46ccff0e15 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs @@ -1778,7 +1778,7 @@ public void MainWindowTitle_GetWithGui_ShouldRefresh_Windows() } } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBuiltWithAggressiveTrimming))] [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void RefreshResetsAllRefreshableFields() { diff --git a/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj b/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj index 396b584abd2a6f..c2b1b8abf05a5d 100644 --- a/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj +++ b/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj @@ -64,6 +64,9 @@ - + + Content + PreserveNewest + diff --git a/src/libraries/System.DirectoryServices.Protocols/tests/SortRequestControlTests.cs b/src/libraries/System.DirectoryServices.Protocols/tests/SortRequestControlTests.cs index 480b537bab85b6..50185cf8d52ef0 100644 --- a/src/libraries/System.DirectoryServices.Protocols/tests/SortRequestControlTests.cs +++ b/src/libraries/System.DirectoryServices.Protocols/tests/SortRequestControlTests.cs @@ -101,7 +101,7 @@ public void SortKeys_SetValid_GetReturnsExpected() public void SortKeys_GetNull_ReturnsEmptyArray() { var control = new SortRequestControl(); - FieldInfo field = control.GetType().GetField("_keys", BindingFlags.NonPublic | BindingFlags.Instance); + FieldInfo field = typeof(SortRequestControl).GetField("_keys", BindingFlags.NonPublic | BindingFlags.Instance); field.SetValue(control, null); Assert.Empty(control.SortKeys); } diff --git a/src/libraries/System.Threading.Tasks.Dataflow/tests/Dataflow/DebugAttributeTests.cs b/src/libraries/System.Threading.Tasks.Dataflow/tests/Dataflow/DebugAttributeTests.cs index 9b757ce5c9e62f..75f45c48a260ad 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/tests/Dataflow/DebugAttributeTests.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/tests/Dataflow/DebugAttributeTests.cs @@ -8,7 +8,9 @@ namespace System.Threading.Tasks.Dataflow.Tests { public class DebugAttributeTests { - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + public static bool IsThreadingAndDebuggerAttributesSupported => PlatformDetection.IsThreadingSupported && PlatformDetection.IsDebuggerTypeProxyAttributeSupported; + + [ConditionalFact(nameof(IsThreadingAndDebuggerAttributesSupported))] public void TestDebuggerDisplaysAndTypeProxies() { // Test both canceled and non-canceled diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 2d46d69750c306..2c64c8eccd8fcc 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -418,6 +418,10 @@ + + + + @@ -469,6 +473,8 @@ + + @@ -476,6 +482,9 @@ + + + @@ -492,16 +501,10 @@ - - - - - - @@ -516,13 +519,8 @@ - - - - - @@ -531,15 +529,12 @@ - - - From cd8da0fac79ff956974d4a2317f271a3e5dfbd0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Sat, 6 Aug 2022 14:28:46 +0900 Subject: [PATCH 2/5] Apply suggestions from code review Co-authored-by: Jan Kotas --- .../ConsoleLoggerExtensionsTests.cs | 2 +- .../SimpleConsoleFormatterTests.cs | 2 +- src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs | 3 ++- .../tests/System.Diagnostics.Process.Tests.csproj | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerExtensionsTests.cs b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerExtensionsTests.cs index 8f8dfd1e7d33c2..de5dd9310cd781 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerExtensionsTests.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerExtensionsTests.cs @@ -271,7 +271,7 @@ public void AddSystemdConsole_OutsideConfig_TakesProperty() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/73432", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] + [ActiveIssue("https://github.com/dotnet/runtime/issues/73436", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public void AddJsonConsole_ChangeProperties_IsReadFromLoggingConfiguration() { var configuration = new ConfigurationBuilder().AddInMemoryCollection(new[] { diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/SimpleConsoleFormatterTests.cs b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/SimpleConsoleFormatterTests.cs index b27b5b519e0674..4192809f7e913b 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/SimpleConsoleFormatterTests.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/SimpleConsoleFormatterTests.cs @@ -15,7 +15,7 @@ public class SimpleConsoleFormatterTests : ConsoleFormatterTests [InlineData(LoggerColorBehavior.Disabled)] [ActiveIssue("https://github.com/dotnet/runtime/issues/50575", TestPlatforms.Android)] [ActiveIssue("https://github.com/dotnet/runtime/issues/51398", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/73432", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] + [ActiveIssue("https://github.com/dotnet/runtime/issues/73436", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public void Log_WritingScopes_LogsWithCorrectColorsWhenColorEnabled(LoggerColorBehavior colorBehavior) { // Arrange diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs index 28da46ccff0e15..cbd9cf648c910f 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs @@ -1778,7 +1778,8 @@ public void MainWindowTitle_GetWithGui_ShouldRefresh_Windows() } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBuiltWithAggressiveTrimming))] + [Fact] + [DynamicDependency(DynamicallyAccessedMemberTypes.NonPublicFields, typeof(Process))] [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void RefreshResetsAllRefreshableFields() { diff --git a/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj b/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj index c2b1b8abf05a5d..e23bb4a94a71c6 100644 --- a/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj +++ b/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj @@ -64,7 +64,7 @@ - + Content PreserveNewest From 359bce48658061b8db3aa4b0d87041a91c2e551e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Sun, 7 Aug 2022 15:12:58 +0900 Subject: [PATCH 3/5] Update ProcessTests.cs --- src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs index cbd9cf648c910f..39696fcea0190b 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; using System.DirectoryServices.ActiveDirectory; using System.IO; using System.IO.Pipes; From a353acf9fafe7c97da580583f0dd012f092fd588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Mon, 8 Aug 2022 10:49:42 +0900 Subject: [PATCH 4/5] skljlfd --- .../tests/EventLogMessagesTests.cs | 4 +++- .../System.Diagnostics.Process/tests/ProcessModuleTests.cs | 3 ++- .../System.Diagnostics.Process/tests/ProcessTests.cs | 4 +--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libraries/System.Diagnostics.EventLog/tests/EventLogMessagesTests.cs b/src/libraries/System.Diagnostics.EventLog/tests/EventLogMessagesTests.cs index a29dbc0dd17f08..410b7920aa019a 100644 --- a/src/libraries/System.Diagnostics.EventLog/tests/EventLogMessagesTests.cs +++ b/src/libraries/System.Diagnostics.EventLog/tests/EventLogMessagesTests.cs @@ -50,7 +50,9 @@ public unsafe void CanFormatMessage(uint messageId) } } - [ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))] + public static bool HasAssemblyFilesIsElevatedAndSupportsEventLogs => PlatformDetection.HasAssemblyFiles && Helpers.IsElevatedAndSupportsEventLogs; + + [ConditionalFact(nameof(HasAssemblyFilesIsElevatedAndSupportsEventLogs))] public void CanReadAndWriteMessages() { string messageDllPath = Path.Combine(Path.GetDirectoryName(typeof(EventLog).Assembly.Location), "System.Diagnostics.EventLog.Messages.dll"); diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.cs index 1b05b2fa84f55b..a5376fce094160 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.cs @@ -38,7 +38,8 @@ public void Modules_Get_ContainsHostFileName() Assert.Contains(modules.Cast(), m => m.FileName.Contains(RemoteExecutor.HostRunnerName)); } - [Fact] + // Single-file executables don't have libcoreclr or libSystem.Native + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.HasAssemblyFiles))] [PlatformSpecific(TestPlatforms.Linux)] // OSX only includes the main module public void TestModulesContainsUnixNativeLibs() { diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs index 39696fcea0190b..28da46ccff0e15 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; using System.DirectoryServices.ActiveDirectory; using System.IO; using System.IO.Pipes; @@ -1779,8 +1778,7 @@ public void MainWindowTitle_GetWithGui_ShouldRefresh_Windows() } } - [Fact] - [DynamicDependency(DynamicallyAccessedMemberTypes.NonPublicFields, typeof(Process))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBuiltWithAggressiveTrimming))] [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void RefreshResetsAllRefreshableFields() { From 744defc8b537fea6ab9c500af79ab3a823ad7c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Tue, 9 Aug 2022 13:48:09 +0900 Subject: [PATCH 5/5] Update ProcessTests.cs --- .../System.Diagnostics.Process/tests/ProcessTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs index 28da46ccff0e15..6fa4ee16248878 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs @@ -1778,7 +1778,7 @@ public void MainWindowTitle_GetWithGui_ShouldRefresh_Windows() } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBuiltWithAggressiveTrimming))] + [Fact] [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void RefreshResetsAllRefreshableFields() { @@ -1827,7 +1827,7 @@ static void SetPrivateFieldsToNonDefaultValues(Process process) SetPrivateFieldValue(process, "_haveExitTime", true); SetPrivateFieldValue(process, "_havePriorityBoostEnabled", true); - SetPrivateFieldValue(process, "_processInfo", typeof(Process).Assembly.GetType("System.Diagnostics.ProcessInfo").GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, Array.Empty()).Invoke(null)); + SetPrivateFieldValue(process, "_processInfo", Type.GetType("System.Diagnostics.ProcessInfo, System.Diagnostics.Process").GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, Array.Empty()).Invoke(null)); SetPrivateFieldValue(process, "_threads", new ProcessThreadCollection(Array.Empty())); SetPrivateFieldValue(process, "_modules", new ProcessModuleCollection(Array.Empty()));