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 @@ -171,7 +171,7 @@ public string[] ComputerName
set { _computerName = value; }
}

private string[] _computerName = new string[0];
private string[] _computerName = Array.Empty<string>();

private ResourceManager _resourceMgr = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public string[] ListSet
set { _listSet = value; }
}

private string[] _listSet = new string[0];
private string[] _listSet = Array.Empty<string>();

//
// StartTime parameter
Expand Down Expand Up @@ -138,7 +138,7 @@ public string[] Counter
set { _counter = value; }
}

private string[] _counter = new string[0];
private string[] _counter = Array.Empty<string>();

//
// Summary switch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class JoinPathCommand : CoreCommandWithCredentialsBase
[AllowNull]
[AllowEmptyString]
[AllowEmptyCollection]
public string[] AdditionalChildPath { get; set; } = Utils.EmptyArray<string>();
public string[] AdditionalChildPath { get; set; } = Array.Empty<string>();

/// <summary>
/// Determines if the path should be resolved after being joined.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ private bool IsServerCoreOrHeadLessServer()
using (System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create())
{
ps.AddScript(TestHeadlessServerScript);
Collection<PSObject> psObjectCollection = ps.Invoke(new object[0]);
Collection<PSObject> psObjectCollection = ps.Invoke(Array.Empty<object>());
Dbg.Assert(psObjectCollection != null && psObjectCollection.Count == 1, "invoke should never return null, there should be only one return item");
if (LanguagePrimitives.IsTrue(PSObject.Base(psObjectCollection[0])))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public sealed class GetEventLogCommand : PSCmdlet
[ValidateNotNullOrEmpty()]
[Alias("Cn")]
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
public string[] ComputerName { get; set; } = new string[0];
public string[] ComputerName { get; set; } = Array.Empty<string>();

/// <summary>
/// Read only this number of entries.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public string[] Name
{
if (value == null)
{
value = Utils.EmptyArray<string>();
value = Array.Empty<string>();
}

_property = value;
Expand Down Expand Up @@ -111,7 +111,7 @@ internal override object GetDynamicParameters(CmdletProviderContext context)
/// <summary>
/// The property to be created.
/// </summary>
private string[] _property = new string[0];
private string[] _property = Array.Empty<string>();

#endregion parameter data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public virtual string[] Include
{
get;
set;
} = new string[0];
} = Array.Empty<string>();

/// <summary>
/// Gets or sets the exclude property.
Expand All @@ -202,7 +202,7 @@ public virtual string[] Exclude
{
get;
set;
} = new string[0];
} = Array.Empty<string>();

/// <summary>
/// Gets or sets the force property.
Expand Down Expand Up @@ -351,7 +351,7 @@ public class GetLocationCommand : DriveMatchingCoreCommandBase
public string[] PSProvider
{
get => _provider;
set => _provider = value ?? Utils.EmptyArray<string>();
set => _provider = value ?? Array.Empty<string>();
}

/// <summary>
Expand Down Expand Up @@ -401,7 +401,7 @@ public string[] StackName
/// <summary>
/// The name of the provider from which to return the current location.
/// </summary>
private string[] _provider = new string[0];
private string[] _provider = Array.Empty<string>();

#endregion Location parameter set data

Expand Down Expand Up @@ -1522,7 +1522,7 @@ public string[] LiteralName
public string[] PSProvider
{
get => _provider;
set => _provider = value ?? Utils.EmptyArray<string>();
set => _provider = value ?? Array.Empty<string>();
}

/// <summary>
Expand Down Expand Up @@ -1563,7 +1563,7 @@ public override SwitchParameter Force
/// <summary>
/// The name of the provider(s) for which to remove all drives.
/// </summary>
private string[] _provider = new string[0];
private string[] _provider = Array.Empty<string>();

#endregion Command data

Expand Down Expand Up @@ -1717,7 +1717,7 @@ public string[] LiteralName
public string[] PSProvider
{
get => _provider;
set => _provider = value ?? Utils.EmptyArray<string>();
set => _provider = value ?? Array.Empty<string>();
}

#endregion Command parameters
Expand All @@ -1732,7 +1732,7 @@ public string[] PSProvider
/// <summary>
/// The provider ID for the drives you want to see.
/// </summary>
private string[] _provider = new string[0];
private string[] _provider = Array.Empty<string>();

#endregion Command data

Expand Down Expand Up @@ -4137,7 +4137,7 @@ public class GetPSProviderCommand : CoreCommandBase
public string[] PSProvider
{
get => _provider;
set => _provider = value ?? Utils.EmptyArray<string>();
set => _provider = value ?? Array.Empty<string>();
}

#endregion Command parameters
Expand All @@ -4146,7 +4146,7 @@ public string[] PSProvider
/// <summary>
/// The string ID of the provider to remove.
/// </summary>
private string[] _provider = new string[0];
private string[] _provider = Array.Empty<string>();

#endregion Command data

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Management.Automation;
using Dbg = System.Management.Automation;

Expand Down Expand Up @@ -70,7 +71,7 @@ public override string[] Exclude
/// <summary>
/// The path to the item.
/// </summary>
internal string[] paths = new string[0];
internal string[] paths = Array.Empty<string>();

#endregion parameter data
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Management.Automation;
using Dbg = System.Management.Automation;

Expand Down Expand Up @@ -62,7 +63,7 @@ public string[] Name
{
get { return _property; }

set { _property = value ?? Utils.EmptyArray<string>(); }
set { _property = value ?? Array.Empty<string>(); }
}

/// <summary>
Expand Down Expand Up @@ -120,7 +121,7 @@ internal override object GetDynamicParameters(CmdletProviderContext context)
/// <summary>
/// The property to be created.
/// </summary>
private string[] _property = new string[0];
private string[] _property = Array.Empty<string>();

#endregion parameter data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected override void EndProcessing()
{
try
{
var emptyArray = Utils.EmptyArray<object>();
var emptyArray = Array.Empty<object>();
_transactedScript.InvokeUsingCmdlet(
contextCmdlet: this,
useLocalScope: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected override void ProcessRecord()

if (_content == null)
{
_content = new object[0];
_content = Array.Empty<object>();
}

if (_pipingPaths)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public string[] MemberDefinition
[ValidateNotNull()]
[Alias("Using")]
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
public string[] UsingNamespace { get; set; } = Utils.EmptyArray<string>();
public string[] UsingNamespace { get; set; } = Array.Empty<string>();

/// <summary>
/// The path to the source code or DLL to load.
Expand Down Expand Up @@ -310,7 +310,7 @@ public string[] ReferencedAssemblies
}
}

private string[] referencedAssemblies = Utils.EmptyArray<string>();
private string[] referencedAssemblies = Array.Empty<string>();

/// <summary>
/// The path to the output assembly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public string[] TypeName

if (_typename == null)
{
_filter = Utils.EmptyArray<WildcardPattern>();
_filter = Array.Empty<WildcardPattern>();
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public string[] Exclude
{
get { return _excludes; }

set { _excludes = value ?? new string[0]; }
set { _excludes = value ?? Array.Empty<string>(); }
}

private string[] _excludes = new string[0];
private string[] _excludes = Array.Empty<string>();

/// <summary>
/// The scope parameter for the command determines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ public string[] Module
{
if (value == null)
{
value = new string[0];
value = Array.Empty<string>();
}

_PSSnapins = value;
Expand All @@ -449,7 +449,7 @@ public string[] Module
}
}

private string[] _PSSnapins = new string[0];
private string[] _PSSnapins = Array.Empty<string>();
internal bool IsModuleSpecified = false;
/// <summary>
/// Gets or sets the FullyQualifiedModule parameter to the cmdlet.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Management.Automation;
using System.Management.Automation.Internal;

Expand Down Expand Up @@ -42,7 +43,7 @@ protected override void ProcessRecord()
myScriptBlock.LanguageMode = PSLanguageMode.ConstrainedLanguage;
}

var emptyArray = Utils.EmptyArray<object>();
var emptyArray = Array.Empty<object>();
myScriptBlock.InvokeUsingCmdlet(
contextCmdlet: this,
useLocalScope: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected override void ProcessRecord()
useLocalScope: false,
errorHandlingBehavior: ScriptBlock.ErrorHandlingBehavior.WriteToCurrentErrorPipe,
dollarUnder: InputObject, // $_
input: new object[0], // $input
input: Array.Empty<object>(), // $input
scriptThis: AutomationNull.Value,
outputPipe: new Pipe { NullPipe = true },
invocationInfo: null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public class UpdateData : PSCmdlet
ParameterSetName = FileParameterSet)]
[Alias("PSPath", "Path")]
[ValidateNotNull]
public string[] AppendPath { set; get; } = Utils.EmptyArray<string>();
public string[] AppendPath { set; get; } = Array.Empty<string>();

/// <summary>
/// Files to prepend to the existing set.
/// </summary>
[Parameter(ParameterSetName = FileParameterSet)]
[ValidateNotNull]
public string[] PrependPath { set; get; } = Utils.EmptyArray<string>();
public string[] PrependPath { set; get; } = Array.Empty<string>();

private static void ReportWrongExtension(string file, string errorId, PSCmdlet cmdlet)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ protected string[] IncludeFilters
{
if (value == null)
{
value = new string[0];
value = Array.Empty<string>();
}

_include = value;
}
}

private string[] _include = new string[0];
private string[] _include = Array.Empty<string>();

/// <summary>
/// The Exclude parameter for all the variable commands.
Expand All @@ -65,14 +65,14 @@ protected string[] ExcludeFilters
{
if (value == null)
{
value = new string[0];
value = Array.Empty<string>();
}

_exclude = value;
}
}

private string[] _exclude = new string[0];
private string[] _exclude = Array.Empty<string>();

#region helpers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ private static object ProcessCustomObject<T>(object o, int depth, in ConvertToJs
object value;
try
{
value = getMethod.Invoke(o, new object[0]);
value = getMethod.Invoke(o, Array.Empty<object>());
}
catch (Exception)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ protected override void BeginProcessing()

if (ArgumentList == null || ArgumentList.Length == 0)
{
ConstructorInfo ci = type.GetConstructor(PSTypeExtensions.EmptyTypes);
ConstructorInfo ci = type.GetConstructor(Type.EmptyTypes);
if (ci != null && ci.IsPublic)
{
_newObject = CallConstructor(type, new ConstructorInfo[] { ci }, new object[] { });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public PSObject[] EventArguments
}
}

private PSObject[] _eventArguments = new PSObject[0];
private PSObject[] _eventArguments = Array.Empty<PSObject>();

/// <summary>
/// Data relating to this event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ private object RunExpression()
dollarUnder: InputObject,
input: new object[] { InputObject },
scriptThis: AutomationNull.Value,
args: Utils.EmptyArray<object>());
args: Array.Empty<object>());
}

private object StepCommand()
Expand Down
Loading