diff --git a/src/System.Management.Automation/engine/InternalCommands.cs b/src/System.Management.Automation/engine/InternalCommands.cs
index 2b901b782c..010f1e1f9c 100644
--- a/src/System.Management.Automation/engine/InternalCommands.cs
+++ b/src/System.Management.Automation/engine/InternalCommands.cs
@@ -23,7 +23,7 @@ namespace Microsoft.PowerShell.Commands
///
/// A thin wrapper over a property-getting Callsite, to allow reuse when possible.
///
- struct DynamicPropertyGetter
+ internal struct DynamicPropertyGetter
{
private CallSite> _getValueDynamicSite;
@@ -37,7 +37,6 @@ namespace Microsoft.PowerShell.Commands
// If wildcards are involved, the resolved property name could potentially
// be different on every object... but probably not, so we'll attempt to
// reuse the callsite if possible.
-
if (!propertyName.Equals(_lastUsedPropertyName, StringComparison.OrdinalIgnoreCase))
{
_lastUsedPropertyName = propertyName;
@@ -91,81 +90,93 @@ namespace Microsoft.PowerShell.Commands
private List _scripts = new List();
///
- /// The script block to apply in begin processing.
+ /// Gets or sets the script block to apply in begin processing.
///
[Parameter(ParameterSetName = ForEachObjectCommand.ScriptBlockSet)]
public ScriptBlock Begin
{
- set
- {
- _scripts.Insert(0, value);
- }
-
get
{
return null;
}
+
+ set
+ {
+ _scripts.Insert(0, value);
+ }
}
///
- /// The script block to apply.
+ /// Gets or sets the script block to apply.
///
[Parameter(Mandatory = true, Position = 0, ParameterSetName = ForEachObjectCommand.ScriptBlockSet)]
[AllowNull]
[AllowEmptyCollection]
public ScriptBlock[] Process
{
- set
- {
- if (value == null)
- _scripts.Add(null);
- else
- _scripts.AddRange(value);
- }
-
get
{
return null;
}
+
+ set
+ {
+ if (value == null)
+ {
+ _scripts.Add(null);
+ }
+ else
+ {
+ _scripts.AddRange(value);
+ }
+ }
}
private ScriptBlock _endScript;
private bool _setEndScript;
+
///
- /// The script block to apply in complete processing.
+ /// Gets or sets the script block to apply in complete processing.
///
[Parameter(ParameterSetName = ForEachObjectCommand.ScriptBlockSet)]
public ScriptBlock End
{
+ get
+ {
+ return _endScript;
+ }
+
set
{
_endScript = value;
_setEndScript = true;
}
-
- get
- {
- return _endScript;
- }
}
///
- /// The remaining script blocks to apply.
+ /// Gets or sets the remaining script blocks to apply.
///
[Parameter(ParameterSetName = ForEachObjectCommand.ScriptBlockSet, ValueFromRemainingArguments = true)]
[AllowNull]
[AllowEmptyCollection]
public ScriptBlock[] RemainingScripts
{
+ get
+ {
+ return null;
+ }
+
set
{
if (value == null)
+ {
_scripts.Add(null);
+ }
else
+ {
_scripts.AddRange(value);
+ }
}
-
- get { return null; }
}
private int _start, _end;
@@ -175,16 +186,22 @@ namespace Microsoft.PowerShell.Commands
#region PropertyAndMethodSet
///
- /// The property or method name.
+ /// Gets or sets the property or method name.
///
[Parameter(Mandatory = true, Position = 0, ParameterSetName = ForEachObjectCommand.PropertyAndMethodSet)]
[ValidateTrustedData]
[ValidateNotNullOrEmpty]
public string MemberName
{
- set { _propertyOrMethodName = value; }
+ get
+ {
+ return _propertyOrMethodName;
+ }
- get { return _propertyOrMethodName; }
+ set
+ {
+ _propertyOrMethodName = value;
+ }
}
private string _propertyOrMethodName;
@@ -341,7 +358,7 @@ namespace Microsoft.PowerShell.Commands
}
#endregion
-
+
#region Private Methods
#region PSTasks
@@ -375,7 +392,7 @@ namespace Microsoft.PowerShell.Commands
allowUsingExpression,
this.Context,
null);
-
+
// Validate using values map, which is a map of '$using:' variables referenced in the script.
// Script block variables are not allowed since their behavior is undefined outside the runspace
// in which they were created.
@@ -498,7 +515,9 @@ namespace Microsoft.PowerShell.Commands
private void EndBlockParameterSet()
{
if (_endScript == null)
+ {
return;
+ }
var emptyArray = Array.Empty