Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
4860837
User can set `GlobalizationShard`.
ilonatommy Dec 14, 2022
234ee73
Sample for sharding, might be transformed into a test.
ilonatommy Dec 14, 2022
6790c0f
Option of custom shard file upload.
ilonatommy Dec 16, 2022
8b293c5
Replaced sample with WBT.
ilonatommy Jan 10, 2023
da5c9bc
Remove unnecessary change.
ilonatommy Jan 10, 2023
5e8b107
Merge branch 'main' into wasm-browser-basic-sharding
ilonatommy Jan 10, 2023
5ad7252
Fixed invariantMode + full custom path + nit.
ilonatommy Jan 10, 2023
a30970e
Draft of documentation.
ilonatommy Jan 10, 2023
147d604
Rename to reflect usage better.
ilonatommy Jan 10, 2023
5d2aa14
Fix full path file loading to the Browser.
ilonatommy Jan 10, 2023
ca4c9fe
Fix.
ilonatommy Jan 10, 2023
ef0782c
Fixed WBT build errors.
ilonatommy Jan 10, 2023
002cbc5
Docs: only one ICU file can be used.
ilonatommy Jan 10, 2023
2354514
Fixed NodeJs: `navigator` is not defined.
ilonatommy Jan 11, 2023
e8b1af5
Paritial fix of sharding tests.
ilonatommy Jan 11, 2023
b3ff241
RuntimePack can differ for AOT and Release.
ilonatommy Jan 11, 2023
348d4bf
Fix `ja-JP` culture not found in CheckDateTimeLocale.
ilonatommy Jan 11, 2023
ef2dc3c
Fixedculture not found in SatelliteAssemblyTests.
ilonatommy Jan 11, 2023
b1b2b52
Fixed culture not found in System.Runtime tests.
ilonatommy Jan 11, 2023
5df3c9c
`icudt.dat` should not be loaded when <IcuFileName> empty + EFIGS con…
ilonatommy Jan 12, 2023
d55aeb3
Improved doc readability using @radical's suggestions.
ilonatommy Jan 12, 2023
d229736
Forgot to remove comments.
ilonatommy Jan 12, 2023
f06aba4
Missing change for 5df3c9ccc851c45fbdbc3acfd96162c3237973c1.
ilonatommy Jan 12, 2023
2d2ef60
WBT: Applied review.
ilonatommy Jan 12, 2023
983e62b
Applied @pavelsavara's suggestion.
ilonatommy Jan 12, 2023
b5a1308
Added `WasmIncludeFullIcuData` to work like Blazor.
ilonatommy Jan 12, 2023
5127929
Another missing change for 5df3c9ccc851c45fbdbc3acfd96162c3237973c1.
ilonatommy Jan 12, 2023
e86f132
Missing change for b5a1308372ed00f1dea08dadd647e97dffe57e27.
ilonatommy Jan 12, 2023
0d2b732
Fix debugger failures for real, previous flag was in the wrong place.
ilonatommy Jan 12, 2023
87caebd
Fixed most libraries that require full ICU.
ilonatommy Jan 13, 2023
3abed9f
Merge branch 'main' into wasm-browser-basic-sharding
ilonatommy Jan 13, 2023
9d5f54c
WBT should load full icu only when invariant off.
ilonatommy Jan 13, 2023
1884b53
Applied @radical's idea.
ilonatommy Jan 16, 2023
ea5785c
Missing change for the last commit.
ilonatommy Jan 16, 2023
04e97e4
Build args should not be edited inside of `BuildProject()` + Identity…
ilonatommy Jan 17, 2023
2d8ec10
One flag for all lib tests instead of multiple changes.
ilonatommy Jan 18, 2023
12408bb
Revert comments for the prev commit.
ilonatommy Jan 18, 2023
cc9750e
Fix for trimming tests.
ilonatommy Jan 18, 2023
821afdc
Rename + throwing when file not found.
ilonatommy Jan 18, 2023
9abdb6c
Fixed NoopNativeRebuildTest WBT.
ilonatommy Jan 18, 2023
beaa6e0
Forgotten logging.
ilonatommy Jan 19, 2023
d332ed9
Tests with custom shard.
ilonatommy Jan 19, 2023
930a295
Added more complex tests.
ilonatommy Jan 19, 2023
ca0e1b8
Should fix wasm tests on helix.
ilonatommy Jan 20, 2023
48f146f
Fix WBT.
ilonatommy Jan 20, 2023
2fab2ec
Merge branch 'main' into wasm-browser-basic-sharding.
ilonatommy Jan 23, 2023
016af2e
Merge branch 'main' into wasm-browser-basic-sharding
ilonatommy Jan 24, 2023
fd07a3c
[wasm] Update eng/testing/scenarios/BuildWasmAppsJobsList.txt
radical Jan 25, 2023
0969201
[wasm] fix testassets path
radical Jan 25, 2023
9b1cd94
Merge remote-tracking branch 'origin/main' into wasm-browser-basic-sh…
radical Jan 25, 2023
125ede2
Default mode for tests should be the same as default mode for templat…
ilonatommy Jan 27, 2023
984716f
Checking preferred icu when assets are still not populated was incorr…
ilonatommy Jan 27, 2023
ad5791e
DataTimeFormat does not work well for browser + wrong condition.
ilonatommy Jan 27, 2023
3c36db4
Removed empty space changes.
ilonatommy Jan 27, 2023
98b17e6
WBT for automatic icu selection based on locale.
ilonatommy Jan 27, 2023
8a39ff5
Moved the full icu flag from libs to lib tests.
ilonatommy Jan 30, 2023
f47d570
Flag in tests.wasm.targets should be enough for trimming tests.
ilonatommy Jan 30, 2023
358ecd4
Debugger tests in default globalization mode unless CJK needed. Firef…
ilonatommy Jan 30, 2023
90c5f4f
Removing forgotten comment.
ilonatommy Jan 30, 2023
5188563
Fixed sharding wbt.
ilonatommy Jan 31, 2023
988b037
This should not be commented out.
ilonatommy Jan 31, 2023
92cced7
Merge branch 'main' into wasm-browser-basic-sharding
ilonatommy Feb 2, 2023
dde05ee
Sharding WBT do not make sense on v8 + fixed debugger tests on Linux …
ilonatommy Feb 3, 2023
6935c7e
Merge branch 'main' into wasm-browser-basic-sharding
ilonatommy Feb 3, 2023
6d6f3bb
Cleanup.
ilonatommy Feb 7, 2023
cbd3803
Merge branch 'main' into wasm-browser-basic-sharding
ilonatommy Feb 7, 2023
63e5e60
Merge branch 'main' into wasm-browser-basic-sharding
ilonatommy Feb 10, 2023
b414f33
Fix test to have sense.
ilonatommy Feb 10, 2023
38a692c
Merge branch 'main' into wasm-browser-basic-sharding
ilonatommy Feb 15, 2023
e66edb0
Fixed tests to reflect expected behavior after removing predefinedCul…
ilonatommy Feb 16, 2023
60199cd
Fixed merge errors, removed redundant comment.
ilonatommy Feb 16, 2023
ca1bd11
Update docs, disable NodeJS in tests.
ilonatommy Feb 22, 2023
30d7096
@radical's review part 1: embedded comments.
ilonatommy Feb 23, 2023
f7c8b20
Merge branch 'main' into wasm-browser-basic-sharding
ilonatommy Feb 23, 2023
8a27d8e
Merge with main and fix strange CI behavior.
ilonatommy Feb 23, 2023
f0484db
Test clean-up by @radical.
ilonatommy Feb 23, 2023
a9a0167
Fix WASI to treat ICU like WASM.
ilonatommy Feb 23, 2023
839bb77
Fix arg order in debugger + revert wasi sharding.
ilonatommy Feb 23, 2023
f080222
It's a list, not a prop.
ilonatommy Feb 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Design Docs
=================

- [.NET Globalization Invariant Mode](design/features/globalization-invariant-mode.md)
- [WASM Globalization Icu](design/features/globalization-icu-wasm.md)
- [Cross-Platform Cryptography](design/features/cross-platform-cryptography.md)
- Many more under [design/features](design/features/)

Expand Down
63 changes: 63 additions & 0 deletions docs/design/features/globalization-icu-wasm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# WASM Globalization Icu

In WASM applications when [globalization invariant mode](globalization-invariant-mode.md) is switched off, internalization data file is loaded. There are four basic types of these files:
- `icudt.dat` - full data
- `icudt_EFIGS.dat` - data for locales: "en-*", "fr-FR", "es-ES", "it-IT", and "de-DE".
- `icudt_CJK.dat` - for locales: "en" "ja", "ko", and "zh".
- `icudt_no_CJK.dat` - all locales from `icudt.dat`, excluding "ja", "ko", and "zh".

## Wasm Console, Wasm Browser

We can specify the file we want to load, e.g. `icudt_no_CJK.dat` by adding to .csproj:
```
<WasmIcuDataFileName>icudt_no_CJK.dat</WasmIcuDataFileName>
```
Only one value for `WasmIcuDataFileName` can be set. It can also be a custom file, created by the developer. To create a custom ICU file, see `Custom ICU` section below. If no `WasmIcuDataFileName` was specified, the application's culture will be checked and the corresponding file will be loaded, e.g. for `en-US` file `icudt_EFIGS.dat`, and for `zh-CN` - `icudt_CJK.dat`.

## Custom ICU

The easiest way to build ICU is to open https://github.com/dotnet/icu/ it in [Codespaces](docs\workflow\Codespaces.md). See files in https://github.com/dotnet/icu/tree/dotnet/main/icu-filters, and read https://unicode-org.github.io/icu/userguide/icu_data/buildtool.html#locale-slicing. Build your own filter or edit the existing file.
We advise to edit the filters **only by adding/removing locales** from the `localeFilter/whitelist` to avoid removing important data. We recommend not to remove "en-US" locale from the localeFilter/whitelist because it is used as a fallback. Removing it for when
- `<PredefinedCulturesOnly>true</PredefinedCulturesOnly>`: results in `Encountered infinite recursion while looking for resource in System.Private.Corelib.` exception
- when predefined cultures only is not set: results in resolving data from ICU's `root.txt` files, e.g. `CultureInfo.DateTimeFormat.GetDayName(DateTime.Today.DayOfWeek)` will return an abbreviated form: `Mon` instead of `Monday`.
Removing specific feature data might result in an exception that starts with `[CultureData.IcuGetLocaleInfo(LocaleStringData)] Failed`. It means you removed data necessary to extract basic information about the locale.

In the file `eng/icu.mk`, you can choose what filters to build. Choose the platform:

### Building for Browser:
* For prerequisites run `.devcontainer/postCreateCommand.sh` (it is run automatically on creation if using Codespaces)
* Building:
```
./build.sh /p:TargetOS=Browser /p:TargetArchitecture=wasm /p:IcuTracing=true
```
Output is located in `artifacts/bin/icu-browser-wasm`.

### Building for Mobiles:
* For prerequisites run:
```bash
export ANDROID_NDK_ROOT=$PWD/artifacts/ndk/
mkdir $ANDROID_NDK_ROOT
wget https://dl.google.com/android/repository/android-ndk-r25b-linux.zip
unzip android-ndk-r25b-linux.zip -d $ANDROID_NDK_ROOT
rm android-ndk-r25b-linux.zip
mv $ANDROID_NDK_ROOT/*/* $ANDROID_NDK_ROOT
rmdir $ANDROID_NDK_ROOT/android-ndk-r25b
```
* Building:
```bash
./build.sh /p:TargetOS=Android /p:TargetArchitecture=x64 /p:IcuTracing=true
```

Output from both builds will be located in subdirectories of `artifacts/bin`. Copy the generated `.dat` files to a suitable location and provide the full path to it in the `.csproj`, e.g.:
```xml
<WasmIcuDataFileName>C:\Users\wasmUser\icuSources\customIcu.dat</WasmIcuDataFileName>
```

## Blazor

In Blazor we are loading the file based on the applications's culture.
To force the full data to be loaded, add this to your `.csproj`:
```xml
<BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
```
Custom files loading for Blazor is not possible.
4 changes: 3 additions & 1 deletion eng/testing/scenarios/BuildWasmAppsJobsList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ Wasm.Build.NativeRebuild.Tests.OptimizationFlagChangeTests
Wasm.Build.NativeRebuild.Tests.ReferenceNewAssemblyRebuildTest
Wasm.Build.NativeRebuild.Tests.SimpleSourceChangeRebuildTest
Wasm.Build.Tests.Blazor.BuildPublishTests
Wasm.Build.Tests.Blazor.MiscTests2
Wasm.Build.Tests.Blazor.MiscTests
Wasm.Build.Tests.Blazor.MiscTests2
Wasm.Build.Tests.Blazor.NativeRefTests
Wasm.Build.Tests.BuildPublishTests
Wasm.Build.Tests.CleanTests
Wasm.Build.Tests.ConfigSrcTests
Wasm.Build.Tests.IcuShardingTests
Wasm.Build.Tests.InvariantGlobalizationTests
Wasm.Build.Tests.MainWithArgsTests
Wasm.Build.Tests.NativeBuildTests
Wasm.Build.Tests.NativeLibraryTests
Wasm.Build.Tests.NonWasmTemplateBuildTests
Wasm.Build.Tests.PInvokeTableGeneratorTests
Wasm.Build.Tests.RebuildTests
Wasm.Build.Tests.SatelliteAssembliesTests
Expand Down
5 changes: 5 additions & 0 deletions eng/testing/tests.browser.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<PropertyGroup>
<IsBrowserWasmProject Condition="'$(IsBrowserWasmProject)' == ''">true</IsBrowserWasmProject>

<!-- some tests require full ICU data, force it for all the tests -->
<WasmIncludeFullIcuData>true</WasmIncludeFullIcuData>

<!-- set this when provisioning emsdk on CI -->
<EMSDK_PATH Condition="'$(EMSDK_PATH)' == '' and '$(ContinuousIntegrationBuild)' == 'true' and '$(MonoProjectRoot)' != ''">$([MSBuild]::NormalizeDirectory($(MonoProjectRoot), 'wasm', 'emsdk'))</EMSDK_PATH>

Expand Down Expand Up @@ -184,6 +187,8 @@
<_WasmPropertyNames Include="DisableParallelEmccCompile" />
<_WasmPropertyNames Include="EmccCompileOptimizationFlag" />
<_WasmPropertyNames Include="EmccLinkOptimizationFlag" />
<_WasmPropertyNames Include="WasmIncludeFullIcuData" />
<_WasmPropertyNames Include="WasmIcuDataFileName" />
</ItemGroup>
</Target>

Expand Down
18 changes: 10 additions & 8 deletions src/mono/wasi/build/WasiApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -319,27 +319,29 @@

<Target Name="_GetWasiGenerateAppBundleDependencies">
<PropertyGroup>
<WasmIcuDataFileName Condition="'$(InvariantGlobalization)' != 'true'">icudt.dat</WasmIcuDataFileName>

<_HasDotnetWasm Condition="'%(WasmNativeAsset.FileName)%(WasmNativeAsset.Extension)' == 'dotnet.wasm'">true</_HasDotnetWasm>
</PropertyGroup>

<ItemGroup>
<!-- If dotnet.{wasm,js} weren't added already (eg. AOT can add them), then add the default ones -->
<WasmNativeAsset Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)dotnet.wasm" Condition="'$(_HasDotnetWasm)' != 'true'" />

<WasmNativeAsset Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)$(WasmIcuDataFileName)" Condition="'$(InvariantGlobalization)' != 'true'" />
<WasmNativeAsset Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)dotnet.timezones.blat" />

<WasmFilesToIncludeInFileSystem Include="@(WasmNativeAsset)" Condition="'%(WasmNativeAsset.FileName)%(WasmNativeAsset.Extension)' == 'dotnet.js.symbols'" />
</ItemGroup>

<ItemGroup Condition="'$(InvariantGlobalization)' != 'true'">
<WasmIcuDataFileNames Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)icudt.dat"/>
<WasmNativeAsset Include="@(WasmIcuDataFileNames)"/>
</ItemGroup>
</Target>

<Target Name="_WasiGenerateAppBundle"
Inputs="@(_WasmAssembliesInternal);$(WasmIcuDataFileName);@(WasmNativeAsset)"
Inputs="@(_WasmAssembliesInternal);@(WasmNativeAsset)"
Outputs="$(WasmAppDir)\.stamp"
Condition="'$(WasmGenerateAppBundle)' == 'true'"
DependsOnTargets="_WasmGenerateRuntimeConfig;_GetWasiGenerateAppBundleDependencies;_WasiDefaultGenerateAppBundle;_GenerateRunWasmtimeScript" />
DependsOnTargets="_WasmGenerateRuntimeConfig;_GetWasiGenerateAppBundleDependencies;_WasiDefaultGenerateAppBundle;_GenerateRunWasmtimeScript">
</Target>


<Target Name="_WasiDefaultGenerateAppBundle">

Expand All @@ -353,7 +355,7 @@
DefaultHostConfig="$(DefaultWasmHostConfig)"
InvariantGlobalization="$(InvariantGlobalization)"
SatelliteAssemblies="@(_WasmSatelliteAssemblies)"
IcuDataFileName="$(WasmIcuDataFileName)"
IcuDataFileNames="@(WasmIcuDataFileNames)"
ExtraFilesToDeploy="@(WasmExtraFilesToDeploy)"
NativeAssets="@(WasmNativeAsset)"
DebugLevel="$(WasmDebugLevel)"
Expand Down
124 changes: 97 additions & 27 deletions src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public abstract class BuildTestBase : IClassFixture<SharedBuildPerTestClassFixtu
{
public const string DefaultTargetFramework = "net8.0";
public const string DefaultTargetFrameworkForBlazor = "net8.0";
private const string DefaultEnvironmentLocale = "en-US";
protected static readonly bool s_skipProjectCleanup;
protected static readonly string s_xharnessRunnerCommand;
protected string? _projectDir;
Expand All @@ -39,8 +40,13 @@ public abstract class BuildTestBase : IClassFixture<SharedBuildPerTestClassFixtu
protected SharedBuildPerTestClassFixture _buildContext;
protected string _nugetPackagesDir = string.Empty;

private static bool s_isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
// changing Windows's language programistically is complicated and Node is using OS's language to determine
// what is client's preferred locale and then to load corresponding ICU => skip automatic icu testing with Node
// on Linux sharding does not work because we rely on LANG env var to check locale and emcc is overwriting it
protected static RunHost s_hostsForOSLocaleSensitiveTests = RunHost.Chrome;
// FIXME: use an envvar to override this
protected static int s_defaultPerTestTimeoutMs = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? 30*60*1000 : 15*60*1000;
protected static int s_defaultPerTestTimeoutMs = s_isWindows ? 30*60*1000 : 15*60*1000;
protected static BuildEnvironment s_buildEnv;
private const string s_runtimePackPathPattern = "\\*\\* MicrosoftNetCoreAppRuntimePackDir : '([^ ']*)'";
private const string s_nugetInsertionTag = "<!-- TEST_RESTORE_SOURCES_INSERTION_LINE -->";
Expand Down Expand Up @@ -139,7 +145,8 @@ protected string RunAndTestWasmApp(BuildArgs buildArgs,
string targetFramework = DefaultTargetFramework,
string? extraXHarnessMonoArgs = null,
string? extraXHarnessArgs = null,
string jsRelativePath = "test-main.js")
string jsRelativePath = "test-main.js",
string environmentLocale = DefaultEnvironmentLocale)
{
buildDir ??= _projectDir;
envVars ??= new();
Expand All @@ -157,16 +164,15 @@ protected string RunAndTestWasmApp(BuildArgs buildArgs,
}

bundleDir ??= Path.Combine(GetBinDir(baseDir: buildDir, config: buildArgs.Config, targetFramework: targetFramework), "AppBundle");
if (host is RunHost.V8 && OperatingSystem.IsWindows())
IHostRunner hostRunner = GetHostRunnerFromRunHost(host);
if (!hostRunner.CanRunWBT())
throw new InvalidOperationException("Running tests with V8 on windows isn't supported");

// Use wasm-console.log to get the xharness output for non-browser cases
(string testCommand, string xharnessArgs, bool useWasmConsoleOutput) = host switch
{
RunHost.V8 => ("wasm test", $"--js-file={jsRelativePath} --engine=V8 -v trace", true),
RunHost.NodeJS => ("wasm test", $"--js-file={jsRelativePath} --engine=NodeJS -v trace", true),
_ => ("wasm test-browser", $"-v trace -b {host} --web-server-use-cop", false)
};
string testCommand = hostRunner.GetTestCommand();
XHarnessArgsOptions options = new XHarnessArgsOptions(jsRelativePath, environmentLocale, host);
string xharnessArgs = s_isWindows ? hostRunner.GetXharnessArgsWindowsOS(options) : hostRunner.GetXharnessArgsOtherOS(options);
bool useWasmConsoleOutput = hostRunner.UseWasmConsoleOutput();

extraXHarnessArgs += " " + xharnessArgs;

Expand Down Expand Up @@ -336,7 +342,7 @@ protected static BuildArgs ExpandBuildArgs(BuildArgs buildArgs, string extraProp
if (buildArgs.AOT)
{
extraProperties = $"{extraProperties}\n<RunAOTCompilation>true</RunAOTCompilation>";
extraProperties += $"\n<EmccVerbose>{RuntimeInformation.IsOSPlatform(OSPlatform.Windows)}</EmccVerbose>\n";
extraProperties += $"\n<EmccVerbose>{s_isWindows}</EmccVerbose>\n";
}

if (UseWebcil) {
Expand Down Expand Up @@ -429,7 +435,8 @@ protected static BuildArgs ExpandBuildArgs(BuildArgs buildArgs, string extraProp
options.MainJS ?? "test-main.js",
options.HasV8Script,
options.TargetFramework ?? DefaultTargetFramework,
options.HasIcudt,
options.GlobalizationMode,
options.PredefinedIcudt ?? "",
options.DotnetWasmFromRuntimePack ?? !buildArgs.AOT,
UseWebcil);
}
Expand Down Expand Up @@ -633,7 +640,8 @@ protected static void AssertBasicAppBundle(string bundleDir,
string mainJS,
bool hasV8Script,
string targetFramework,
bool hasIcudt = true,
GlobalizationMode? globalizationMode,
string predefinedIcudt = "",
bool dotnetWasmFromRuntimePack = true,
bool useWebcil = true)
{
Expand All @@ -648,7 +656,7 @@ protected static void AssertBasicAppBundle(string bundleDir,
});

AssertFilesExist(bundleDir, new[] { "run-v8.sh" }, expectToExist: hasV8Script);
AssertFilesExist(bundleDir, new[] { "icudt.dat" }, expectToExist: hasIcudt);
AssertIcuAssets();

string managedDir = Path.Combine(bundleDir, "managed");
string bundledMainAppAssembly =
Expand All @@ -670,6 +678,53 @@ protected static void AssertBasicAppBundle(string bundleDir,
}

AssertDotNetWasmJs(bundleDir, fromRuntimePack: dotnetWasmFromRuntimePack, targetFramework);

void AssertIcuAssets()
{
bool expectEFIGS = false;
bool expectCJK = false;
bool expectNOCJK = false;
bool expectFULL = false;
switch (globalizationMode)
{
case GlobalizationMode.Invariant:
break;
case GlobalizationMode.FullIcu:
expectFULL = true;
break;
case GlobalizationMode.PredefinedIcu:
if (string.IsNullOrEmpty(predefinedIcudt))
throw new ArgumentException("WasmBuildTest is invalid, value for predefinedIcudt is required when GlobalizationMode=PredefinedIcu.");
AssertFilesExist(bundleDir, new[] { predefinedIcudt }, expectToExist: true);
// predefined ICU name can be identical with the icu files from runtime pack
switch (predefinedIcudt)
{
case "icudt.dat":
expectFULL = true;
break;
case "icudt_EFIGS.dat":
expectEFIGS = true;
break;
case "icudt_CJK.dat":
expectCJK = true;
break;
case "icudt_no_CJK.dat":
expectNOCJK = true;
break;
}
break;
default:
// icu shard chosen based on the locale
expectCJK = true;
expectEFIGS = true;
expectNOCJK = true;
break;
}
AssertFilesExist(bundleDir, new[] { "icudt.dat" }, expectToExist: expectFULL);
AssertFilesExist(bundleDir, new[] { "icudt_EFIGS.dat" }, expectToExist: expectEFIGS);
AssertFilesExist(bundleDir, new[] { "icudt_CJK.dat" }, expectToExist: expectCJK);
AssertFilesExist(bundleDir, new[] { "icudt_no_CJK.dat" }, expectToExist: expectNOCJK);
}
}

protected static void AssertDotNetWasmJs(string bundleDir, bool fromRuntimePack, string targetFramework)
Expand Down Expand Up @@ -1093,6 +1148,13 @@ public static int Main()
return 42;
}
}";

private IHostRunner GetHostRunnerFromRunHost(RunHost host) => host switch
{
RunHost.V8 => new V8HostRunner(),
RunHost.NodeJS => new NodeJSHostRunner(),
_ => new BrowserHostRunner(),
};
}

public record BuildArgs(string ProjectName,
Expand All @@ -1106,20 +1168,21 @@ internal record BuildPaths(string ObjWasmDir, string ObjDir, string BinDir, stri

public record BuildProjectOptions
(
Action? InitProject = null,
bool? DotnetWasmFromRuntimePack = null,
bool HasIcudt = true,
bool UseCache = true,
bool ExpectSuccess = true,
bool AssertAppBundle = true,
bool CreateProject = true,
bool Publish = true,
bool BuildOnlyAfterPublish = true,
bool HasV8Script = true,
string? Verbosity = null,
string? Label = null,
string? TargetFramework = null,
string? MainJS = null,
Action? InitProject = null,
bool? DotnetWasmFromRuntimePack = null,
GlobalizationMode? GlobalizationMode = null,
string? PredefinedIcudt = null,
bool UseCache = true,
bool ExpectSuccess = true,
bool AssertAppBundle = true,
bool CreateProject = true,
bool Publish = true,
bool BuildOnlyAfterPublish = true,
bool HasV8Script = true,
string? Verbosity = null,
string? Label = null,
string? TargetFramework = null,
string? MainJS = null,
IDictionary<string, string>? ExtraBuildEnvironmentVariables = null
);

Expand All @@ -1132,5 +1195,12 @@ public record BlazorBuildOptions
bool WarnAsError = true
);

public enum GlobalizationMode
{
Invariant, // no icu
FullIcu, // full icu data: icudt.dat is loaded
PredefinedIcu // user set WasmIcuDataFileName value and we are loading that file
};

public enum NativeFilesType { FromRuntimePack, Relinked, AOT };
}
Loading