-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Remove dependency on System.Console in Blazor WASM app #30251
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
Conversation
src/Components/WebAssembly/WebAssembly/src/Services/WebAssemblyConsoleLogger.cs
Outdated
Show resolved
Hide resolved
src/Components/WebAssembly/WebAssembly/src/Services/WebAssemblyConsoleLogger.cs
Outdated
Show resolved
Hide resolved
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.
I approve as a non-stakeholder.
I think it could be doable, we would need to call some JS interop API instead to notify JS of the error. @SteveSandersonMS do you have any thoughts/concerns? |
@captainsafia - any thoughts on this PR? I think it is ready to merge, unless you have other feedback. |
@eerhardt can we let @SteveSandersonMS comment on the last System.Console usage to see if we can just update this PR and trim the entire assembly? |
My understanding is to trim the entire System.Console assembly is going to take a bit of refactoring how we initialize a Blazor WASM app, and it may take coordination with @lewing's team. |
Ah, thanks for the clarification. Then let's get this merged! Thanks for the PR |
@eerhardt do you want to merge the PR yourself or are you ok if we do it for you |
src/Components/WebAssembly/WebAssembly/src/Services/WebAssemblyConsoleLogger.cs
Show resolved
Hide resolved
I'm sure we can remove the Or if that's inconvenient, we could even have a dedicated |
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.
Looks good from my end!
We can take Steve's recommendation on cleaning up the System.Console
use in the entrypoint invoker and finish this off.
This is the first change necessary. It removes the one place that depends on
Console.WriteLine
.This first change doesn't save much size (.br compressed):
However, if we can also remove the last place that references
System.Console
, we should be able to trim the whole assembly (6KB .br compressed).aspnetcore/src/Components/WebAssembly/WebAssembly/src/Hosting/EntrypointInvoker.cs
Lines 79 to 83 in dfe625f
Speaking with @lewing, we thought if we unified the startup paths between the mono runtime and Blazor, we should be able to remove this last dependency on
System.Console
. @lewing was going to log an issue to track unifying the startup code.cc @marek-safar