[NativeAOT] System.Runtime.Tests fail under single-file/static-link app bundle
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Description
## Description
When `System.Runtime.Tests.dll` is built with NativeAOT and packaged into an Apple mobile `.app` (iOS / tvOS / MacCatalyst), three tests fail because the test project is statically linked into the app binary with no on-disk managed DLL, and the app's working directory does not point at bundled content files.
Failing tests:
1. `System.Reflection.Tests.ModuleTests.Name` — `Module.Name` returns `""` (expected `"system.runtime.tests.dll"`).
2. `System.Reflection.Tests.ModuleTests.FullyQualifiedName` — `Module.FullyQualifiedName` returns `""` (expected empty).
3. `System.Tests.DoubleTests.ParsePatterns` — `FileNotFoundException` for `/ibm-fpgen.txt`; the test reads `Directory.GetCurrentDirectory() + ibm-fpgen.txt`, but cwd is `/` and `ibm-fpgen.txt` (from the `System.Runtime.Numerics.TestData` content-files NuGet) is not bundled into the `.app`.
### Fix
- `ModuleTests.Name` / `ModuleTests.FullyQualifiedName`: extend the existing `#if SINGLE_FILE_TEST_RUNNER` branch (which already asserts `""`) to cover NativeAOT-on-Apple-mobile. Either define `SINGLE_FILE_TEST_RUNNER` for that build, or replace the `#if` with a runtime check (e.g. `if (PlatformDetection.IsAppleMobile && PlatformDetection.IsNativeAot)`).
- `DoubleTests.ParsePatterns`: bundle `ibm-fpgen.txt` into the `.app` (e.g. `` plus inclusion in `BundleFiles` / AppleAppBuilder resources) and resolve the path via `AppContext.BaseDirectory` instead of `Directory.GetCurrentDirectory()`.
Contributor guide
Assessment
This issue has not been assessed yet.