diff --git a/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/Common/SerializationTest.cs b/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/Common/SerializationTest.cs index d893fca6899bf1..9028aa53ae05a2 100644 --- a/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/Common/SerializationTest.cs +++ b/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/Common/SerializationTest.cs @@ -8,6 +8,7 @@ namespace System.Resources.Extensions.Tests.Common; +[ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsBinaryFormatterSupported))] public abstract class SerializationTest where TSerializer : ISerializer { public static TheoryData FormatterOptions => new() diff --git a/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/Common/SystemDrawingTests.cs b/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/Common/SystemDrawingTests.cs index 81b491e887edba..9fcb7d60a6cc89 100644 --- a/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/Common/SystemDrawingTests.cs +++ b/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/Common/SystemDrawingTests.cs @@ -7,10 +7,11 @@ namespace System.Resources.Extensions.Tests.Common; -[ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsDrawingSupported))] +// This type can not be annotated with [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsDrawingSupported))] +// because the base type is annotated with [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsBinaryFormatterSupported))] public abstract class SystemDrawingTests : SerializationTest where T : ISerializer { - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsDrawingSupported), nameof(PlatformDetection.SupportsComInterop))] [MemberData(nameof(FormatterOptions))] [SupportedOSPlatform("windows")] public void Bitmap_RoundTrip(FormatterTypeStyle typeStyle, FormatterAssemblyStyle assemblyMatching) @@ -20,7 +21,7 @@ public void Bitmap_RoundTrip(FormatterTypeStyle typeStyle, FormatterAssemblyStyl deserialized.Size.Should().Be(bitmap.Size); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsDrawingSupported), nameof(PlatformDetection.SupportsComInterop))] [MemberData(nameof(FormatterOptions))] [SupportedOSPlatform("windows")] public void Png_RoundTrip(FormatterTypeStyle typeStyle, FormatterAssemblyStyle assemblyMatching) diff --git a/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/FormattedObject/BinaryFormattedTypes.cs b/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/FormattedObject/BinaryFormattedTypes.cs index b49320a1cadf5b..f9641ce9c86613 100644 --- a/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/FormattedObject/BinaryFormattedTypes.cs +++ b/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/FormattedObject/BinaryFormattedTypes.cs @@ -8,6 +8,7 @@ namespace System.Resources.Extensions.Tests.FormattedObject; +[ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsBinaryFormatterSupported))] public class BinaryFormattedTypes { [Theory] diff --git a/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/FormattedObject/SystemDrawingTests.cs b/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/FormattedObject/SystemDrawingTests.cs index bb26d521a9e3e7..99a95fbb6c70da 100644 --- a/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/FormattedObject/SystemDrawingTests.cs +++ b/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/FormattedObject/SystemDrawingTests.cs @@ -9,7 +9,7 @@ namespace System.Resources.Extensions.Tests.FormattedObject; public class SystemDrawingTests : Common.SystemDrawingTests { - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDrawingSupported))] public void PointF_Parse() { PointF input = new() { X = 123.5f, Y = 456.1f }; @@ -26,7 +26,7 @@ public void PointF_Parse() classInfo.GetSingle("y").Should().Be(input.Y); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDrawingSupported))] public void RectangleF_Parse() { RectangleF input = new(x: 123.5f, y: 456.1f, width: 100.25f, height: 200.75f); diff --git a/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/Legacy/BinaryFormatterTests.cs b/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/Legacy/BinaryFormatterTests.cs index d8492e19dd574a..8f99d4437ba36b 100644 --- a/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/Legacy/BinaryFormatterTests.cs +++ b/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/Legacy/BinaryFormatterTests.cs @@ -15,6 +15,7 @@ namespace BinaryFormatTests.FormatterTests; +[ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsBinaryFormatterSupported))] public partial class BinaryFormatterTests { [Theory] diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 754ba0940ab820..9e4ac5317716fe 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -425,6 +425,11 @@ + + + + + @@ -506,8 +511,6 @@ - -