-
-
Notifications
You must be signed in to change notification settings - Fork 355
feat(EnsureInitialized): add CanWrite filter #6665
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The property references type 'Foo' which is not defined in the test file or visible imports. This will cause a compilation error.
Copilot uses AI. Check for mistakes.
|
||
public Foo? Foo { get; set; } | ||
|
||
public Foo? Bar { get; } |
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 property references type 'Foo' which is not defined in the test file or visible imports. This will cause a compilation error.
Copilot uses AI. Check for mistakes.
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: