-
Notifications
You must be signed in to change notification settings - Fork 983
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
Refactor ArrangedElementCollection to use List<IArrangedElement> instead of ArrayList #8207
Refactor ArrangedElementCollection to use List<IArrangedElement> instead of ArrayList #8207
Conversation
|
@elachlan Thanks for pointing this out. Fixed. |
src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlCollection.cs
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/Layout/ArrangedElementCollection.cs
Show resolved
Hide resolved
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.
Please add description with details for each change types to help review better.
421b548
to
ed827e8
Compare
ed827e8
to
342c6ce
Compare
@dreddy-work this looks like flaky tests, can you please refresh the pipeline? |
src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlCollection.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlCollection.cs
Outdated
Show resolved
Hide resolved
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.
Thanks for doing this! I've got a couple of comments to address, but otherwise looks good!
src/System.Windows.Forms/src/System/Windows/Forms/Layout/ArrangedElementCollection.cs
Outdated
Show resolved
Hide resolved
int IList.Add(object? value) => InnerList.Add(value); | ||
int IList.Add(object? value) | ||
{ | ||
if (value is IArrangedElement element) |
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.
Typing this collection is a breaking change so it is probably better to throw an argument exception here and change the documentation to make it clear that the collection will only take IArrangedElement
now. -1
is not something you would ever get from ArrayList.Add
.
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.
One option here is to cast the inner list to IList
so you get the same exact throw it would do (ArgumentException
). You'll also get the count out that way.
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.
@Jericho would you mind updating those?
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.
Absolutely. I'll go back to all PRS where we refactored classes to use List instead if Array List.
0421b3c
to
5e5fda2
Compare
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.
@elachlan , i see change to type |
Related: #8140
Microsoft Reviewers: Open in CodeFlow