-
-
Notifications
You must be signed in to change notification settings - Fork 363
feat(Table): throw exception when set IsTree to true in virtualize mode #5721
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 |
|---|---|---|
|
|
@@ -8911,9 +8911,10 @@ public async Task TestLoopQueryAsync() | |
|
|
||
| public RenderFragment RenderVirtualPlaceHolder() => new(builder => | ||
| { | ||
| if (ScrollMode == ScrollMode.Virtual && VirtualizeElement != null) | ||
| var fieldInfo = GetType().BaseType!.GetField("_virtualizeElement", BindingFlags.NonPublic | BindingFlags.Instance)!; | ||
| if (ScrollMode == ScrollMode.Virtual && fieldInfo.GetValue(this) is Virtualize<Foo> element) | ||
|
Comment on lines
+8914
to
+8915
Contributor
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. suggestion (testing): Avoid testing private fields with reflection. Testing private fields using reflection makes tests brittle and tightly coupled to implementation details. Consider exposing the necessary information through a protected property or method if it's essential for testing. Alternatively, refactor the test to interact with the component's public API and verify the expected behavior without relying on internal state. Suggested implementation: if (ScrollMode == ScrollMode.Virtual && VirtualizeElement is Virtualize<Foo> element)Ensure that the component exposes a protected property VirtualizeElement (if not already present) that returns the value of the private _virtualizeElement field. For example, in the component's base class you may add: protected Virtualize? VirtualizeElement => _virtualizeElement; This change avoids testing private fields via reflection and makes the test less brittle while still exposing the necessary state for verifying the component behavior. |
||
| { | ||
| builder.AddContent(0, VirtualizeElement.Placeholder?.Invoke(new Microsoft.AspNetCore.Components.Web.Virtualization.PlaceholderContext())); | ||
| builder.AddContent(0, element.Placeholder?.Invoke(new PlaceholderContext())); | ||
| } | ||
| }); | ||
|
|
||
|
|
||
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.
question (bug_risk): Using [NotNull] with conditional assignment may be misleading.
The _virtualizeElement field is marked with [NotNull] yet may remain null depending on the rendering branch. Please verify that this attribute accurately reflects its lifecycle or consider handling the nullability to avoid potential warnings or runtime issues.