Skip to content

Commit f83660e

Browse files
authored
Seal ClientRemotePowerShell (PowerShell#15802)
Seal `System.Management.Automation.Runspaces.Internal.ClientRemotePowerShell Simplify IDisposable implementation
1 parent 3eca7c0 commit f83660e

File tree

1 file changed

+28
-41
lines changed

1 file changed

+28
-41
lines changed

src/System.Management.Automation/engine/remoting/client/ClientRemotePowerShell.cs

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace System.Management.Automation.Runspaces.Internal
1515
/// PowerShell client side proxy base which handles invocation
1616
/// of powershell on a remote machine.
1717
/// </summary>
18-
internal class ClientRemotePowerShell : IDisposable
18+
internal sealed class ClientRemotePowerShell : IDisposable
1919
{
2020
#region Tracer
2121

@@ -902,28 +902,28 @@ private void HandleRobustConnectionNotification(
902902

903903
#endregion Private Methods
904904

905-
#region Protected Members
906-
907-
protected ObjectStreamBase inputstream;
908-
protected ObjectStreamBase errorstream;
909-
protected PSInformationalBuffers informationalBuffers;
910-
protected PowerShell shell;
911-
protected Guid clientRunspacePoolId;
912-
protected bool noInput;
913-
protected PSInvocationSettings settings;
914-
protected ObjectStreamBase outputstream;
915-
protected string computerName;
916-
protected ClientPowerShellDataStructureHandler dataStructureHandler;
917-
protected bool stopCalled = false;
918-
protected PSHost hostToUse;
919-
protected RemoteRunspacePoolInternal runspacePool;
920-
921-
protected const string WRITE_DEBUG_LINE = "WriteDebugLine";
922-
protected const string WRITE_VERBOSE_LINE = "WriteVerboseLine";
923-
protected const string WRITE_WARNING_LINE = "WriteWarningLine";
924-
protected const string WRITE_PROGRESS = "WriteProgress";
925-
926-
protected bool initialized = false;
905+
#region Private Fields
906+
907+
private ObjectStreamBase inputstream;
908+
private ObjectStreamBase errorstream;
909+
private PSInformationalBuffers informationalBuffers;
910+
private readonly PowerShell shell;
911+
private readonly Guid clientRunspacePoolId;
912+
private bool noInput;
913+
private PSInvocationSettings settings;
914+
private ObjectStreamBase outputstream;
915+
private readonly string computerName;
916+
private ClientPowerShellDataStructureHandler dataStructureHandler;
917+
private bool stopCalled = false;
918+
private PSHost hostToUse;
919+
private readonly RemoteRunspacePoolInternal runspacePool;
920+
921+
private const string WRITE_DEBUG_LINE = "WriteDebugLine";
922+
private const string WRITE_VERBOSE_LINE = "WriteVerboseLine";
923+
private const string WRITE_WARNING_LINE = "WriteWarningLine";
924+
private const string WRITE_PROGRESS = "WriteProgress";
925+
926+
private bool initialized = false;
927927
/// <summary>
928928
/// This queue is for the state change events that resulted in closing the underlying
929929
/// datastructure handler. We cannot send the state back to the upper layers until
@@ -933,33 +933,20 @@ private void HandleRobustConnectionNotification(
933933

934934
private PSConnectionRetryStatus _connectionRetryStatus = PSConnectionRetryStatus.None;
935935

936-
#endregion Protected Members
936+
#endregion Private Fields
937937

938938
#region IDisposable
939939

940940
/// <summary>
941-
/// Public interface for dispose.
941+
/// Release all resources.
942942
/// </summary>
943943
public void Dispose()
944944
{
945-
Dispose(true);
946-
947-
GC.SuppressFinalize(this);
945+
// inputstream.Dispose();
946+
// outputstream.Dispose();
947+
// errorstream.Dispose();
948948
}
949949

950-
/// <summary>
951-
/// Release all resources.
952-
/// </summary>
953-
/// <param name="disposing">If true, release all managed resources.</param>
954-
protected void Dispose(bool disposing)
955-
{
956-
if (disposing)
957-
{
958-
// inputstream.Dispose();
959-
// outputstream.Dispose();
960-
// errorstream.Dispose();
961-
}
962-
}
963950
#endregion IDisposable
964951
}
965952

0 commit comments

Comments
 (0)