-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Control collection parent fixes #887
base: dev
Are you sure you want to change the base?
Conversation
…re correct functionality when adding/removing/iterating
Gonna do some testing with this build to make sure there are no weird behaviors, but appears to look good and assumptions appear to all be correct. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
thinking about it, would it be better to throw ArgumentNullException on operations that involve trying to insert or remove null values? |
Sorry for the delays on this. Yes, I think you're right. I can't think of a scenario where it would be intended and the short-circuit might mask a module or core bug. Though, like with lists, it may be safe to keep it off of the remove function. Open to your thoughts, though. The only item that I think we might need to change is:
This is correct, but it's a breaking change that I can't guarantee won't cause problems within one of the modules. Throwing an exception on inserting/removing null values would also be a breaking change, but seems less likely, and I imagine we would catch it during preview testing. Open to your thoughts on that as well. |
Discord Discussion
Breaking change: no
Likely fixes #886
This reworks the internals of the
ControlCollection<T>
class, with the following changes:null
values are unable to be added to the collection, with short-circuits for methods whenitem
isnull
AddChild
orRemoveChild
action from a Container should no longer cause theParent
property of the control in question to be in a potentially invalid state.using (...) { ... }
syntax rather than having to use try/finally everywhere.Parent
on controls when callingClear
- this should be handled by the Container as there's no guarantee that the ControlCollection is being used for parenting/hierarchy purposes.Notes:
ControlCollection<T>
should remove the item when attempting to set an indexed position tonull
or if it should be a noop, currently it removes the item. Additionally, if an index is set to an item that exists elsewhere in the collection, it currently overwrites the index, then removes the duplicate.