Skip to content

Commit 72e6094

Browse files
EvangelinkCopilot
andcommitted
Address review comments and fix CA1416 on wasi target
Program.cs: - Drop AddHangDumpProvider() registration: PR #8564 marked it [UnsupportedOSPlatform(\"wasi\")], so CA1416 now flags the call site in a wasi-wasm sample. Hang dumps rely on System.Diagnostics.Process which is not available on wasi; leave a comment in place of the call to explain the intentional omission. README.md: - Replace the hard-coded runtime-pack version 10.0.7 (already out of sync with global.json 10.0.8) with a 'dir /b' lookup followed by a <runtime-version> placeholder. - Clarify InvariantGlobalization=true: it prevents the trimmer from crashing during publish but the pre-built dotnet.wasm still loads ICU at runtime, so step 2 is still required. - Link the tracked async-Main blocker to #5366 instead of saying 'Tracked separately'. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent dd41c90 commit 72e6094

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

‎samples/WasiPlayground/Program.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
testApplicationBuilder.AddTrxReportProvider();
1515
testApplicationBuilder.AddAppInsightsTelemetryProvider();
1616
testApplicationBuilder.AddCrashDumpProvider();
17-
testApplicationBuilder.AddHangDumpProvider();
17+
// AddHangDumpProvider is intentionally not registered: hang dumps rely on
18+
// System.Diagnostics.Process which is unsupported on wasi (see #8564).
1819
testApplicationBuilder.AddAzureDevOpsProvider();
1920
using ITestApplication testApplication = await testApplicationBuilder.BuildAsync();
2021
return await testApplication.RunAsync();

‎samples/WasiPlayground/README.md‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,15 @@ Then:
2323
dotnet publish samples\WasiPlayground\WasiPlayground.csproj -c Debug -f net10.0
2424
```
2525

26-
2. The pre-built `dotnet.wasm` does not embed the ICU data file, so copy it next to the bundle:
26+
2. The pre-built `dotnet.wasm` does not embed the ICU data file, so copy it
27+
next to the bundle. First list the installed runtime-pack version (a
28+
single folder name such as `10.0.8`), then substitute it into the copy
29+
command:
2730

2831
```cmd
29-
copy .dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.wasi-wasm\10.0.7\runtimes\wasi-wasm\native\icudt.dat ^
32+
dir /b .dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.wasi-wasm
33+
34+
copy .dotnet\packs\Microsoft.NETCore.App.Runtime.Mono.wasi-wasm\<runtime-version>\runtimes\wasi-wasm\native\icudt.dat ^
3035
artifacts\bin\WasiPlayground\Debug\net10.0\wasi-wasm\AppBundle\
3136
```
3237

@@ -56,8 +61,8 @@ System.PlatformNotSupportedException: Arg_PlatformNotSupported
5661
The exception comes from the C# compiler's synthetic `Main` wrapper for
5762
`async Task Main`, which calls `Task.GetAwaiter().GetResult()` &rarr;
5863
`Task.Wait()`. On single-threaded `wasi-wasm` (no thread pool) this throws
59-
`PlatformNotSupportedException`. Tracked separately so this sample can act as
60-
the canonical repro.
64+
`PlatformNotSupportedException`. Tracked in [#5366](https://github.com/microsoft/testfx/issues/5366)
65+
so this sample can act as the canonical repro.
6166

6267
## Build configuration notes
6368

@@ -67,5 +72,5 @@ the canonical repro.
6772
| --- | --- |
6873
| `UsingWasiRuntimeWorkload=true` | Workaround for an SDK manifest bug in `11.0.100-preview.5` where `$(UsingWasiRuntimeWorkload)` never resolves to `true` for net10.0 projects, so the WASI Sdk targets are never imported and no `dotnet.wasm` is produced. |
6974
| `WasmSingleFileBundle=false` | Single-file bundling requires the [wasi-sdk](https://github.com/WebAssembly/wasi-sdk) (clang) toolchain to relink the native runtime. Keeping the managed assemblies on disk avoids that requirement. |
70-
| `InvariantGlobalization=true` | Trimmed builds otherwise crash on startup trying to load `icudt.dat`. |
75+
| `InvariantGlobalization=true` | Prevents the trimmer from crashing during publish, but the pre-built `dotnet.wasm` still loads ICU at runtime, so `icudt.dat` must still be staged next to the bundle (see step 2). |
7176

0 commit comments

Comments
 (0)