Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ Copyright (c) .NET Foundation. All rights reserved.
<_WasmWebcilVersion Condition="'$(_WasmWebcilVersion)' == ''">0</_WasmWebcilVersion>
<_BlazorWebAssemblyJiterpreter>$(BlazorWebAssemblyJiterpreter)</_BlazorWebAssemblyJiterpreter>
<_BlazorWebAssemblyRuntimeOptions>$(BlazorWebAssemblyRuntimeOptions)</_BlazorWebAssemblyRuntimeOptions>
<!-- With AOT, each AOT image hard-binds to every assembly it references when the image is
loaded. A BlazorWebAssemblyLazyLoad assembly is not present at runtime startup, so any
AOT image that references it would be marked unusable and its methods would fall back to
the interpreter (which can then hit unsupported constructs and abort). Enable lazy AOT
assembly loading so referenced lazy assemblies are only bound when they are loaded. -->
<_BlazorWebAssemblyRuntimeOptions Condition="'$(RunAOTCompilation)' == 'true' and @(BlazorWebAssemblyLazyLoad->Count()) != 0 and !$(_BlazorWebAssemblyRuntimeOptions.Contains('--aot-lazy-assembly-load'))">$([System.String]::Concat('$(_BlazorWebAssemblyRuntimeOptions)', ' --aot-lazy-assembly-load').Trim())</_BlazorWebAssemblyRuntimeOptions>
Comment thread
lewing marked this conversation as resolved.
<_WasmInlineBootConfig Condition="'$(_WasmInlineBootConfig)' == '' and '$(_TargetingNET100OrLater)' == 'true'">true</_WasmInlineBootConfig>
<_WasmInlineBootConfig Condition="'$(_WasmInlineBootConfig)' == ''">false</_WasmInlineBootConfig>
<!-- true = wasm assets will have hard fingerprint; false = wasm assets won't have even soft fingerprint -->
Expand Down
22 changes: 22 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/LazyLoadingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,28 @@ public async Task LoadLazyAssemblyTwiceIsIdempotent()
Assert.False(result.ConsoleOutput.Any(m => m.Contains("must be marked with 'BlazorWebAssemblyLazyLoad'")), "Reloading an already-loaded lazy assembly must not throw the 'must be marked' error");
}

[Fact]
[TestCategory("native-mono")]
public async Task LoadLazyAssemblyWithAOT()
{
// Regression coverage for https://github.com/dotnet/runtime/issues/125794:
// AOT combined with BlazorWebAssemblyLazyLoad must still initialize the runtime
// and lazily load assemblies at runtime. AOT is only supported when publishing
// in Release, so this exercises the publish + AOT + lazy-load combination that
// the Debug build/run tests above do not cover.
Configuration config = Configuration.Release;
ProjectInfo info = CopyTestAsset(config, aot: true, TestAsset.WasmBasicTestApp, "LazyLoadingTestsAOT");
PublishProject(info, config, new PublishOptions(AOT: true, ExtraMSBuildArgs: "-p:TestLazyLoading=true"));

RunResult result = await RunForPublishWithWebServer(new BrowserRunOptions(
config,
AOT: true,
TestScenario: "LazyLoadingTest"
));

Assert.True(result.TestOutput.Any(m => m.Contains("FirstName")), "The lazy loading test didn't emit expected message with JSON");
Comment thread
lewing marked this conversation as resolved.
}

[Fact]
public async Task FailOnMissingLazyAssembly()
{
Expand Down
Loading