Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,9 @@ private bool ScanForwardsForTail(ContentHolder holder, CmdletProviderContext cur
if (ReadCount <= 0 || (ReadCount >= tailResultQueue.Count && ReadCount != 1))
{
count = tailResultQueue.Count;
ArrayList outputList = new ArrayList();
while (tailResultQueue.Count > 0)
{
outputList.Add(tailResultQueue.Dequeue());
}

// Write out the content as an array of objects
WriteContentObject(outputList.ToArray(), count, holder.PathInfo, currentContext);
WriteContentObject(tailResultQueue.ToArray(), count, holder.PathInfo, currentContext);
}
else if (ReadCount == 1)
{
Expand All @@ -356,7 +352,7 @@ private bool ScanForwardsForTail(ContentHolder holder, CmdletProviderContext cur
{
while (tailResultQueue.Count >= ReadCount)
{
ArrayList outputList = new ArrayList();
var outputList = new List<object>((int)ReadCount);
for (int idx = 0; idx < ReadCount; idx++, count++)
outputList.Add(tailResultQueue.Dequeue());
// Write out the content as an array of objects
Expand All @@ -366,11 +362,8 @@ private bool ScanForwardsForTail(ContentHolder holder, CmdletProviderContext cur
int remainder = tailResultQueue.Count;
if (remainder > 0)
{
ArrayList outputList = new ArrayList();
for (; remainder > 0; remainder--, count++)
outputList.Add(tailResultQueue.Dequeue());
// Write out the content as an array of objects
WriteContentObject(outputList.ToArray(), count, holder.PathInfo, currentContext);
WriteContentObject(tailResultQueue.ToArray(), count, holder.PathInfo, currentContext);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ private string[] GetAcceptedPaths(string[] unfilteredPaths, CmdletProviderContex
{
Collection<PathInfo> pathInfos = ResolvePaths(unfilteredPaths, true, false, currentContext);

ArrayList paths = new ArrayList();
var paths = new List<string>();

foreach (PathInfo pathInfo in pathInfos)
{
Expand All @@ -343,7 +343,7 @@ private string[] GetAcceptedPaths(string[] unfilteredPaths, CmdletProviderContex
}
}

return (string[])paths.ToArray(typeof(string));
return paths.ToArray();
}

#endregion protected members
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ private List<MshParameter> ProcessParameter(object[] properties)
private void InitializeResolvedNameMshParameters()
{
// temp list of properties with wildcards resolved
ArrayList resolvedNameProperty = new ArrayList();
var resolvedNameProperty = new List<object>();

foreach (MshParameter p in _propertyMshParameterList)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ protected override void ProcessRecord()
{
if (_valueList == null)
{
_valueList = new ArrayList();
_valueList = new List<object>();
}

_valueList.Add(Value);
Expand All @@ -759,7 +759,7 @@ protected override void ProcessRecord()
}
}

private ArrayList _valueList;
private List<object> _valueList;

/// <summary>
/// Sets the variable if the name was specified as a formal parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2670,7 +2670,7 @@ private void EvaluateSuggestions(ConsoleHostUserInterface ui)
// Output any training suggestions
try
{
ArrayList suggestions = HostUtilities.GetSuggestion(_parent.Runspace);
List<string> suggestions = HostUtilities.GetSuggestion(_parent.Runspace);

if (suggestions.Count > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public string[] LiteralPath
//
// list of files that were not found
//
private ArrayList _filesNotFound = new ArrayList();
private List<string> _filesNotFound = new List<string>();

/// <summary>
/// Initializes a new instance of the GetPfxCertificateCommand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Management.Automation;
using System.Management.Automation.Host;
using System.Management.Automation.Internal;
Expand Down Expand Up @@ -88,7 +88,7 @@ protected override void BeginProcessing()

if (Context.CurrentCommandProcessor.CommandRuntime.OutVarList != null)
{
_outVarResults = new ArrayList();
_outVarResults = new List<PSObject>();
}
}

Expand Down Expand Up @@ -162,7 +162,7 @@ protected override void InternalDispose()
}
}

private ArrayList _outVarResults = null;
private List<PSObject> _outVarResults = null;
private IDisposable _transcribeOnlyCookie = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ public static class HostUtilities
$formatString -f [string]::Join(', ', (Get-Command $lastError.TargetObject -UseFuzzyMatch | Select-Object -First 10 -Unique -ExpandProperty Name))
";

private static ArrayList s_suggestions = InitializeSuggestions();
private static List<Hashtable> s_suggestions = InitializeSuggestions();

private static ArrayList InitializeSuggestions()
private static List<Hashtable> InitializeSuggestions()
{
ArrayList suggestions = new ArrayList(
var suggestions = new List<Hashtable>(
new Hashtable[]
{
NewSuggestion(
Expand Down Expand Up @@ -307,10 +307,10 @@ internal static string GetMaxLines(string source, int maxLines)
return returnValue.ToString();
}

internal static ArrayList GetSuggestion(Runspace runspace)
internal static List<string> GetSuggestion(Runspace runspace)
{
LocalRunspace localRunspace = runspace as LocalRunspace;
if (localRunspace == null) { return new ArrayList(); }
if (localRunspace == null) { return new List<string>(); }

// Get the last value of $?
bool questionMarkVariableValue = localRunspace.ExecutionContext.QuestionMarkVariableValue;
Expand All @@ -320,7 +320,7 @@ internal static ArrayList GetSuggestion(Runspace runspace)
HistoryInfo[] entries = history.GetEntries(-1, 1, true);

if (entries.Length == 0)
return new ArrayList();
return new List<string>();

HistoryInfo lastHistory = entries[0];

Expand Down Expand Up @@ -363,7 +363,7 @@ internal static ArrayList GetSuggestion(Runspace runspace)
Runspace.DefaultRunspace = runspace;
}

ArrayList suggestions = null;
List<string> suggestions = null;

try
{
Expand All @@ -383,9 +383,9 @@ internal static ArrayList GetSuggestion(Runspace runspace)
}

[SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly")]
internal static ArrayList GetSuggestion(HistoryInfo lastHistory, object lastError, ArrayList errorList)
internal static List<string> GetSuggestion(HistoryInfo lastHistory, object lastError, ArrayList errorList)
{
ArrayList returnSuggestions = new ArrayList();
var returnSuggestions = new List<string>();

PSModuleInfo invocationModule = new PSModuleInfo(true);
invocationModule.SessionState.PSVariable.Set("lastHistory", lastHistory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internal class RemoteRunspace : Runspace, IDisposable
{
#region Private Members

private ArrayList _runningPipelines = new ArrayList();
private List<RemotePipeline> _runningPipelines = new List<RemotePipeline>();
private object _syncRoot = new object();
private RunspaceStateInfo _runspaceStateInfo = new RunspaceStateInfo(RunspaceState.BeforeOpen);
private bool _bSessionStateProxyCallInProgress = false;
Expand Down Expand Up @@ -1522,7 +1522,7 @@ private bool WaitForFinishofPipelines()

lock (_syncRoot)
{
runningPipelines = (RemotePipeline[])_runningPipelines.ToArray(typeof(RemotePipeline));
runningPipelines = _runningPipelines.ToArray();
}

if (runningPipelines.Length > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1912,7 +1912,7 @@ internal static PSEventArgs GetPSEventArgs(PSObject dataAsPSObject)
string computerName = GetPropertyValue<string>(dataAsPSObject, RemoteDataNameStrings.PSEventArgsComputerName);
Guid runspaceId = GetPropertyValue<Guid>(dataAsPSObject, RemoteDataNameStrings.PSEventArgsRunspaceId);

ArrayList sourceArgs = new ArrayList();
var sourceArgs = new List<object>();
foreach (object argument in RemotingDecoder.EnumerateListProperty<object>(dataAsPSObject, RemoteDataNameStrings.PSEventArgsSourceArgs))
{
sourceArgs.Add(argument);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1858,15 +1858,15 @@ private void MergeConfigHashIntoConfigHash(IDictionary childConfigHash)
{
string customizationString = customization.ToString();

ArrayList customizationValue = new ArrayList();
var customizationValue = new List<object>();

// First, take all values from the master config table
if (_configHash.ContainsKey(customizationString))
{
IEnumerable existingValueAsCollection = LanguagePrimitives.GetEnumerable(_configHash[customization]);
if (existingValueAsCollection != null)
{
foreach (Object value in existingValueAsCollection)
foreach (object value in existingValueAsCollection)
{
customizationValue.Add(value);
}
Expand All @@ -1881,7 +1881,7 @@ private void MergeConfigHashIntoConfigHash(IDictionary childConfigHash)
IEnumerable newValueAsCollection = LanguagePrimitives.GetEnumerable(childConfigHash[customization]);
if (newValueAsCollection != null)
{
foreach (Object value in newValueAsCollection)
foreach (object value in newValueAsCollection)
{
customizationValue.Add(value);
}
Expand Down
11 changes: 5 additions & 6 deletions src/System.Management.Automation/help/HelpErrorTracer.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Reflection;

namespace System.Management.Automation
{
Expand Down Expand Up @@ -134,7 +133,7 @@ internal HelpErrorTracer(HelpSystem helpSystem)
/// <summary>
/// This tracks all live TraceFrame objects, which forms a stack.
/// </summary>
private ArrayList _traceFrames = new ArrayList();
private readonly List<TraceFrame> _traceFrames = new List<TraceFrame>();

/// <summary>
/// This is the API to use for starting a help trace scope.
Expand All @@ -160,7 +159,7 @@ internal void TraceError(ErrorRecord errorRecord)
if (_traceFrames.Count <= 0)
return;

TraceFrame traceFrame = (TraceFrame)_traceFrames[_traceFrames.Count - 1];
TraceFrame traceFrame = _traceFrames[_traceFrames.Count - 1];

traceFrame.TraceError(errorRecord);
}
Expand All @@ -175,7 +174,7 @@ internal void TraceErrors(Collection<ErrorRecord> errorRecords)
if (_traceFrames.Count <= 0)
return;

TraceFrame traceFrame = (TraceFrame)_traceFrames[_traceFrames.Count - 1];
TraceFrame traceFrame = _traceFrames[_traceFrames.Count - 1];

traceFrame.TraceErrors(errorRecords);
}
Expand All @@ -185,7 +184,7 @@ internal void PopFrame(TraceFrame traceFrame)
if (_traceFrames.Count <= 0)
return;

TraceFrame lastFrame = (TraceFrame)_traceFrames[_traceFrames.Count - 1];
TraceFrame lastFrame = _traceFrames[_traceFrames.Count - 1];

if (lastFrame == traceFrame)
{
Expand Down
4 changes: 2 additions & 2 deletions src/System.Management.Automation/help/MUIFileSearcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private string[] GetFiles(string path, string pattern)
#if UNIX
// On Linux, file names are case sensitive, so we need to add
// extra logic to select the files that match the given pattern.
ArrayList result = new ArrayList();
var result = new List<string>();
string[] files = Directory.GetFiles(path);

var wildcardPattern = WildcardPattern.ContainsWildcardCharacters(pattern)
Expand All @@ -143,7 +143,7 @@ private string[] GetFiles(string path, string pattern)
}
}

return (string[])result.ToArray(typeof(string));
return result.ToArray();
#else
return Directory.GetFiles(path, pattern);
#endif
Expand Down
Loading