Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR refines the EnsureInitialized extension by filtering out non-writable class properties during initialization and adds corresponding unit tests to verify this behavior. Sequence diagram for EnsureInitialized property initialization with CanWrite filtersequenceDiagram
participant Caller
participant ObjectExtensions
participant PropertyInfo
Caller->>ObjectExtensions: EnsureInitialized(instance, isAutoInitialize)
ObjectExtensions->>PropertyInfo: GetProperties()
loop For each property
ObjectExtensions->>PropertyInfo: Check PropertyType.IsClass
ObjectExtensions->>PropertyInfo: Check PropertyType != string
ObjectExtensions->>PropertyInfo: Check CanWrite
alt Property is class, not string, and writable
ObjectExtensions->>PropertyInfo: GetValue(instance)
ObjectExtensions->>PropertyInfo: SetValue(instance, newValue)
else Property is not writable
ObjectExtensions-->>PropertyInfo: Skip initialization
end
end
Class diagram for updated EnsureInitialized property filteringclassDiagram
class ObjectExtensions {
+EnsureInitialized(instance, isAutoInitialize)
}
class PropertyInfo {
+PropertyType: Type
+CanWrite: bool
}
ObjectExtensions --> PropertyInfo : uses
PropertyInfo : PropertyType.IsClass
PropertyInfo : PropertyType != typeof(string)
PropertyInfo : CanWrite
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.
Pull Request Overview
Adds a CanWrite filter to the EnsureInitialized method to prevent initialization attempts on read-only properties, along with a version update from beta to release.
- Added CanWrite property filter in ObjectExtensions.EnsureInitialized method
- Added unit test to verify behavior with read-only properties
- Updated version from 9.9.3-beta03 to 9.9.3
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/BootstrapBlazor/Extensions/ObjectExtensions.cs | Added CanWrite filter to prevent initialization of read-only properties |
| test/UnitTest/Extensions/ObjectExtensionsTest.cs | Added test case and MockObject class with read-only property to verify the fix |
| src/BootstrapBlazor/BootstrapBlazor.csproj | Version update from beta to release |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| { | ||
| public string? Name { get; set; } | ||
|
|
||
| public Foo? Foo { get; set; } |
There was a problem hiding this comment.
The property references type 'Foo' which is not defined in the test file or visible imports. This will cause a compilation error.
|
|
||
| public Foo? Foo { get; set; } | ||
|
|
||
| public Foo? Bar { get; } |
There was a problem hiding this comment.
The property references type 'Foo' which is not defined in the test file or visible imports. This will cause a compilation error.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6665 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 739 739
Lines 31672 31674 +2
Branches 4459 4459
=========================================
+ Hits 31672 31674 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Link issues
fixes #6664
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Add a CanWrite filter to the EnsureInitialized extension to skip read-only properties and update tests to confirm only writable properties are initialized.
Bug Fixes:
Enhancements:
Tests: