diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeAugments.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeAugments.cs index 010c453c367da7..b089a30f5eb67b 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeAugments.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeAugments.cs @@ -86,6 +86,8 @@ public static object NewObject(RuntimeTypeHandle typeHandle) || eeType == EETypePtr.EETypePtrOf() ) return null; + if (eeType.IsByRefLike) + throw new System.Reflection.TargetException(); return RuntimeImports.RhNewObject(eeType); } diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index a8d0ad4a98e8ce..130e89ad18f489 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -152,6 +152,8 @@ private static bool GetLinqExpressionsBuiltWithIsInterpretingOnly() public static bool IsAssemblyLoadingSupported => !IsNativeAot; public static bool IsMethodBodySupported => !IsNativeAot; public static bool IsDebuggerTypeProxyAttributeSupported => !IsNativeAot; + public static bool HasAssemblyFiles => !string.IsNullOrEmpty(typeof(PlatformDetection).Assembly.Location); + public static bool HasHostExecutable => HasAssemblyFiles; // single-file don't have a host private static volatile Tuple s_lazyNonZeroLowerBoundArraySupported; public static bool IsNonZeroLowerBoundArraySupported diff --git a/src/libraries/System.Buffers/tests/ArrayPool/UnitTests.cs b/src/libraries/System.Buffers/tests/ArrayPool/UnitTests.cs index 84246f7d170cdc..2cb5087132dad1 100644 --- a/src/libraries/System.Buffers/tests/ArrayPool/UnitTests.cs +++ b/src/libraries/System.Buffers/tests/ArrayPool/UnitTests.cs @@ -345,7 +345,9 @@ public static void RentingSpecificLengthsYieldsExpectedLengths(int requestedMini } } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.Is64BitProcess))] + public static bool Is64BitProcessAndRemoteExecutorSupported => PlatformDetection.Is64BitProcess && RemoteExecutor.IsSupported; + + [ConditionalTheory(nameof(Is64BitProcessAndRemoteExecutorSupported))] [InlineData(1024 * 1024 * 1024 - 1, true)] [InlineData(1024 * 1024 * 1024, true)] [InlineData(1024 * 1024 * 1024 + 1, false)] diff --git a/src/libraries/System.Collections.Concurrent/tests/BlockingCollectionTests.cs b/src/libraries/System.Collections.Concurrent/tests/BlockingCollectionTests.cs index cb18979ec407de..3bd513e1dd183f 100644 --- a/src/libraries/System.Collections.Concurrent/tests/BlockingCollectionTests.cs +++ b/src/libraries/System.Collections.Concurrent/tests/BlockingCollectionTests.cs @@ -170,7 +170,7 @@ public static void TestBugFix914998() Assert.Equal(1, BlockingCollection.TryTakeFromAny(producerArray, out ignored, -1)); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))] public static void TestDebuggerAttributes() { DebuggerAttributes.ValidateDebuggerDisplayReferences(new BlockingCollection()); @@ -181,7 +181,7 @@ public static void TestDebuggerAttributes() Assert.Equal(col, items); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))] public static void TestDebuggerAttributes_Null() { Type proxyType = DebuggerAttributes.GetProxyType(new BlockingCollection()); diff --git a/src/libraries/System.Collections.Concurrent/tests/ConcurrentDictionary/ConcurrentDictionaryTests.cs b/src/libraries/System.Collections.Concurrent/tests/ConcurrentDictionary/ConcurrentDictionaryTests.cs index abc0598004f3be..5ef256c48765f5 100644 --- a/src/libraries/System.Collections.Concurrent/tests/ConcurrentDictionary/ConcurrentDictionaryTests.cs +++ b/src/libraries/System.Collections.Concurrent/tests/ConcurrentDictionary/ConcurrentDictionaryTests.cs @@ -622,7 +622,7 @@ public static void TestConstructor() Assert.Equal(1, dictionary.Values.Count); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))] public static void TestDebuggerAttributes() { DebuggerAttributes.ValidateDebuggerDisplayReferences(new ConcurrentDictionary()); @@ -635,7 +635,7 @@ public static void TestDebuggerAttributes() Assert.Equal(dict, items); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))] public static void TestDebuggerAttributes_Null() { Type proxyType = DebuggerAttributes.GetProxyType(new ConcurrentDictionary()); diff --git a/src/libraries/System.Collections.Concurrent/tests/ProducerConsumerCollectionTests.cs b/src/libraries/System.Collections.Concurrent/tests/ProducerConsumerCollectionTests.cs index f94c4a758fd8f9..7aae42fcae3eca 100644 --- a/src/libraries/System.Collections.Concurrent/tests/ProducerConsumerCollectionTests.cs +++ b/src/libraries/System.Collections.Concurrent/tests/ProducerConsumerCollectionTests.cs @@ -953,7 +953,7 @@ public void ManyConcurrentAddsTakes_ForceContentionWithGetEnumerator(int initial Assert.Equal(initialCount, c.Count); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))] [InlineData(0)] [InlineData(10)] public void DebuggerAttributes_Success(int count) @@ -966,7 +966,7 @@ public void DebuggerAttributes_Success(int count) Assert.Equal(c, items.Cast()); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))] public void DebuggerTypeProxy_Ctor_NullArgument_Throws() { IProducerConsumerCollection c = CreateProducerConsumerCollection(); diff --git a/src/libraries/System.Drawing.Common/tests/BitmapTests.cs b/src/libraries/System.Drawing.Common/tests/BitmapTests.cs index e4322e65f43735..2ea9b32e774144 100644 --- a/src/libraries/System.Drawing.Common/tests/BitmapTests.cs +++ b/src/libraries/System.Drawing.Common/tests/BitmapTests.cs @@ -790,6 +790,7 @@ public void GetHicon_Disposed_ThrowsArgumentException() [ConditionalFact(Helpers.IsDrawingSupported)] [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "In .NET Framework we use GDI 1.0")] + [ActiveIssue("https://github.com/dotnet/runtime/issues/72165", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public void SaveWmfAsPngDoesntChangeImageBoundaries() { if (PlatformDetection.IsWindows7) diff --git a/src/libraries/System.Drawing.Common/tests/IconTests.cs b/src/libraries/System.Drawing.Common/tests/IconTests.cs index 82086c4e427e68..fae209c336dfb2 100644 --- a/src/libraries/System.Drawing.Common/tests/IconTests.cs +++ b/src/libraries/System.Drawing.Common/tests/IconTests.cs @@ -647,7 +647,8 @@ void VerifyPngNotSupported() } else { - VerifyPngNotSupported(); + if (AppContext.TryGetSwitch(DontSupportPngFramesInIcons, out bool enabled) && enabled) + VerifyPngNotSupported(); } } diff --git a/src/libraries/System.Drawing.Common/tests/System.Drawing.Common.Tests.csproj b/src/libraries/System.Drawing.Common/tests/System.Drawing.Common.Tests.csproj index 7b437679f7ae9a..33f175f14567d6 100644 --- a/src/libraries/System.Drawing.Common/tests/System.Drawing.Common.Tests.csproj +++ b/src/libraries/System.Drawing.Common/tests/System.Drawing.Common.Tests.csproj @@ -5,6 +5,9 @@ $(NetCoreAppCurrent)-windows;net48 true + + + diff --git a/src/libraries/System.Drawing.Common/tests/System/Drawing/FontConverterTests.cs b/src/libraries/System.Drawing.Common/tests/System/Drawing/FontConverterTests.cs index 63c35baa39f525..e2c54362c48901 100644 --- a/src/libraries/System.Drawing.Common/tests/System/Drawing/FontConverterTests.cs +++ b/src/libraries/System.Drawing.Common/tests/System/Drawing/FontConverterTests.cs @@ -81,7 +81,7 @@ public void EmptyStringInput() Assert.Null(font); } - [ConditionalFact(Helpers.IsDrawingSupported)] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDrawingSupported), nameof(PlatformDetection.IsNotBuiltWithAggressiveTrimming))] public void GetFontPropsSorted() { // The order provided since .NET Framework diff --git a/src/libraries/System.Drawing.Common/tests/default.rd.xml b/src/libraries/System.Drawing.Common/tests/default.rd.xml new file mode 100644 index 00000000000000..c2aeeadaf8e445 --- /dev/null +++ b/src/libraries/System.Drawing.Common/tests/default.rd.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/libraries/System.IO.MemoryMappedFiles/tests/System.IO.MemoryMappedFiles.Tests.csproj b/src/libraries/System.IO.MemoryMappedFiles/tests/System.IO.MemoryMappedFiles.Tests.csproj index a8a88974aee7bc..ef44754372ef71 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/tests/System.IO.MemoryMappedFiles.Tests.csproj +++ b/src/libraries/System.IO.MemoryMappedFiles/tests/System.IO.MemoryMappedFiles.Tests.csproj @@ -5,6 +5,9 @@ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser true + + + diff --git a/src/libraries/System.IO.MemoryMappedFiles/tests/default.rd.xml b/src/libraries/System.IO.MemoryMappedFiles/tests/default.rd.xml new file mode 100644 index 00000000000000..1ba604c63c9809 --- /dev/null +++ b/src/libraries/System.IO.MemoryMappedFiles/tests/default.rd.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libraries/System.Memory.Data/tests/BinaryDataTests.cs b/src/libraries/System.Memory.Data/tests/BinaryDataTests.cs index 042d9e4b9293b1..737dbb924361da 100644 --- a/src/libraries/System.Memory.Data/tests/BinaryDataTests.cs +++ b/src/libraries/System.Memory.Data/tests/BinaryDataTests.cs @@ -316,7 +316,7 @@ public void MaxStreamLengthRespected() var data = BinaryData.FromStream(new OverFlowStream(offset: int.MaxValue - 1000)); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBuiltWithAggressiveTrimming))] public void CanCreateBinaryDataFromCustomType() { TestModel payload = new TestModel { A = "value", B = 5, C = true, D = null }; @@ -342,7 +342,7 @@ void AssertData(BinaryData data) } } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBuiltWithAggressiveTrimming))] public void CanSerializeNullData() { BinaryData data = new BinaryData(jsonSerializable: null); @@ -399,7 +399,7 @@ public void CreateThrowsOnNullArray() Assert.Contains("data", ex.Message); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBuiltWithAggressiveTrimming))] public void ToObjectHandlesBOM() { TestModel payload = new TestModel { A = "string", B = 42, C = true }; @@ -415,7 +415,7 @@ public void ToObjectHandlesBOM() Assert.Equal(payload.C, model.C); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBuiltWithAggressiveTrimming))] public void ToObjectThrowsExceptionOnIncompatibleType() { TestModel payload = new TestModel { A = "value", B = 5, C = true }; diff --git a/src/libraries/System.Memory/tests/MemoryMarshal/GetArrayDataReference.cs b/src/libraries/System.Memory/tests/MemoryMarshal/GetArrayDataReference.cs index ea9ab626213630..0fc55c64c44513 100644 --- a/src/libraries/System.Memory/tests/MemoryMarshal/GetArrayDataReference.cs +++ b/src/libraries/System.Memory/tests/MemoryMarshal/GetArrayDataReference.cs @@ -17,7 +17,7 @@ public static void GetArrayDataReference_NullInput_ThrowsNullRef() Assert.Throws(() => MemoryMarshal.GetArrayDataReference((Array)null)); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNonZeroLowerBoundArraySupported))] public static void GetArrayDataReference_NonEmptyInput_ReturnsRefToFirstElement() { // szarray @@ -50,7 +50,7 @@ public static unsafe void GetArrayDataReference_EmptyInput_ReturnsRefToWhereFirs Assert.True(Unsafe.AreSame(ref theRef, ref theMdArrayRef)); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNonZeroLowerBoundArraySupported))] [InlineData(1)] [InlineData(2)] [InlineData(3)] diff --git a/src/libraries/System.Memory/tests/Span/Reflection.cs b/src/libraries/System.Memory/tests/Span/Reflection.cs index 77fb1159fa0548..11e2c65d3c933f 100644 --- a/src/libraries/System.Memory/tests/Span/Reflection.cs +++ b/src/libraries/System.Memory/tests/Span/Reflection.cs @@ -51,13 +51,21 @@ public static void BinaryPrimitives_StaticWithSpanArgument() [Fact] public static void MemoryMarshal_GenericStaticReturningSpan() { - Type type = typeof(MemoryMarshal); + MethodInfo createSpanMethod = typeof(MemoryMarshal).GetMethod(nameof(MemoryMarshal.CreateSpan)); int value = 0; ref int refInt = ref value; - - MethodInfo method = type.GetMethod(nameof(MemoryMarshal.CreateSpan)).MakeGenericMethod((refInt.GetType())); - Assert.Throws(() => method.Invoke(null, new object[] { null, 0 })); + Type refIntType = refInt.GetType(); + + if (PlatformDetection.IsNativeAot) + { + Assert.Throws(() => createSpanMethod.MakeGenericMethod(refIntType)); + } + else + { + MethodInfo method = createSpanMethod.MakeGenericMethod(refIntType); + Assert.Throws(() => method.Invoke(null, new object[] { null, 0 })); + } } [Fact] diff --git a/src/libraries/System.Memory/tests/System.Memory.Tests.csproj b/src/libraries/System.Memory/tests/System.Memory.Tests.csproj index 9cf7d462bec5b8..5e0b857be6a71c 100644 --- a/src/libraries/System.Memory/tests/System.Memory.Tests.csproj +++ b/src/libraries/System.Memory/tests/System.Memory.Tests.csproj @@ -5,6 +5,9 @@ true $(NetCoreAppCurrent) + + + diff --git a/src/libraries/System.Memory/tests/TestHelpers.cs b/src/libraries/System.Memory/tests/TestHelpers.cs index a65d9ca010ce9a..daca3c6eeb75a2 100644 --- a/src/libraries/System.Memory/tests/TestHelpers.cs +++ b/src/libraries/System.Memory/tests/TestHelpers.cs @@ -48,14 +48,11 @@ public static void AssertThrows(Span span, AssertThrowsAction action try { action(span); - Assert.False(true, "Expected exception: " + typeof(E).GetType()); + Assert.False(true, $"Expected exception: {typeof(E)}"); } - catch (E) + catch (Exception ex) { - } - catch (Exception wrongException) - { - Assert.False(true, "Wrong exception thrown: Expected " + typeof(E).GetType() + ": Actual: " + wrongException.GetType()); + Assert.True(ex is E, $"Wrong exception thrown. Expected: {typeof(E)} Actual: {ex.GetType()}"); } } @@ -112,14 +109,11 @@ public static void AssertThrows(ReadOnlySpan span, AssertThrowsActionRe try { action(span); - Assert.False(true, "Expected exception: " + typeof(E).GetType()); - } - catch (E) - { + Assert.False(true, $"Expected exception: {typeof(E)}"); } - catch (Exception wrongException) + catch (Exception ex) { - Assert.False(true, "Wrong exception thrown: Expected " + typeof(E).GetType() + ": Actual: " + wrongException.GetType()); + Assert.True(ex is E, $"Wrong exception thrown. Expected: {typeof(E)} Actual: {ex.GetType()}"); } } diff --git a/src/libraries/System.Memory/tests/default.rd.xml b/src/libraries/System.Memory/tests/default.rd.xml new file mode 100644 index 00000000000000..ab97e03a817ed2 --- /dev/null +++ b/src/libraries/System.Memory/tests/default.rd.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/CustomAttributeDecoderTests.cs b/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/CustomAttributeDecoderTests.cs index 60fee1d24e9799..aed29838d61cbd 100644 --- a/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/CustomAttributeDecoderTests.cs +++ b/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/CustomAttributeDecoderTests.cs @@ -12,7 +12,7 @@ namespace System.Reflection.Metadata.Decoding.Tests { public class CustomAttributeDecoderTests { - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.HasAssemblyFiles))] [ActiveIssue("https://github.com/dotnet/runtime/issues/60579", TestPlatforms.iOS | TestPlatforms.tvOS)] [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Type assembly name is different on .NET Framework.")] public void TestCustomAttributeDecoder() diff --git a/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/SignatureDecoderTests.cs b/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/SignatureDecoderTests.cs index 7669fbcc2ef312..f5fe93875d8da2 100644 --- a/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/SignatureDecoderTests.cs +++ b/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/SignatureDecoderTests.cs @@ -80,7 +80,7 @@ public unsafe void DecodeInvalidMethodSpecificationSignature(byte[] testSignatur } } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.HasAssemblyFiles))] public void DecodeVarArgsDefAndRef() { using (FileStream stream = File.OpenRead(AssemblyPathHelper.GetAssemblyLocation(typeof(VarArgsToDecode).GetTypeInfo().Assembly))) @@ -132,7 +132,7 @@ public static void VarArgsCaller() } // Test as much as we can with simple C# examples inline below. - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.HasAssemblyFiles))] public void SimpleSignatureProviderCoverage() { using (FileStream stream = File.OpenRead(AssemblyPathHelper.GetAssemblyLocation(typeof(SignaturesToDecode<>).GetTypeInfo().Assembly))) @@ -243,7 +243,7 @@ public struct Nested { } public event EventHandler Event { add { } remove { } } } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.HasAssemblyFiles))] public void PinnedAndUnpinnedLocals() { using (FileStream stream = File.OpenRead(AssemblyPathHelper.GetAssemblyLocation(typeof(PinnedAndUnpinnedLocalsToDecode).GetTypeInfo().Assembly))) @@ -282,7 +282,7 @@ public static unsafe int DoSomething() } } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.HasAssemblyFiles))] public void WrongSignatureType() { using (FileStream stream = File.OpenRead(AssemblyPathHelper.GetAssemblyLocation(typeof(VarArgsToDecode).GetTypeInfo().Assembly))) diff --git a/src/libraries/System.Reflection.Metadata/tests/Metadata/MetadataReaderTests.cs b/src/libraries/System.Reflection.Metadata/tests/Metadata/MetadataReaderTests.cs index 9d7c52c14dff1e..ea219e381763dc 100644 --- a/src/libraries/System.Reflection.Metadata/tests/Metadata/MetadataReaderTests.cs +++ b/src/libraries/System.Reflection.Metadata/tests/Metadata/MetadataReaderTests.cs @@ -3088,8 +3088,11 @@ public void GetAssemblyName() Assert.Throws(() => MetadataReader.GetAssemblyName(tempFile.Path)); } - Assembly a = typeof(MetadataReaderTests).Assembly; - Assert.Equal(new AssemblyName(a.FullName).ToString(), MetadataReader.GetAssemblyName(AssemblyPathHelper.GetAssemblyLocation(a)).ToString()); + if (PlatformDetection.HasAssemblyFiles) + { + Assembly a = typeof(MetadataReaderTests).Assembly; + Assert.Equal(new AssemblyName(a.FullName).ToString(), MetadataReader.GetAssemblyName(AssemblyPathHelper.GetAssemblyLocation(a)).ToString()); + } } } } diff --git a/src/libraries/System.Reflection.Metadata/tests/Metadata/TagToTokenTests.cs b/src/libraries/System.Reflection.Metadata/tests/Metadata/TagToTokenTests.cs index be0568e20ee1f0..0466681515d43f 100644 --- a/src/libraries/System.Reflection.Metadata/tests/Metadata/TagToTokenTests.cs +++ b/src/libraries/System.Reflection.Metadata/tests/Metadata/TagToTokenTests.cs @@ -93,8 +93,7 @@ private IEnumerable GetTags() }; } - [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/50714", typeof(PlatformDetection), nameof(PlatformDetection.IsBuiltWithAggressiveTrimming), nameof(PlatformDetection.IsBrowser))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBuiltWithAggressiveTrimming))] public void ValidateTagToTokenConversion() { foreach (var tag in GetTags()) diff --git a/src/libraries/System.Reflection.Metadata/tests/PortableExecutable/PEBuilderTests.cs b/src/libraries/System.Reflection.Metadata/tests/PortableExecutable/PEBuilderTests.cs index 33c57919af240e..27ba57133ff1ed 100644 --- a/src/libraries/System.Reflection.Metadata/tests/PortableExecutable/PEBuilderTests.cs +++ b/src/libraries/System.Reflection.Metadata/tests/PortableExecutable/PEBuilderTests.cs @@ -756,7 +756,7 @@ public void Checksum() Assert.False(TestChecksumAndAuthenticodeSignature(new MemoryStream(Misc.Deterministic))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.HasAssemblyFiles))] [SkipOnPlatform(TestPlatforms.Browser, "System.Security.Cryptography isn't supported on browser")] public void ChecksumFXAssemblies() { diff --git a/src/libraries/System.Reflection.Metadata/tests/TestUtilities/AssertEx.cs b/src/libraries/System.Reflection.Metadata/tests/TestUtilities/AssertEx.cs index 01cc513401f875..a414b853b892e9 100644 --- a/src/libraries/System.Reflection.Metadata/tests/TestUtilities/AssertEx.cs +++ b/src/libraries/System.Reflection.Metadata/tests/TestUtilities/AssertEx.cs @@ -457,13 +457,10 @@ public static void Throws(Func testCode, Action exceptionValidatio testCode(); Assert.False(true, $"Exception of type '{typeof(T)}' was expected but none was thrown."); } - catch (T e) - { - exceptionValidation(e); - } catch (Exception e) { - Assert.False(true, $"Exception of type '{typeof(T)}' was expected but '{e.GetType()}' was thrown instead."); + Assert.True(e is T, $"Exception of type '{typeof(T)}' was expected but '{e.GetType()}' was thrown instead."); + exceptionValidation((T)e); } } } diff --git a/src/libraries/System.Threading.Thread/tests/ThreadTests.cs b/src/libraries/System.Threading.Thread/tests/ThreadTests.cs index 25d5a80dcc5383..43204224c3ef94 100644 --- a/src/libraries/System.Threading.Thread/tests/ThreadTests.cs +++ b/src/libraries/System.Threading.Thread/tests/ThreadTests.cs @@ -158,7 +158,7 @@ public static IEnumerable ApartmentStateTest_MemberData() }; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer), nameof(PlatformDetection.IsNotMobile))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer), nameof(PlatformDetection.IsNotMobile), nameof(PlatformDetection.HasHostExecutable))] [InlineData("STAMain.exe", "GetApartmentStateTest")] [InlineData("STAMain.exe", "SetApartmentStateTest")] [InlineData("STAMain.exe", "WaitAllNotSupportedOnSta_Test0")] @@ -168,8 +168,6 @@ public static IEnumerable ApartmentStateTest_MemberData() [InlineData("DefaultApartmentStateMain.exe", "GetApartmentStateTest")] [InlineData("DefaultApartmentStateMain.exe", "SetApartmentStateTest")] [ActiveIssue("https://github.com/dotnet/runtime/issues/34543", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "Not supported on iOS, MacCatalyst, or tvOS.")] - [SkipOnPlatform(TestPlatforms.Browser, "System.Diagnostics.Process is not supported on this platform.")] public static void ApartmentState_AttributePresent(string appName, string testName) { var psi = new ProcessStartInfo(); @@ -255,6 +253,7 @@ public static void GetSetApartmentStateTest_ChangeAfterThreadStarted_Windows( [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))] [ActiveIssue("https://github.com/dotnet/runtime/issues/34543", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/72232", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] [MemberData(nameof(ApartmentStateTest_MemberData))] [PlatformSpecific(TestPlatforms.Windows)] // Expected behavior differs on Unix and Windows public static void ApartmentStateTest_ChangeBeforeThreadStarted_Windows( @@ -279,6 +278,7 @@ public static void ApartmentStateTest_ChangeBeforeThreadStarted_Windows( [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsWindowsNanoServer))] [MemberData(nameof(ApartmentStateTest_MemberData))] + [ActiveIssue("https://github.com/dotnet/runtime/issues/72232", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public static void ApartmentStateTest_ChangeBeforeThreadStarted_Windows_Nano_Server( Func getApartmentState, Func setApartmentState, @@ -669,6 +669,7 @@ public static void ThreadNameDoesNotAffectProcessName() }).Dispose(); } + [ActiveIssue("https://github.com/dotnet/runtime/issues/72246", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public static void PriorityTest() { @@ -687,6 +688,7 @@ public static void PriorityTest() waitForThread(); } + [ActiveIssue("https://github.com/dotnet/runtime/issues/72231", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public static void ThreadStateTest() { @@ -915,6 +917,7 @@ public static void LocalDataSlotTest() [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] [ActiveIssue("https://github.com/dotnet/runtime/issues/49521", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [ActiveIssue("https://github.com/dotnet/runtimelab/issues/155", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public static void InterruptTest() { // Interrupting a thread that is not blocked does not do anything, but once the thread starts blocking, it gets @@ -964,6 +967,7 @@ public static void InterruptTest() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [ActiveIssue("https://github.com/dotnet/runtimelab/issues/155", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] [ActiveIssue("https://github.com/dotnet/runtime/issues/49521", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] public static void InterruptInFinallyBlockTest_SkipOnDesktopFramework() { diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 340116853154ce..b27319507b512f 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -449,8 +449,12 @@ Condition="'$(TargetOS)' == 'linux'" /> + + + + - @@ -461,12 +465,10 @@ - - @@ -487,7 +489,6 @@ - @@ -507,7 +508,6 @@ - @@ -516,11 +516,8 @@ - - - @@ -531,7 +528,6 @@ -