-
Notifications
You must be signed in to change notification settings - Fork 992
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
Property Store Refactor #11779
Property Store Refactor #11779
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/10.0 #11779 +/- ##
======================================================
+ Coverage 74.94672% 74.97851% +0.03179%
======================================================
Files 3026 3032 +6
Lines 630129 631581 +1452
Branches 46738 47088 +350
======================================================
+ Hits 472261 473550 +1289
- Misses 154520 154649 +129
- Partials 3348 3382 +34
Flags with carried forward coverage won't be shown. Click here to find out more. |
GetSize
/SetSize
3f96ff7
to
96f178e
Compare
@lonitra |
1e65c5e
to
dbb47f3
Compare
Comment on this seems to indicate that we are always calling this in class initializer and we do not have same class hierarchy initializing on multiple threads. I looked for the callers of this and that seems to still be true, so I think we should be ok to leave it as is here. |
d5fd031
to
e641e6b
Compare
e2af75c
to
715155e
Compare
After we're done with moving to the new API we should probably create a global enum with "keys" as a more efficient replacement. Then we won't have hundreds of these calls on startup, no threading concerns, and greatly simplified static field content. Maybe something like: internal enum PropertyKey
{
BackgroundBrush, // Instead of s_backBrushProperty
FontHeight, // Instead of s_fontHeightProperty
} |
|
||
return DrawMode.Normal; | ||
} | ||
get => Properties.TryGetValue(s_propDrawMode, out DrawMode drawMode) ? drawMode : DrawMode.Normal; |
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.
This could just be the OrDefault overload as DrawMode.Normal is the default.
set | ||
{ | ||
if (DrawMode != value) | ||
{ | ||
// valid values are 0x0 to 0x2. | ||
SourceGenerated.EnumValidator.Validate(value); | ||
ResetHeightCache(); | ||
Properties.SetInteger(s_propDrawMode, (int)value); | ||
Properties.AddValue(s_propDrawMode, value); |
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.
Related to the value being the default, it might be better to update AddOrRemoveValue
to not be constrained to class and instead check == default(T)
. Then we can be removing entries for other default values as well.
int dividerThickness = Properties.GetInteger(s_propDividerThickness, out bool found); | ||
return found ? dividerThickness : 0; | ||
} | ||
get => Properties.TryGetValue(s_propDividerThickness, out int dividerThickness) ? dividerThickness : 0; |
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.
Shouldn't this be GetValueOrDefault?
int dividerThickness = Properties.GetInteger(s_propDividerThickness, out bool found); | ||
return found ? dividerThickness : 0; | ||
} | ||
get => Properties.TryGetValue(s_propDividerThickness, out int dividerThickness) ? dividerThickness : 0; | ||
set | ||
{ | ||
ArgumentOutOfRangeException.ThrowIfNegative(value); | ||
ArgumentOutOfRangeException.ThrowIfGreaterThan(value, MaxBandThickness); | ||
|
||
if (value != DividerThickness) |
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.
This is one where AddOrRemoveValue simplifies things. You can then check the result to see if value is different. (See my earlier comment about opening this overload up to all T values).
{ | ||
PInvoke.SendMessage(this, PInvoke.CB_SETDROPPEDWIDTH, (WPARAM)dropDownWidth); | ||
} | ||
|
||
_ = Properties.GetInteger(s_propItemHeight, out found); | ||
if (found) | ||
if (Properties.TryGetValue(s_propItemHeight, out int _)) |
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.
ContainsKey?
@elachlan I left some comments. I've reviewed about half of it. I'll review again after you ping me. This is about the largest change size we'd want to make for this. I'd even suggest making them a little smaller in the future so we can review with a bit more confidence that we aren't missing something. |
715155e
to
588fa23
Compare
@JeremyKuhne I have made another branch locally to keep the changes and reverted this branch to the last know test pass. This change set should also be smaller now. Ill open up a follow up PR once this is merged. |
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.
Left a few comments
src/System.Windows.Forms/src/System/Windows/Forms/Layout/CommonProperties.cs
Outdated
Show resolved
Hide resolved
In general looks good, looks like some tests need updated. |
I'm just reviewing it again myself. I've found a few more discards and places where we can use |
@JeremyKuhne can you check CI please? It's got a fail. But no test failures. |
Integration tests failed, but didn't report the failing test |
Related: #9508
Microsoft Reviewers: Open in CodeFlow