Convert `ArrayList` usage to `List<T>` where possible
See original GitHub issueIs your feature request related to a problem? Please describe
Winforms uses Arraylist extensively.
Describe the solution you’d like and alternatives you’ve considered
Convert Arraylist usage to List<T> to reduce boxing and improve memory utilization.
Will this feature affect UI controls?
N/A
Related: #2644
Remaining occurrences in System.Windows.Forms.Design
| File | Line Count |
|---|---|
| src\System\ComponentModel\Design\ExceptionCollection.cs | 33 |
| src\System\Windows\Forms\Design\ToolStripItemDataObject.cs | 34 |
| src\System\Windows\Forms\Design\ControlDesigner.DesignerControlCollectionCodeDomSerializer.cs | 38 |
| src\System\Windows\Forms\Design\UpDownBaseDesigner.cs | 63 |
| src\System\Windows\Forms\Design\DesignBindingValueUIHandler.cs | 66 |
| src\System\Windows\Forms\Design\ImageListImageEditor.cs | 108 |
| src\System\Windows\Forms\Design\ImageCollectionEditor.cs | 113 |
| src\System\Windows\Forms\Design\GroupBoxDesigner.cs | 124 |
| src\System\Windows\Forms\Design\ComboBoxDesigner.cs | 128 |
| src\System\Windows\Forms\Design\LabelDesigner.cs | 146 |
| src\System\Windows\Forms\Design\TextBoxBaseDesigner.cs | 148 |
| src\System\Windows\Forms\Design\OleDragDropHandler.CfCodeToolboxItem.cs | 162 |
| src\System\Windows\Forms\Design\ButtonBaseDesigner.cs | 218 |
| src\System\Windows\Forms\Design\Behavior\ContainerSelectorBehavior.cs | 230 |
| src\System\Windows\Forms\Design\ToolStripAdornerWindowService.cs | 256 |
| src\System\Windows\Forms\Design\BaseContextMenuStrip.cs | 290 |
| src\System\Windows\Forms\Design\OleDragDropHandler.ComponentDataObject.cs | 302 |
| src\System\ComponentModel\Design\InheritedPropertyDescriptor.cs | 308 |
| src\System\Windows\Forms\Design\Behavior\ToolboxItemSnapLineBehavior.cs | 338 |
| src\System\ComponentModel\Design\CollectionEditor.cs | 347 |
| src\System\Windows\Forms\Design\FormDocumentDesigner.cs | 432 |
| src\System\ComponentModel\Design\SelectionService.cs | 446 |
| src\System\Windows\Forms\Design\Behavior\SelectionManager.cs | 458 |
| src\System\ComponentModel\Design\DesignSurface.cs | 491 |
| src\System\Windows\Forms\Design\DesignerFrame.cs | 576 |
| src\System\Windows\Forms\Design\ToolStripDesignerUtils.cs | 584 |
| src\System\ComponentModel\Design\Serialization\CollectionCodeDomSerializer.cs | 648 |
| src\System\Windows\Forms\Design\DesignerUtils.cs | 816 |
| src\System\Windows\Forms\Design\Behavior\ResizeBehavior.cs | 819 |
| src\System\ComponentModel\Design\Serialization\BasicDesignerLoader.cs | 857 |
| src\System\ComponentModel\Design\Serialization\DesignerSerializationManager.cs | 896 |
| src\System\Windows\Forms\Design\ToolStripItemBehavior.cs | 905 |
| src\System\Windows\Forms\Design\Behavior\DropSourceBehavior.cs | 1029 |
| src\System\Windows\Forms\Design\OleDragDropHandler.cs | 1045 |
| src\System\Windows\Forms\Design\ToolStripItemDesigner.cs | 1177 |
| src\System\ComponentModel\Design\CollectionEditor.CollectionEditorCollectionForm.cs | 1223 |
| src\System\ComponentModel\Design\Serialization\CodeDomComponentSerializationService.cs | 1471 |
| src\System\ComponentModel\Design\DesignerHost.cs | 1615 |
| src\System\Windows\Forms\Design\ToolStripKeyboardHandlingService.cs | 1891 |
| src\System\Windows\Forms\Design\ControlDesigner.cs | 2205 |
| src\System\Windows\Forms\Design\ToolStripDesigner.cs | 2260 |
| src\System\Windows\Forms\Design\ParentControlDesigner.cs | 2378 |
| src\System\Windows\Forms\Design\ToolStripMenuItemDesigner.cs | 2527 |
| src\System\ComponentModel\Design\Serialization\CodeDomSerializerBase.cs | 3020 |
Issue Analytics
- State:
- Created 10 months ago
- Reactions:4
- Comments:17 (17 by maintainers)
Top Results From Across the Web
Convert ArrayList<String> to java.util.List [closed]
An ArrayList<anything> is already a List<anything> , because ArrayList implements the List interface. No casting is necessary. Share.
Read more >Java ArrayList Conversions To Other Collections
Answer: To convert an ArrayList to an Array in Java, one can use the toArray ( ) method from ArrayList API that converts...
Read more >Converting Between an Array and a List in Java
In this quick tutorial, we're going to learn how to convert between an Array and a List using core Java libraries, Guava and...
Read more >How do you turn an ArrayList into a Set in Java
An ArrayList can be converted to a set object using Set constructor. The resultant set will elliminate any duplicate entry present in the ......
Read more >Java Program to Convert an Array into a List
Therefore the Array can be converted into the List with the help of the Collections.addAll() method. Algorithm: Get the Array to be converted....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Here’s the list of classes that will benefit from replacing
ArrayListwithList<T>(I’ll continuously maintain this list as I discover more classes):List<WeakRefObject?>instead ofArrayListList<IArrangedElement>instead ofArrayListList<TableLayoutStyle>instead ofArrayListList<IDesignerHost>instead ofArrayListList<IExtenderProvider>instead of ArrayListList<DesignerVerb>instead ofArrayListArrayList. Two of them can be replaced withList<IComponent>and the other one can be replaced withList<ReferenceHolder>ArrayList. One can be replaced withList<string>and the other one can be replaced withList<CodeExpression>List<IComponent>, and the remaining three can be replaced withList<UndoEvent>,List<ChangeUndoEvent>andList<AddRemoveUndoEvent>respectively.ArrayListwithList<Behavior>ArrayListin this class. Four of them can be replaced withList<SnapLine>, one can be replaced withList<SnapLineType>and two can be replaced withList<Line>ArrayListwithList<IComponent>ArrayListwithList<BufferedKey>ArrayListthat can be replaced withList<MenuCommand>ArrayListwithList<DataGridViewRow>ArrayListwithList<DataGridViewCell>ArrayListwithList<DataGridViewColumn>ArrayListwithList<DataGridViewCell>ArrayListwithList<DataGridViewColumn>ArrayListwithList<DataGridViewRow>ArrayListwithList<GridEntryCollection>ArrayListwithList<Binding>List<Attribute>Here are classes that use an
ArrayListand the type of the elements isobject. Is it worth it to convert toList<object>?objectsbut I suspect the intent is to keep a reference of visual components rather than objects. Therefore, I thinkList<IComponent>would be more appropriateI would be happy to contribute. I will start with combing through the code base to identify the various classes that would be affected.