Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[iOS] Mono IL trimmer incorrectly evaluates RuntimeInformation.IsOSPlatform during aggressive trimming #126882

Copy link
Copy link

Description

@kotlarmilos
Issue body actions

Description

When cross-compiling for Apple mobile (iOS/tvOS) with EnableAggressiveTrimming=true using the Mono runtime, the Mono IL trimmer incorrectly evaluates PlatformDetection.IsWindows as true. The call chain passes through RuntimeInformation.IsOSPlatform(OSPlatform.Windows)OperatingSystem.IsOSPlatform("WINDOWS"), which performs a runtime string comparison against the OSPlatformName constant.

Repro

Discovered via the FileVersionInfo_CustomManagedAssembly test (PR #126872). The test uses PlatformDetection.IsWindows to select the expected file extension:

private readonly string OriginalTestAssemblyInternalName = PlatformDetection.IsWindows ?
    "System.Diagnostics.FileVersionInfo.TestAssembly.dll" :
    "System.Diagnostics.FileVersionInfo.TestAssembly.exe";

When cross-compiled targeting iOS (Mono runtime, EnableAggressiveTrimming=true), the field gets the Windows value (.dll) despite running on iOS, causing:

Assert.Equal() Failure: Strings differ
Expected: ···"ystem.Diagnostics.FileVersionInfo.TestAssembly.dll"
Actual:   ···"ystem.Diagnostics.FileVersionInfo.TestAssembly.exe"

Call Chain

  1. PlatformDetection.IsWindowsRuntimeInformation.IsOSPlatform(OSPlatform.Windows) (PlatformDetection.Windows.cs:20)
  2. RuntimeInformation.IsOSPlatform(OSPlatform)OperatingSystem.IsOSPlatform(osPlatform.Name) (RuntimeInformation.cs:26)
  3. OperatingSystem.IsOSPlatform(string) → compares against OSPlatformName, a compile-time constant set via #if TARGET_* (OperatingSystem.cs:14-47, 127-138)

Context

Build Information

Build: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1378235&view=results
Build error leg or test failing: FileVersionInfo_CustomManagedAssembly
Pull request: #126872

Error Message

Fill the error message using step by step known issues guidance.

{
  "ErrorMessage": "[FAIL] System.Diagnostics.Tests.FileVersionInfoTest.FileVersionInfo_CustomManagedAssembly",
  "BuildRetry": false,
  "ExcludeConsoleLog": false
}

Known issue validation

Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=1378235
Error message validated: [[FAIL] System.Diagnostics.Tests.FileVersionInfoTest.FileVersionInfo_CustomManagedAssembly]
Result validation: ✅ Known issue matched with the provided build.
Validation performed at: 4/15/2026 9:56:28 AM UTC

Report

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
0 0 0
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Known Build ErrorUse this to report build issues in the .NET Helix tabUse this to report build issues in the .NET Helix tabarea-Tools-ILLink.NET linker development as well as trimming analyzers.NET linker development as well as trimming analyzersbugos-iosApple iOSApple iOSuntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    Status
    No status
    Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.