-
-
Notifications
You must be signed in to change notification settings - Fork 375
feat(ErrorLogger): check EnableErrorLogger parameter #7483
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the Apache 2.0 License | ||
| // See the LICENSE file in the project root for more information. | ||
| // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone | ||
|
|
@@ -101,15 +101,20 @@ protected override async Task OnInitializedAsync() | |
| /// <param name="builder"></param> | ||
| protected override void BuildRenderTree(RenderTreeBuilder builder) | ||
| { | ||
| builder.OpenComponent<CascadingValue<IErrorLogger>>(0); | ||
| builder.AddAttribute(1, nameof(CascadingValue<>.Value), this); | ||
| builder.AddAttribute(2, nameof(CascadingValue<>.IsFixed), true); | ||
| builder.AddAttribute(3, nameof(CascadingValue<>.ChildContent), RenderContent); | ||
| builder.CloseComponent(); | ||
| if (EnableErrorLogger) | ||
| { | ||
| builder.OpenComponent<CascadingValue<IErrorLogger>>(0); | ||
| builder.AddAttribute(1, nameof(CascadingValue<>.Value), this); | ||
| builder.AddAttribute(2, nameof(CascadingValue<>.IsFixed), true); | ||
| builder.AddAttribute(3, nameof(CascadingValue<>.ChildContent), RenderError); | ||
| builder.CloseComponent(); | ||
| } | ||
| else | ||
| { | ||
| builder.AddContent(10, ChildContent); | ||
| } | ||
|
Comment on lines
+104
to
+115
|
||
| } | ||
|
|
||
| private RenderFragment? RenderContent => EnableErrorLogger ? RenderError : ChildContent; | ||
|
|
||
| private RenderFragment RenderError => builder => | ||
| { | ||
| builder.OpenComponent<BootstrapBlazorErrorBoundary>(0); | ||
|
|
@@ -119,7 +124,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder) | |
| builder.AddAttribute(4, nameof(BootstrapBlazorErrorBoundary.ErrorContent), ErrorContent); | ||
| builder.AddAttribute(5, nameof(BootstrapBlazorErrorBoundary.ChildContent), ChildContent); | ||
| builder.AddAttribute(6, nameof(BootstrapBlazorErrorBoundary.EnableILogger), EnableILogger); | ||
| builder.AddComponentReferenceCapture(5, obj => _errorBoundary = (BootstrapBlazorErrorBoundary)obj); | ||
| builder.AddComponentReferenceCapture(7, obj => _errorBoundary = (BootstrapBlazorErrorBoundary)obj); | ||
| builder.CloseComponent(); | ||
| }; | ||
|
|
||
|
|
||
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.
The refactored BuildRenderTree method introduces new conditional logic where EnableErrorLogger false directly renders ChildContent without the CascadingValue wrapper. However, there are no tests in ErrorLoggerTest.cs that verify this specific behavior. Consider adding a test that verifies when EnableErrorLogger is false, the CascadingValue is not created and ChildContent is rendered directly.