Cleanup workflow - remove PSProxyJob (#10083)

This commit is contained in:
Ilya 2019-07-12 07:56:27 +05:00 committed by GitHub
parent 7150308de6
commit 18ff2b6b1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1 additions and 3083 deletions

View File

@ -3896,29 +3896,6 @@ namespace System.Management.Automation
}
}
/// <summary>
/// This has been added as a work around for Windows8 bug 803461.
/// It should be used only for the PSJobProxy API.
///
/// Resets the instance ID of the command to a new guid.
/// If this is not done, then there is a race condition on the server
/// in the following circumstances:
///
/// ps.BeginInvoke(...);
/// ps.Stop()
/// ps.Commands.Clear();
/// ps.AddCommand("Foo");
/// ps.Invoke();
///
/// In these conditions, stop returns before the server is done cleaning up.
/// The subsequent invoke will cause an error because the guid already
/// identifies a command in progress.
/// </summary>
internal void GenerateNewInstanceId()
{
InstanceId = Guid.NewGuid();
}
/// <summary>
/// Get a steppable pipeline object.
/// </summary>
@ -5935,55 +5912,6 @@ namespace System.Management.Automation
#endregion
#region V3 Extensions
/// <summary>
/// Returns a job object which can be used to
/// control the invocation of the command with
/// AsJob Parameter.
/// </summary>
/// <returns>Job object.</returns>
public PSJobProxy AsJobProxy()
{
// if there are no commands added
// throw an invalid operation exception
if (this.Commands.Commands.Count == 0)
{
throw PSTraceSource.NewInvalidOperationException(PowerShellStrings.GetJobForCommandRequiresACommand);
}
// if there is more than one command in the
// command collection throw an error
if (this.Commands.Commands.Count > 1)
{
throw PSTraceSource.NewInvalidOperationException(PowerShellStrings.GetJobForCommandNotSupported);
}
// check if the AsJob parameter has already
// been added. If not, add the same
bool found = false;
foreach (CommandParameter parameter in this.Commands.Commands[0].Parameters)
{
if (string.Compare(parameter.Name, "AsJob", StringComparison.OrdinalIgnoreCase) == 0)
{
found = true;
}
}
if (!found)
{
AddParameter("AsJob");
}
// initialize the job invoker and return the same
PSJobProxy job = new PSJobProxy(this.Commands.Commands[0].CommandText);
job.InitializeJobProxy(this.Commands, this.Runspace, this.RunspacePool);
return job;
}
#endregion V3 Extensions
#if !CORECLR // PSMI Not Supported On CSS
#region Win Blue Extensions

View File

@ -159,30 +159,15 @@
<data name="CommandInvokedFromWrongThreadWithCommand" xml:space="preserve">
<value>There is no Runspace available to run commands in this thread. You can provide one in the DefaultRunspace property of the System.Management.Automation.Runspaces.Runspace type. The command you attempted to invoke was: {0}</value>
</data>
<data name="JobProxyReceiveInvalid" xml:space="preserve">
<value>You can only begin receiving data on a PSJobProxy instance when it has been created with data streaming disabled. This operation can run only once.</value>
</data>
<data name="GetJobForCommandNotSupported" xml:space="preserve">
<value>GetJobForCommand is not supported when there is more than one command in the PowerShell instance.</value>
</data>
<data name="GetJobForCommandRequiresACommand" xml:space="preserve">
<value>The Command property of a PowerShell object cannot be empty.</value>
</data>
<data name="CommandDoesNotWriteJob" xml:space="preserve">
<value>The PSJobProxy object can only be used for remote commands that return a job object.</value>
<comment>PSJobProxy is the name of a class and should not be localized</comment>
</data>
<data name="JobCannotBeStartedWhenRunning" xml:space="preserve">
<value>A job cannot be started when it is already running.</value>
</data>
<data name="OnlyWorkflowInvocationSettingsSupported" xml:space="preserve">
<value>PSJobProxy currently supports only PSWorkflowInvocationSettings.</value>
<comment>PSJobProxy and PSWorkflowInvocationSettings are the names of classes and should not be localized</comment>
</data>
<data name="RunspaceAndRunspacePoolNull" xml:space="preserve">
<value>Either a runspace or runspace pool must be assigned to PSJobProxy before it can be started.</value>
<comment>PSJobProxy is the name of a class and should not be localized</comment>
</data>
<data name="UnblockNotSupported" xml:space="preserve">
<value>Support for interactive jobs is not available</value>
</data>
@ -217,18 +202,7 @@
<data name="CommandInvokedFromWrongThreadWithoutCommand" xml:space="preserve">
<value>There is no Runspace available to run commands in this thread. You can provide one in the DefaultRunspace property of the System.Management.Automation.Runspaces.Runspace type. The current PowerShell instance contains no command to invoke.</value>
</data>
<data name="JobProxyAsJobMustBeTrue" xml:space="preserve">
<value>A command in which the value of AsJob is equal to false cannot be run through a PSJobProxy.</value>
<comment>PSJobProxy is the name of a class and should not be localized. AsJob is the name of a parameter and should not be localized.</comment>
</data>
<data name="ProxyUnblockJobNotSupported" xml:space="preserve">
<value>PSJobProxy does not support the Unblock operation.</value>
<comment>PSJobProxy is the name of a class and should not be localized</comment>
</data>
<data name="NoDefaultRunspaceForPSCreate" xml:space="preserve">
<value>A PowerShell object cannot be created that uses the current runspace because there is no current runspace available. The current runspace might be starting, such as when it is created with an Initial Session State.</value>
</data>
<data name="ProxyJobControlNotSupported" xml:space="preserve">
<value>PSJobProxy does not support this control method.</value>
</data>
</root>

View File

@ -973,9 +973,6 @@ All WinRM sessions connected to PowerShell session configurations, such as Micro
<data name="SetEnabledTrueTarget" xml:space="preserve">
<value>Enabled: True. This configures the WS-Management service to accept the connection request.</value>
</data>
<data name="PSJobProxyInvalidReasonException" xml:space="preserve">
<value>Reason in a deserialized Job object is not valid.</value>
</data>
<data name="DISCAliasDefinitionsComment" xml:space="preserve">
<value>Aliases to be defined when applied to a session</value>
</data>

View File

@ -754,7 +754,7 @@ dir -Recurse `
It "Test member completion of a static method invocation" {
$inputStr = '[powershell]::Create().'
$res = TabExpansion2 -inputScript $inputStr -cursorColumn $inputStr.Length
$res.CompletionMatches | Should -HaveCount 34
$res.CompletionMatches | Should -HaveCount 33
$res.CompletionMatches[0].CompletionText | Should -BeExactly "Commands"
}
}