Skip to content

Commit 628ce61

Browse files
authored
Merge pull request #26688 from dotnet-maestro-bot/merge/release/5.0-to-master
[automated] Merge branch 'release/5.0' => 'master'
2 parents dbdfca4 + 84e9f56 commit 628ce61

15 files changed

+171
-17
lines changed

src/Components/Web.JS/dist/Release/blazor.server.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/dist/Release/blazor.webassembly.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/src/Platform/Mono/MonoPlatform.ts

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ function createEmscriptenModuleInstance(resourceLoader: WebAssemblyResourceLoade
334334
return BINDING.js_to_mono_obj(Promise.resolve(0));
335335
}
336336

337+
const lazyResources: {
338+
assemblies?: (ArrayBuffer | null)[],
339+
pdbs?: (ArrayBuffer | null)[]
340+
} = {};
337341
window['Blazor']._internal.getLazyAssemblies = (assembliesToLoadDotNetArray: System_Array<System_String>): System_Object => {
338342
const assembliesToLoad = BINDING.mono_array_to_js_array<System_String, string>(assembliesToLoadDotNetArray);
339343
const lazyAssemblies = resourceLoader.bootConfig.resources.lazyAssembly;
@@ -364,31 +368,40 @@ function createEmscriptenModuleInstance(resourceLoader: WebAssemblyResourceLoade
364368
.map(assembly => resourceLoader.loadResource(assembly, `_framework/${assembly}`, lazyAssemblies[assembly], 'assembly'))
365369
.map(async resource => (await resource.response).arrayBuffer()));
366370

371+
367372
return BINDING.js_to_mono_obj(
368373
Promise.all([resourcePromises, pdbPromises]).then(values => {
369-
const resourcesToLoad = values[0];
370-
const pdbsToLoad = values[1];
371-
if (resourcesToLoad.length) {
374+
lazyResources["assemblies"] = values[0];
375+
lazyResources["pdbs"] = values[1];
376+
if (lazyResources["assemblies"].length) {
372377
window['Blazor']._internal.readLazyAssemblies = () => {
373-
const assemblyBytes = BINDING.mono_obj_array_new(resourcesToLoad.length);
374-
for (let i = 0; i < resourcesToLoad.length; i++) {
375-
const assembly = resourcesToLoad[i] as ArrayBuffer;
378+
const { assemblies } = lazyResources;
379+
if (!assemblies) {
380+
return BINDING.mono_obj_array_new(0);
381+
}
382+
const assemblyBytes = BINDING.mono_obj_array_new(assemblies.length);
383+
for (let i = 0; i < assemblies.length; i++) {
384+
const assembly = assemblies[i] as ArrayBuffer;
376385
BINDING.mono_obj_array_set(assemblyBytes, i, BINDING.js_typed_array_to_array(new Uint8Array(assembly)));
377386
}
378387
return assemblyBytes;
379388
};
380389

381390
window['Blazor']._internal.readLazyPdbs = () => {
382-
const pdbBytes = BINDING.mono_obj_array_new(resourcesToLoad.length);
383-
for (let i = 0; i < resourcesToLoad.length; i++) {
384-
const pdb = pdbsToLoad && pdbsToLoad[i] ? new Uint8Array(pdbsToLoad[i] as ArrayBufferLike) : new Uint8Array();
391+
const { assemblies, pdbs } = lazyResources;
392+
if (!assemblies) {
393+
return BINDING.mono_obj_array_new(0);
394+
}
395+
const pdbBytes = BINDING.mono_obj_array_new(assemblies.length);
396+
for (let i = 0; i < assemblies.length; i++) {
397+
const pdb = pdbs && pdbs[i] ? new Uint8Array(pdbs[i] as ArrayBufferLike) : new Uint8Array();
385398
BINDING.mono_obj_array_set(pdbBytes, i, BINDING.js_typed_array_to_array(pdb));
386399
}
387400
return pdbBytes;
388401
};
389402
}
390403

391-
return resourcesToLoad.length;
404+
return lazyResources["assemblies"].length;
392405
}));
393406
}
394407
});

src/Components/test/E2ETest/Tests/WebAssemblyLazyLoadTest.cs

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void CanLazyLoadOnRouteChange()
4949
// Visit the route for the lazy-loaded assembly
5050
SetUrlViaPushState("/WithLazyAssembly");
5151

52-
var button = app.FindElement(By.Id("use-package-button"));
52+
var button = Browser.Exists(By.Id("use-package-button"));
5353

5454
// Now we should have requested the DLL
5555
Assert.True(HasLoadedAssembly("Newtonsoft.Json.dll"));
@@ -100,11 +100,11 @@ public void CanLazyLoadAssemblyWithRoutes()
100100
// Now the assembly has been loaded
101101
Assert.True(HasLoadedAssembly("LazyTestContentPackage.dll"));
102102

103-
var button = app.FindElement(By.Id("go-to-lazy-route"));
103+
var button = Browser.Exists(By.Id("go-to-lazy-route"));
104104
button.Click();
105105

106106
// Navigating the lazy-loaded route should show its content
107-
var renderedElement = app.FindElement(By.Id("lazy-page"));
107+
var renderedElement = Browser.Exists(By.Id("lazy-page"));
108108
Assert.True(renderedElement.Displayed);
109109
}
110110

@@ -123,6 +123,39 @@ public void ThrowsErrorForUnavailableAssemblies()
123123
AssertLogContainsCriticalMessages("DoesNotExist.dll must be marked with 'BlazorWebAssemblyLazyLoad' item group in your project file to allow lazy-loading.");
124124
}
125125

126+
[Fact]
127+
public void CanLazyLoadViaLinkChange()
128+
{
129+
// Navigate to a page without any lazy-loaded dependencies
130+
SetUrlViaPushState("/");
131+
var app = Browser.MountTestComponent<TestRouterWithLazyAssembly>();
132+
133+
// We start off with no lazy assemblies loaded
134+
Assert.False(HasLoadedAssembly("LazyTestContentPackage.dll"));
135+
Assert.False(HasLoadedAssembly("Newtonsoft.Json.dll"));
136+
137+
// Click the first link and verify that it worked as expected
138+
var lazyAssemblyLink = Browser.Exists(By.Id("with-lazy-assembly"));
139+
lazyAssemblyLink.Click();
140+
var pkgButton = Browser.Exists(By.Id("use-package-button"));
141+
Assert.True(HasLoadedAssembly("Newtonsoft.Json.dll"));
142+
pkgButton.Click();
143+
144+
// Navigate to the next page and verify that it loaded its assembly
145+
var lazyRoutesLink = Browser.Exists(By.Id("with-lazy-routes"));
146+
lazyRoutesLink.Click();
147+
Browser.Exists(By.Id("lazy-load-msg"));
148+
Assert.True(HasLoadedAssembly("LazyTestContentPackage.dll"));
149+
150+
// Interact with that assembly to ensure it was loaded properly
151+
var button = Browser.Exists(By.Id("go-to-lazy-route"));
152+
button.Click();
153+
154+
// Navigating the lazy-loaded route should show its content
155+
var renderedElement = Browser.Exists(By.Id("lazy-page"));
156+
Assert.True(renderedElement.Displayed);
157+
}
158+
126159
private string SetUrlViaPushState(string relativeUri)
127160
{
128161
var pathBaseWithoutHash = ServerPathBase.Split('#')[0];

src/Components/test/testassets/BasicTestApp/RouterTest/Links.razor

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
<li><NavLink href="/subdir/WithParameters/Name/Abc/LastName/McDef">With more parameters</NavLink></li>
2121
<li><NavLink href="/subdir/LongPage1">Long page 1</NavLink></li>
2222
<li><NavLink href="/subdir/LongPage2">Long page 2</NavLink></li>
23-
<li><NavLink href="/subdir/WithLazyAssembly">With lazy assembly</NavLink></li>
23+
<li><NavLink href="/subdir/WithLazyAssembly" id="with-lazy-assembly">With lazy assembly</NavLink></li>
24+
<li><NavLink href="/subdir/WithLazyLoadedRoutes" id="with-lazy-routes">With lazy loaded routes</NavLink></li>
2425
<li><NavLink href="PreventDefaultCases">preventDefault cases</NavLink></li>
2526
<li><NavLink>Null href never matches</NavLink></li>
2627
</ul>

src/Servers/HttpSys/src/AuthenticationSchemes.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,39 @@
55

66
namespace Microsoft.AspNetCore.Server.HttpSys
77
{
8-
// REVIEW: this appears to be very similar to System.Net.AuthenticationSchemes
8+
/// <summary>
9+
/// Specifies protocols for authentication.
10+
/// </summary>
911
[Flags]
1012
public enum AuthenticationSchemes
1113
{
14+
/// <summary>
15+
/// No authentication is enabled. This should only be used when HttpSysOptions.Authentication.AllowAnonymous is enabled (see <see cref="AuthenticationManager.AllowAnonymous"/>).
16+
/// </summary>
1217
None = 0x0,
18+
19+
/// <summary>
20+
/// Specifies basic authentication.
21+
/// </summary>
1322
Basic = 0x1,
23+
24+
1425
// Digest = 0x2, // TODO: Verify this is no longer supported by Http.Sys
26+
27+
/// <summary>
28+
/// Specifies NTLM authentication.
29+
/// </summary>
1530
NTLM = 0x4,
31+
32+
/// <summary>
33+
/// Negotiates with the client to determine the authentication scheme. If both client and server support Kerberos, it is used;
34+
/// otherwise, NTLM is used.
35+
/// </summary>
1636
Negotiate = 0x8,
37+
38+
/// <summary>
39+
/// Specifies Kerberos authentication.
40+
/// </summary>
1741
Kerberos = 0x10
1842
}
1943
}

src/Servers/HttpSys/src/DelegationRule.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ internal DelegationRule(string queueName, string urlPrefix, ILogger logger)
3131
Queue = new RequestQueue(queueName, UrlPrefix, _logger, receiver: true);
3232
}
3333

34+
/// <inheritdoc />
3435
public void Dispose()
3536
{
3637
Queue.UrlGroup?.Dispose();

src/Servers/HttpSys/src/HttpSysDefaults.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
namespace Microsoft.AspNetCore.Server.HttpSys
55
{
6+
/// <summary>
7+
/// Constants for HttpSys.
8+
/// </summary>
69
public static class HttpSysDefaults
710
{
811
/// <summary>

src/Servers/HttpSys/src/HttpSysException.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
namespace Microsoft.AspNetCore.Server.HttpSys
1010
{
11+
/// <summary>
12+
/// Exception thrown by HttpSys when an error occurs
13+
/// </summary>
1114
[SuppressMessage("Microsoft.Usage", "CA2237:MarkISerializableTypesWithSerializable")]
1215
public class HttpSysException : Win32Exception
1316
{
@@ -28,6 +31,7 @@ internal HttpSysException(int errorCode, string message)
2831

2932
// the base class returns the HResult with this property
3033
// we need the Win32 Error Code, hence the override.
34+
/// <inheritdoc />
3135
public override int ErrorCode
3236
{
3337
get

src/Servers/HttpSys/src/HttpSysOptions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
namespace Microsoft.AspNetCore.Server.HttpSys
99
{
10+
/// <summary>
11+
/// Contains the options used by HttpSys.
12+
/// </summary>
1013
public class HttpSysOptions
1114
{
1215
private const uint MaximumRequestQueueNameLength = 260;
@@ -26,6 +29,9 @@ public class HttpSysOptions
2629
private long? _maxRequestBodySize = DefaultMaxRequestBodySize;
2730
private string _requestQueueName;
2831

32+
/// <summary>
33+
/// Initializes a new <see cref="HttpSysOptions"/>.
34+
/// </summary>
2935
public HttpSysOptions()
3036
{
3137
}

0 commit comments

Comments
 (0)