chore: Add support for WasmShellLoadAllSatelliteResources

This commit is contained in:
Jerome Laban 2024-09-12 10:54:19 -04:00
Родитель 7fa801bf05
Коммит 579e06ba8b
8 изменённых файлов: 43 добавлений и 2 удалений

Просмотреть файл

@ -14,6 +14,14 @@ dotnet publish
The app will be located in the `bin/Release/net9.0/publish/wwwroot` folder. More information about `dotnet publish` can be [found in the Microsoft docs](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish). The app will be located in the `bin/Release/net9.0/publish/wwwroot` folder. More information about `dotnet publish` can be [found in the Microsoft docs](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish).
## Localization publishing
By default, the .NET runtime does not load all resource assemblies, but if you want to load all resources regardless of the user's culture, you can add the following to your project file:
```xml
<PropertyGroup>
<WasmShellLoadAllSatelliteResources>true</WasmShellLoadAllSatelliteResources>
</PropertyGroup>
```
## Integration with ASP.NET Core ## Integration with ASP.NET Core
ASP.NET Core hosting is supported through the `Uno.Wasm.Bootstrap.Server` package. ASP.NET Core hosting is supported through the `Uno.Wasm.Bootstrap.Server` package.

Просмотреть файл

@ -88,6 +88,13 @@ Once done, make sure to install the WebAssembly tools from .NET:
dotnet workload install wasm-tools dotnet workload install wasm-tools
``` ```
By default, the .NET runtime does not load all resource assemblies, but if you want to load all resources regardless of the user's culture, you can add the following to your project file:
```xml
<PropertyGroup>
<WasmShellLoadAllSatelliteResources>true</WasmShellLoadAllSatelliteResources>
</PropertyGroup>
```
## Bootstrapper versions and .NET runtimes ## Bootstrapper versions and .NET runtimes
Each major version of the bootstrapper targets a different version of the .NET Runtime. Each major version of the bootstrapper targets a different version of the .NET Runtime.
@ -103,3 +110,8 @@ Each major version of the bootstrapper targets a different version of the .NET R
> >
> [!NOTE] > [!NOTE]
> Bootstrapper builds version 4.x-dev were based on developments builds of .NET 7 and were later versioned 7.x-dev to match the appropriate runtime. > Bootstrapper builds version 4.x-dev were based on developments builds of .NET 7 and were later versioned 7.x-dev to match the appropriate runtime.
## Previous releases documentation
- [8.0.x](https://github.com/unoplatform/Uno.Wasm.Bootstrap/tree/release/stable/8.0/doc)
- [7.0.x](https://github.com/unoplatform/Uno.Wasm.Bootstrap/tree/release/stable/7.0/doc)
- [3.x](https://github.com/unoplatform/Uno.Wasm.Bootstrap/tree/release/stable/3.3/doc)

Просмотреть файл

@ -102,6 +102,8 @@ namespace Uno.Wasm.Bootstrap
public bool EnableTracing { get; set; } public bool EnableTracing { get; set; }
public bool LoadAllSatelliteResources { get; set; }
public string AotProfile { get; set; } = ""; public string AotProfile { get; set; } = "";
public bool RunAOTCompilation { get; set; } public bool RunAOTCompilation { get; set; }
@ -531,6 +533,7 @@ namespace Uno.Wasm.Bootstrap
config.AppendLine($"config.uno_shell_mode = \"{_shellMode}\";"); config.AppendLine($"config.uno_shell_mode = \"{_shellMode}\";");
config.AppendLine($"config.uno_debugging_enabled = {(!Optimize).ToString().ToLowerInvariant()};"); config.AppendLine($"config.uno_debugging_enabled = {(!Optimize).ToString().ToLowerInvariant()};");
config.AppendLine($"config.uno_enable_tracing = {EnableTracing.ToString().ToLowerInvariant()};"); config.AppendLine($"config.uno_enable_tracing = {EnableTracing.ToString().ToLowerInvariant()};");
config.AppendLine($"config.uno_load_all_satellite_resources = {LoadAllSatelliteResources.ToString().ToLowerInvariant()};");
config.AppendLine($"config.emcc_exported_runtime_methods = [{emccExportedRuntimeMethodsParams}];"); config.AppendLine($"config.emcc_exported_runtime_methods = [{emccExportedRuntimeMethodsParams}];");
if (GenerateAOTProfile) if (GenerateAOTProfile)

Просмотреть файл

@ -254,6 +254,7 @@
GenerateAOTProfile="$(WasmShellGenerateAOTProfile)" GenerateAOTProfile="$(WasmShellGenerateAOTProfile)"
IndexHtmlPath="$(WasmShellIndexHtmlPath)" IndexHtmlPath="$(WasmShellIndexHtmlPath)"
IntermediateOutputPath="$(IntermediateOutputPath)" IntermediateOutputPath="$(IntermediateOutputPath)"
LoadAllSatelliteResources="$(WasmShellLoadAllSatelliteResources)"
LogProfilerOptions="$(WasmShellLogProfilerOptions)" LogProfilerOptions="$(WasmShellLogProfilerOptions)"
MonoEnvironment="@(WasmShellMonoEnvironment)" MonoEnvironment="@(WasmShellMonoEnvironment)"
PublishTrimmed="$(PublishTrimmed)" PublishTrimmed="$(PublishTrimmed)"

Просмотреть файл

@ -101,7 +101,8 @@ namespace Uno.WebAssembly.Bootstrap {
.withModuleConfig({ .withModuleConfig({
preRun: () => bootstrapper.wasmRuntimePreRun(), preRun: () => bootstrapper.wasmRuntimePreRun(),
}) })
.withRuntimeOptions(config.config.uno_runtime_options); .withRuntimeOptions(config.config.uno_runtime_options)
.withConfig({ loadAllSatelliteResources: config.config.uno_loadAllSatelliteResources });
const dotnetRuntime = await m.default( const dotnetRuntime = await m.default(
(context: DotnetPublicAPI) => { (context: DotnetPublicAPI) => {

Просмотреть файл

@ -32,5 +32,7 @@
uno_debugging_enabled?: boolean; uno_debugging_enabled?: boolean;
uno_runtime_options?: string[]; uno_runtime_options?: string[];
uno_load_all_satellite_resources?: string[];
} }
} }

Просмотреть файл

@ -19,6 +19,8 @@ using System.Threading;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Globalization; using System.Globalization;
using System.Runtime.InteropServices.JavaScript;
using System.Threading.Tasks;
namespace Uno.Wasm.Sample namespace Uno.Wasm.Sample
{ {
@ -59,13 +61,20 @@ namespace Uno.Wasm.Sample
#endif #endif
Console.WriteLine($"requireJSAvailable: {requireAvailable}"); Console.WriteLine($"requireJSAvailable: {requireAvailable}");
Console.WriteLine($"CultureInfo.CurrentCulture: {CultureInfo.CurrentCulture}");
Console.WriteLine($"CultureInfo.CurrentUICulture: {CultureInfo.CurrentUICulture}");
Console.WriteLine($"Thread.CurrentThread.CurrentCulture: {Thread.CurrentThread.CurrentCulture}");
Console.WriteLine($"Thread.CurrentThread.CurrentUICulture: {Thread.CurrentThread.CurrentUICulture}");
Console.WriteLine($"CultureInfo.DefaultThreadCurrentCulture: { CultureInfo.DefaultThreadCurrentCulture?.ToString() ?? "<null>" }");
Console.WriteLine($"CultureInfo.DefaultThreadCurrentUICulture: { CultureInfo.DefaultThreadCurrentUICulture?.ToString() ?? "<null>"}");
Console.WriteLine($"Timezone: {TimeZoneInfo.Local.StandardName}"); Console.WriteLine($"Timezone: {TimeZoneInfo.Local.StandardName}");
Console.WriteLine(typeof(Microsoft.Extensions.Logging.Abstractions.NullLogger)); Console.WriteLine(typeof(Microsoft.Extensions.Logging.Abstractions.NullLogger));
var r = new System.Resources.ResourceManager("FxResources.System.Web.Services.Description.SR", typeof(System.Web.Services.Description.Binding).Assembly); var r = new System.Resources.ResourceManager("FxResources.System.Web.Services.Description.SR", typeof(System.Web.Services.Description.Binding).Assembly);
Console.WriteLine($"Res(en): {r.GetString("WebDescriptionMissing", new CultureInfo("en-US"))}"); Console.WriteLine($"Res(en): {r.GetString("WebDescriptionMissing", new CultureInfo("en-US"))}");
Console.WriteLine($"Res(fr): {r.GetString("WebDescriptionMissing", new CultureInfo("fr-CA"))}"); Console.WriteLine($"Res(fr): {r.GetString("WebDescriptionMissing", new CultureInfo("fr"))}");
_t = new Timer(_ => { _t = new Timer(_ => {
Console.WriteLine("message"); Console.WriteLine("message");
@ -84,6 +93,9 @@ namespace Uno.Wasm.Sample
[System.Runtime.InteropServices.JavaScript.JSImport("globalThis.isRequireAvailable")] [System.Runtime.InteropServices.JavaScript.JSImport("globalThis.isRequireAvailable")]
public static partial bool IsRequireAvailable(); public static partial bool IsRequireAvailable();
[JSImport("INTERNAL.loadSatelliteAssemblies")]
internal static partial Task LoadSatelliteAssemblies(string[] culturesToLoad);
} }
#endif #endif

Просмотреть файл

@ -21,6 +21,8 @@
<PropertyGroup> <PropertyGroup>
<AssemblyName>Uno.Wasm.SampleNet7</AssemblyName> <AssemblyName>Uno.Wasm.SampleNet7</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<WasmShellLoadAllSatelliteResources>true</WasmShellLoadAllSatelliteResources>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>