-
-
Notifications
You must be signed in to change notification settings - Fork 323
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
fix(Table): add IsAutoInitializeModelProperty parameter control create instance logic #5530
Conversation
Reviewer's Guide by SourceryThis pull request introduces a new Sequence diagram for CreateInstance with auto-initializationsequenceDiagram
participant Table Component
participant ObjectExtensions
participant Activator
Table Component->>ObjectExtensions: CreateInstance<TItem>(isAutoInitializeModelProperty)
activate ObjectExtensions
ObjectExtensions->>Activator: CreateInstance<TItem>()
activate Activator
Activator-->>ObjectExtensions: instance
deactivate Activator
alt isAutoInitializeModelProperty is true
ObjectExtensions->>ObjectExtensions: EnsureInitialized(instance, isAutoInitializeModelProperty)
activate ObjectExtensions
ObjectExtensions->>ObjectExtensions: GetProperties()
ObjectExtensions->>ObjectExtensions: CreateInstance(type, isAutoInitializeModelProperty)
activate ObjectExtensions
ObjectExtensions->>Activator: CreateInstance(type)
activate Activator
Activator-->>ObjectExtensions: propertyInstance
deactivate Activator
ObjectExtensions->>ObjectExtensions: SetValue(propertyInstance)
deactivate ObjectExtensions
ObjectExtensions-->>ObjectExtensions:
deactivate ObjectExtensions
end
ObjectExtensions-->>Table Component: instance
deactivate ObjectExtensions
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @ArgoZhang - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding a non-nullable
TItem
constraint to theCreateInstance
method signature to avoid the need for null-forgiving operators. - The added unit test for
CreateInstance_Ok
throws an exception, which is unusual for a test that's supposed to verify functionality.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟡 Testing: 2 issues found
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5530 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 649 649
Lines 29583 29599 +16
Branches 4167 4171 +4
=========================================
+ Hits 29583 29599 +16 ☔ View full report in Codecov by Sentry. |
@sourcery-ai review |
Link issues
[请在下方 # 后面填写相关 Issue 编号,如 #42]
fixes #5529
Summary By Copilot
This pull request includes several changes to the
BootstrapBlazor
project, focusing on version updates, enhancements to model property initialization, and improvements to unit tests. The most important changes include updating the project version, adding a new parameter for automatic model property initialization, and modifying theCreateInstance
method to support this new parameter.Version Update:
src/BootstrapBlazor/BootstrapBlazor.csproj
: Updated the project version from 9.4.5 to 9.4.6.Enhancements to Model Property Initialization:
src/BootstrapBlazor/Components/Table/Table.razor.Edit.cs
: Added a new parameterIsAutoInitializeModelProperty
to theInternalOnAddAsync
method and updated theCreateInstance
method to use this parameter.src/BootstrapBlazor/Extensions/ObjectExtensions.cs
: Modified theCreateInstance
method to accept theisAutoInitializeModelProperty
parameter and ensure class-type properties are initialized based on this parameter.Unit Test Improvements:
test/UnitTest/Components/TableTest.cs
: Added a test case to verify theIsAutoInitializeModelProperty
parameter functionality.test/UnitTest/Extensions/ObjectExtensionsTest.cs
: Added a test case for theCreateInstance
method to ensure it works correctly with theisAutoInitializeModelProperty
parameter.Regression?
[If yes, specify the version the behavior has regressed from]
[是否影响老版本]
Risk
[Justify the selection above]
Verification
Packaging changes reviewed?
☑️ Self Check before Merge