Fix FileVersionInfo test failure on Apple mobile with trimming#126872
Fix FileVersionInfo test failure on Apple mobile with trimming#126872kotlarmilos wants to merge 1 commit intodotnet:mainfrom
Conversation
Use OperatingSystem.IsWindows() instead of PlatformDetection.IsWindows for the OriginalTestAssemblyInternalName field initializer. On Apple mobile CI, EnableAggressiveTrimming=true causes PlatformDetection.IsWindows (which chains through RuntimeInformation.IsOSPlatform) to be incorrectly evaluated during cross-compilation trimming. OperatingSystem.IsWindows() is a compile-time constant in the BCL, immune to trimmer mis-evaluation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes a trimming-related test expectation bug for Apple mobile (iOS/tvOS) by avoiding a runtime OS check (PlatformDetection.IsWindows) that can be mis-evaluated during cross-compilation + aggressive trimming, and instead using OperatingSystem.IsWindows() to select the expected internal-name extension.
Changes:
- Update
FileVersionInfo_CustomManagedAssemblyexpectedInternalName/OriginalFilenameextension selection to useOperatingSystem.IsWindows().
|
Tagging subscribers to 'os-ios': @vitek-karas, @kotlarmilos, @steveisok, @akoeplinger |
|
/azp run runtime-ioslike |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
The test is passing in runtime-ioslike pipeline: https://helix.dot.net/api/jobs/5906f052-6013-4ecd-96eb-7c3d494e21ab/workitems?api-version=2019-06-17 |
jkotas
left a comment
There was a problem hiding this comment.
PlatformDetection.IsWindows chains through RuntimeInformation.IsOSPlatform(OSPlatform.Windows), which appears to be incorrectly evaluated by the IL trimmer during cross-compilation (Windows host → iOS target), causing the field to be initialized with the Windows value (.dll) on iOS.
We should fix the IL trimmer evaluation during cross-compilation instead of this workaround.
|
Created a tracking issue and closing this PR: #126882 |
Note
PR description was AI/Copilot-generated.
Summary
Fixes
FileVersionInfo_CustomManagedAssemblytest failure on Apple mobile (iOS/tvOS) when running withEnableAggressiveTrimming=true.Problem
The test expected
InternalNamewith.dllextension on iOS, but the actual value was.exe. The field initializer usedPlatformDetection.IsWindowsto determine the expected extension:PlatformDetection.IsWindowschains throughRuntimeInformation.IsOSPlatform(OSPlatform.Windows), which appears to be incorrectly evaluated by the IL trimmer during cross-compilation (Windows host → iOS target), causing the field to be initialized with the Windows value (.dll) on iOS.Fix
Replace
PlatformDetection.IsWindowswithOperatingSystem.IsWindows(), which is a compile-time constant (#if TARGET_WINDOWS) in the BCL and is immune to trimmer mis-evaluation.Test Failure