From f1d0c866cf675ce463a6ac540e91c50bdf732598 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 24 Apr 2026 11:13:42 +0000 Subject: [PATCH 1/2] Suppress trim/AOT warnings in System.Runtime tests for NativeAOT mobile Add UnconditionalSuppressMessage attributes to System.Runtime tests that use BinaryFormatter, DynamicMethod, and reflection APIs which are not compatible with NativeAOT on mobile platforms (iOS, tvOS, MacCatalyst, Android). These tests are already conditionally skipped or runtime-guarded, but the analyzer still sees the code during compilation. The suppressions allow the Hybrid (NativeAOT) test project builds to succeed without warnings treated as errors. Fixes build failures in runtime-extra-platforms pipeline build 1394339 for: - maccatalyst-arm64/x64 Release AllSubsets_Mono - tvos-arm64 Release AllSubsets_Mono - iossimulator-arm64/x64 Release AllSubsets_Mono - android-* Release AllSubsets_Mono Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../tests/System.Runtime.Tests/System/StringTests.cs | 3 +++ .../tests/System.Runtime.Tests/System/TimeZoneInfoTests.cs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs index 4ec41acad8c125..1f7df0d8f4012a 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs @@ -1134,6 +1134,7 @@ public void Replace_NoSuchStringComparison_ThrowsArgumentException(StringCompari } + [UnconditionalSuppressMessage("AOT", "IL3050", Justification = "Test field used only in conditional tests.")] private static readonly StringComparison[] StringComparisons = (StringComparison[])Enum.GetValues(typeof(StringComparison)); [Fact] @@ -1244,6 +1245,7 @@ public static void GetHashCode_NoSuchStringComparison_ThrowsArgumentException(St [Theory] [InlineData("")] // empty string [InlineData("hello")] // non-empty string + [UnconditionalSuppressMessage("AOT", "IL3050", Justification = "DynamicMethod usage is guarded by IsReflectionEmitSupported runtime check.")] public static unsafe void GetPinnableReference_ReturnsSameAsGCHandleAndLegacyFixed(string input) { Assert.NotNull(input); // test shouldn't have null input @@ -1303,6 +1305,7 @@ public static unsafe void GetPinnableReference_ReturnsSameAsGCHandleAndLegacyFix } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))] + [UnconditionalSuppressMessage("AOT", "IL3050", Justification = "Test is skipped when reflection emit is not supported.")] public static unsafe void GetPinnableReference_WithNullInput_ThrowsNullRef() { // This test uses an explicit call instead of the normal callvirt that C# would emit. diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/TimeZoneInfoTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/TimeZoneInfoTests.cs index 0067c38562b376..5651efc143224d 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/TimeZoneInfoTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/TimeZoneInfoTests.cs @@ -2172,6 +2172,8 @@ public static void ToSerializedString_FromSerializedString_RoundTrips(TimeZoneIn [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBinaryFormatterSupported))] [MemberData(nameof(SystemTimeZonesTestData))] + [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "Test is skipped when BinaryFormatter is not supported.")] + [UnconditionalSuppressMessage("AOT", "IL3050", Justification = "Test is skipped when BinaryFormatter is not supported.")] public static void BinaryFormatter_RoundTrips(TimeZoneInfo timeZone) { BinaryFormatter formatter = new BinaryFormatter(); @@ -2187,6 +2189,7 @@ public static void BinaryFormatter_RoundTrips(TimeZoneInfo timeZone) } [Fact] + [UnconditionalSuppressMessage("Trimming", "IL2075", Justification = "Test uses reflection to inspect internal properties for diagnostics.")] public static void TimeZoneInfo_DoesConvertTimeForOldDatesOfTimeZonesWithExceedingMaxRange() { // On some OSes this time zone contains old adjustment rules which have offset higher than 14h From 347b6ac251161342db0278d9abbd0d477857b8ab Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 24 Apr 2026 11:13:46 +0000 Subject: [PATCH 2/2] ci: trigger checks