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..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,6 +271,7 @@ public void AddSystemdConsole_OutsideConfig_TakesProperty()
}
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
+ [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 46c88511870324..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,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/73436", 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..410b7920aa019a 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)]
@@ -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.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/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 a13d097bd671a8..6fa4ee16248878 100644
--- a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs
+++ b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs
@@ -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()));
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..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,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 @@
-
-
-