blish-hud / Blish-HUD

A Guild Wars 2 overlay with extreme extensibility through compiled modules.
https://blishhud.com
MIT License
320 stars 59 forks source link

Control collection parent fixes #887

Open eksime opened 1 year ago

eksime commented 1 year ago

Discord Discussion

Breaking change: no

Likely fixes #886

This reworks the internals of the ControlCollection<T> class, with the following changes:

Notes:

dlamkins commented 1 year ago

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.

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

eksime commented 1 year ago

thinking about it, would it be better to throw ArgumentNullException on operations that involve trying to insert or remove null values?

dlamkins commented 1 year ago

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:

No longer clear Parent on controls when calling Clear - this should be handled by the Container as there's no guarantee that the ControlCollection is being used for parenting/hierarchy purposes.

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.