-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Try register LazyAssemblyLoader to DI in AddInteractiveWebAssemblyCom… #61719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
oroztocil
wants to merge
5
commits into
main
from
oroztocil/51966-lazy-assembly-loader-DI-registration
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ed81b3d
Try register LazyAssemblyLoader to DI in AddInteractiveWebAssemblyCom…
oroztocil 307e49d
Use TryAddScoped instead of AddScoped
oroztocil 791a82f
Add E2E check that Blazor template adds necessary assembly for LazyAs…
oroztocil 80cf245
Add comment explaining the new template test
oroztocil 2339991
Add DynamicDependencyAttribute to prevent LazyAssemblyBuilder from be…
oroztocil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.IO; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Net.Http.Headers; | ||
|
@@ -26,6 +27,18 @@ public async Task BlazorWebTemplate_Works(BrowserKind browserKind, string intera | |
args: ["-int", interactivityOption], | ||
getTargetProject: GetTargetProject); | ||
|
||
if (HasClientProject()) | ||
{ | ||
// In order to prevent an exception casued by missing LazyAssemblyLoader during pre-rendering, | ||
// we are registering it into DI in AddInteractiveWebAssemblyComponents. | ||
// To avoid adding new references between assemblies we try to resolve the type during run-time using reflection. | ||
// This assert is here to check that the assembly containing LazyAssemblyLoader is actually present in a standard app | ||
// created from the Blazor Web template. | ||
// See https://github.com/dotnet/aspnetcore/issues/51966. | ||
// TODO: Remove this when LazyAssemblyLoader is no longer being used, or the dependency graph changes so reflection is no longer needed. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove todo |
||
AssertServerProjectCanUseLazyAssemblyLoader(GetTargetProject(project)); | ||
} | ||
|
||
// There won't be a counter page when the 'None' interactivity option is used | ||
var pagesToExclude = interactivityOption is "None" | ||
? BlazorTemplatePages.Counter | ||
|
@@ -92,4 +105,12 @@ private static async Task AssertWebAssemblyCompressionFormatAsync(AspNetProcess | |
}); | ||
Assert.Equal(expectedEncoding, response.Content.Headers.ContentEncoding.Single()); | ||
} | ||
|
||
private static void AssertServerProjectCanUseLazyAssemblyLoader(Project project) | ||
{ | ||
var assemblyName = "Microsoft.AspNetCore.Components.WebAssembly.dll"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also check that the class is in the dll |
||
var fullPath = Path.Combine(project.TemplateBuildDir, assemblyName); | ||
var doesExist = File.Exists(fullPath); | ||
Assert.True(doesExist, "Required assembly does not exist"); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the TODO please