Skip to content

[Apple mobile] Skip unsupported tests on Apple mobile platforms#126631

Open
kotlarmilos wants to merge 11 commits intodotnet:mainfrom
kotlarmilos:fix/apple-mobile-test-failures
Open

[Apple mobile] Skip unsupported tests on Apple mobile platforms#126631
kotlarmilos wants to merge 11 commits intodotnet:mainfrom
kotlarmilos:fix/apple-mobile-test-failures

Conversation

@kotlarmilos
Copy link
Copy Markdown
Member

@kotlarmilos kotlarmilos commented Apr 8, 2026

Summary

Skip unsupported tests on Apple mobile platforms.

Changes

  • Exclude System.Diagnostics.TraceSource.Config.Tests.csproj
  • CustomMethodInfoTests.GetMethodImplementationFlags_ReturnsIL and CustomConstructorInfoTests.GetMethodImplementationFlags_ReturnsIL not supported on Mono
  • Set RestoreUseStaticGraphEvaluation=false to workaround known nuget issue

- PlatformDetection.IsMethodBodySupported: use IsBuiltWithAggressiveTrimming
  to exclude platforms where IL bodies are stripped (NativeAOT, Apple mobile)
- ProcessTests.Start_Disposed_ThrowsObjectDisposedException: skip on
  iOS/tvOS/MacCatalyst where Process.Start throws
  PlatformNotSupportedException before checking disposed state
- CustomMethodInfoTests/CustomConstructorInfoTests: guard
  GetMethodImplementationFlags_ReturnsIL with IsMethodBodySupported
  since AOT IL stripping changes flags from IL to NoInlining

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 8, 2026 08:22
@kotlarmilos kotlarmilos changed the title Fix test failures on Apple mobile platforms due to IL stripping [Apple mobile] Fix test failures on Apple mobile platforms due to IL stripping Apr 8, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @akoeplinger, @matouskozak, @simonrozsival
See info in area-owners.md if you want to be subscribed.

@kotlarmilos kotlarmilos added this to the 11.0.0 milestone Apr 8, 2026
@kotlarmilos kotlarmilos enabled auto-merge (squash) April 8, 2026 08:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes test failures on Apple mobile platforms (iOS/tvOS/MacCatalyst) caused by Mono AOT IL stripping altering/removing method bodies, by skipping or conditioning affected tests.

Changes:

  • Update IsMethodBodySupported to account for aggressively-trimmed builds (incl. Apple mobile).
  • Make GetMethodImplementationFlags_ReturnsIL tests conditional on method-body availability.
  • Skip ProcessTests.Start_Disposed_ThrowsObjectDisposedException on Apple mobile platforms.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/libraries/System.Reflection.Context/tests/CustomMethodInfoTests.cs Makes the implementation-flags assertion conditional on PlatformDetection.IsMethodBodySupported.
src/libraries/System.Reflection.Context/tests/CustomConstructorInfoTests.cs Same conditional gating for constructor implementation-flags test.
src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs Skips a disposed-start exception test on select Apple platforms.
src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs Broadens IsMethodBodySupported to treat aggressively trimmed builds as unsupported for method-body-based tests.

kotlarmilos and others added 2 commits April 8, 2026 10:35
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 8, 2026 08:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kotlarmilos
Copy link
Copy Markdown
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Member

@vitek-karas vitek-karas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good
@adamsitnik can you quickly review the process test changes just to be sure?

@vitek-karas vitek-karas requested a review from adamsitnik April 8, 2026 09:35
@vitek-karas
Copy link
Copy Markdown
Member

I'm also trying to add #126635 into this since it looks like the same root cause (agressive trimming)

Copy link
Copy Markdown
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Process part LGTM, thank you @kotlarmilos !

…f IsMethodBodySupported

These tests check method implementation flags, not method bodies. Mono IL
stripping changes flags from IL to NoInlining, but R2R IL stripping does
not. Skip on Mono only to preserve NativeAOT coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 8, 2026 12:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

vitek-karas and others added 2 commits April 8, 2026 16:00
…ming

Add the active issue for the aggressive-trimming failure tracked by dotnet#126635.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 8, 2026 18:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (2)

src/libraries/System.Reflection.Context/tests/CustomMethodInfoTests.cs:195

  • This test is now conditioned on PlatformDetection.IsNotMonoRuntime, but the rationale (and nearby tests) point to method bodies/flags changing under aggressive trimming/IL stripping. Gating on IsNotMonoRuntime will skip the test on all Mono runtimes (even when method bodies are available) and may still run under trimmed CoreCLR scenarios. Consider conditioning on PlatformDetection.IsMethodBodySupported or PlatformDetection.IsNotBuiltWithAggressiveTrimming instead, so the skip matches the actual failing environment.
        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoRuntime))]
        public void GetMethodImplementationFlags_ReturnsIL()
        {
            MethodImplAttributes flags = _customMethod.GetMethodImplementationFlags();
            Assert.Equal(MethodImplAttributes.IL, flags);
        }

src/libraries/System.Reflection.Context/tests/CustomConstructorInfoTests.cs:163

  • This test is now conditioned on PlatformDetection.IsNotMonoRuntime, but the underlying failure mode described for Apple mobile is aggressive trimming/IL stripping affecting implementation flags. Using IsNotMonoRuntime is broader than necessary and may also fail to skip trimmed non-Mono runs. Consider gating on PlatformDetection.IsMethodBodySupported or PlatformDetection.IsNotBuiltWithAggressiveTrimming so the skip condition matches the scenario being worked around.
        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoRuntime))]
        public void GetMethodImplementationFlags_ReturnsIL()
        {
            MethodImplAttributes flags = _customConstructor.GetMethodImplementationFlags();
            Assert.Equal(MethodImplAttributes.IL, flags);
        }

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 9, 2026 10:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

src/libraries/System.Reflection.Context/tests/CustomMethodInfoTests.cs:194

  • GetMethodImplementationFlags_ReturnsIL is now conditioned on PlatformDetection.IsNotMonoRuntime, which will still run on NativeAOT and on CoreCLR-based Apple mobile runs. Those are exactly the environments where aggressive trimming/AOT can change MethodImplAttributes away from IL, so this test may still fail. If the intent is to skip when method bodies/IL are stripped, gate this on PlatformDetection.IsMethodBodySupported (or IsNotBuiltWithAggressiveTrimming) instead of IsNotMonoRuntime, or update the assertion to accept the trimmed/AOT flags when appropriate.
        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoRuntime))]
        public void GetMethodImplementationFlags_ReturnsIL()
        {
            MethodImplAttributes flags = _customMethod.GetMethodImplementationFlags();
            Assert.Equal(MethodImplAttributes.IL, flags);

src/libraries/System.Reflection.Context/tests/CustomConstructorInfoTests.cs:162

  • Same issue as CustomMethodInfoTests: conditioning this test on PlatformDetection.IsNotMonoRuntime will still execute it on NativeAOT (and potentially CoreCLR-based Apple mobile), where trimming/AOT can change GetMethodImplementationFlags() away from MethodImplAttributes.IL. Consider gating on PlatformDetection.IsMethodBodySupported / IsNotBuiltWithAggressiveTrimming, or broaden the expected flags for trimmed/AOT builds.
        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoRuntime))]
        public void GetMethodImplementationFlags_ReturnsIL()
        {
            MethodImplAttributes flags = _customConstructor.GetMethodImplementationFlags();
            Assert.Equal(MethodImplAttributes.IL, flags);

Copilot AI review requested due to automatic review settings April 9, 2026 18:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

src/libraries/System.Reflection.Context/tests/CustomMethodInfoTests.cs:195

  • Using PlatformDetection.IsNotMonoRuntime here skips the test on all Mono configurations, but it still runs on NativeAOT (which is also affected by aggressive trimming/IL stripping). If the intent is to avoid failures when method bodies are stripped and the implementation flags change, consider conditioning on PlatformDetection.IsNotBuiltWithAggressiveTrimming (or another trimming/AOT-specific predicate) instead so the test continues to run on non-trimmed Mono and is skipped on NativeAOT/Apple-mobile where it’s known to differ.
        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoRuntime))]
        public void GetMethodImplementationFlags_ReturnsIL()
        {
            MethodImplAttributes flags = _customMethod.GetMethodImplementationFlags();
            Assert.Equal(MethodImplAttributes.IL, flags);
        }

src/libraries/System.Reflection.Context/tests/CustomConstructorInfoTests.cs:163

  • Same issue as CustomMethodInfoTests: PlatformDetection.IsNotMonoRuntime will skip on all Mono configurations but still run on NativeAOT. If this assertion is only valid when method bodies aren’t aggressively trimmed, condition it on PlatformDetection.IsNotBuiltWithAggressiveTrimming (or similar) so it’s skipped on NativeAOT/Apple-mobile but still exercised on non-trimmed Mono.
        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoRuntime))]
        public void GetMethodImplementationFlags_ReturnsIL()
        {
            MethodImplAttributes flags = _customConstructor.GetMethodImplementationFlags();
            Assert.Equal(MethodImplAttributes.IL, flags);
        }

Instead of using a class-level ActiveIssue with IsBuiltWithAggressiveTrimming
(which also suppresses NativeAOT), exclude the entire project from compilation
and Helix submission for Apple mobile CoreCLR. All individual tests already
have ActiveIssue for iOS/tvOS/Android, so zero tests would run anyway.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kotlarmilos kotlarmilos changed the title [Apple mobile] Fix test failures on Apple mobile platforms due to IL stripping [Apple mobile] Skip unsupported tests on Apple mobile platforms Apr 9, 2026
@kotlarmilos
Copy link
Copy Markdown
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants