[bcl] Use List instead of ArrayList () in a few places.
authorZoltan Varga <vargaz@gmail.com>
Wed, 8 Oct 2014 20:12:01 +0000 (16:12 -0400)
committerZoltan Varga <vargaz@gmail.com>
Wed, 8 Oct 2014 20:12:01 +0000 (16:12 -0400)
mcs/class/System/System.Diagnostics/LocalFileEventLog.cs
mcs/class/System/System.Diagnostics/Process.cs
mcs/class/System/System.Diagnostics/Win32EventLog.cs
mcs/class/System/System.IO/DefaultWatcher.cs

index e5a34ff1a41478735652b7c883839575fba532a6..c013223d08108d239bdc1c84481cc55c1d407358 100644 (file)
@@ -29,7 +29,7 @@
 //
 
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.ComponentModel;
 using System.Diagnostics;
 using System.Globalization;
@@ -227,7 +227,7 @@ namespace System.Diagnostics
                                        DateFormat, CultureInfo.InvariantCulture);
                                DateTime timeWritten = File.GetLastWriteTime (file);
                                int stringNums = int.Parse (tr.ReadLine ().Substring (20));
-                               ArrayList replacementTemp = new ArrayList ();
+                               var replacementTemp = new List<string> ();
                                StringBuilder sb = new StringBuilder ();
                                while (replacementTemp.Count < stringNums) {
                                        char c = (char) tr.Read ();
@@ -238,8 +238,7 @@ namespace System.Diagnostics
                                                sb.Append (c);
                                        }
                                }
-                               string [] replacementStrings = new string [replacementTemp.Count];
-                               replacementTemp.CopyTo (replacementStrings, 0);
+                               string [] replacementStrings = replacementTemp.ToArray ();
 
                                string message = FormatMessage (source, instanceID, replacementStrings);
                                int eventID = EventLog.GetEventID (instanceID);
index ef042e905cf39257eb8254b3e61b3544391738bd..0cf197af1dcac3be7c072c2ee3ac51b74573023f 100644 (file)
@@ -39,7 +39,7 @@ using System.ComponentModel.Design;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Security.Permissions;
-using System.Collections;
+using System.Collections.Generic;
 using System.Security;
 using System.Threading;
 
@@ -832,13 +832,13 @@ namespace System.Diagnostics {
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                private extern static int[] GetProcesses_internal();
 
-               public static Process[] GetProcesses()
+               public static Process[] GetProcesses ()
                {
                        int [] pids = GetProcesses_internal ();
                        if (pids == null)
                                return new Process [0];
 
-                       ArrayList proclist = new ArrayList (pids.Length);
+                       var proclist = new List<Process> (pids.Length);
                        for (int i = 0; i < pids.Length; i++) {
                                try {
                                        proclist.Add (GetProcessById (pids [i]));
@@ -851,7 +851,7 @@ namespace System.Diagnostics {
                                }
                        }
 
-                       return ((Process []) proclist.ToArray (typeof (Process)));
+                       return proclist.ToArray ();
                }
 
                [MonoTODO ("There is no support for retrieving process information from a remote machine")]
@@ -871,7 +871,7 @@ namespace System.Diagnostics {
                        if (pids == null)
                                return new Process [0];
                        
-                       ArrayList proclist = new ArrayList (pids.Length);
+                       var proclist = new List<Process> (pids.Length);
                        for (int i = 0; i < pids.Length; i++) {
                                try {
                                        Process p = GetProcessById (pids [i]);
@@ -886,7 +886,7 @@ namespace System.Diagnostics {
                                }
                        }
 
-                       return ((Process []) proclist.ToArray (typeof (Process)));
+                       return proclist.ToArray ();
                }
 
                [MonoTODO]
index 40fe3a36b157ac461654e70c532d17ec06966ce7..4002c3b7cdc4850dbe9490d4831005ed7024fc27 100644 (file)
@@ -28,7 +28,7 @@
 //
 
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.ComponentModel;
 using System.Diagnostics;
 using System.Globalization;
@@ -177,12 +177,11 @@ namespace System.Diagnostics
 
                                string [] sources = (string []) logKey.GetValue ("Sources");
                                if (sources != null) {
-                                       ArrayList temp = new ArrayList ();
+                                       var temp = new List<string> ();
                                        for (int i = 0; i < sources.Length; i++)
                                                if (sources [i] != source)
                                                        temp.Add (sources [i]);
-                                       string [] newSources = new string [temp.Count];
-                                       temp.CopyTo (newSources, 0);
+                                       string [] newSources = temp.ToArray ();
                                        logKey.SetValue ("Sources", newSources);
                                }
                        }
index 8988a6b97030e2180008f7c7551ac043e366a0a3..d2d8b28d86cef4ebbeeff516308503d14cf10fe2 100644 (file)
@@ -30,6 +30,7 @@
 
 using System;
 using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 using System.Threading;
 
@@ -240,12 +241,12 @@ namespace System.IO {
                                return;
 
                        /* Removed files */
-                       ArrayList removed = null;
+                       List<string> removed = null;
                        foreach (string filename in data.Files.Keys) {
                                FileData fd = (FileData) data.Files [filename];
                                if (fd.NotExists) {
                                        if (removed == null)
-                                               removed = new ArrayList ();
+                                               removed = new List<string> ();
 
                                        removed.Add (filename);
                                        DispatchEvents (data.FSW, FileAction.Removed, filename);
@@ -269,7 +270,7 @@ namespace System.IO {
                                } catch {
                                        /* Deleted */
                                        if (removed == null)
-                                               removed = new ArrayList ();
+                                               removed = new List<string> ();
 
                                        removed.Add (filename);
                                        DispatchEvents (data.FSW, FileAction.Removed, filename);