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 @@ -18,12 +18,12 @@ internal class ClientMethodExecutor
/// <summary>
/// Transport manager.
/// </summary>
private BaseClientTransportManager _transportManager;
private readonly BaseClientTransportManager _transportManager;

/// <summary>
/// Client host.
/// </summary>
private PSHost _clientHost;
private readonly PSHost _clientHost;

/// <summary>
/// Client runspace pool id.
Expand All @@ -38,7 +38,7 @@ internal class ClientMethodExecutor
/// <summary>
/// Remote host call.
/// </summary>
private RemoteHostCall _remoteHostCall;
private readonly RemoteHostCall _remoteHostCall;

/// <summary>
/// Remote host call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal class ClientRemotePowerShell : IDisposable
#region Tracer

[TraceSourceAttribute("CRPS", "ClientRemotePowerShell")]
private static PSTraceSource s_tracer = PSTraceSource.GetTracer("CRPS", "ClientRemotePowerShellBase");
private static readonly PSTraceSource s_tracer = PSTraceSource.GetTracer("CRPS", "ClientRemotePowerShellBase");

#endregion Tracer

Expand Down Expand Up @@ -929,7 +929,7 @@ private void HandleRobustConnectionNotification(
/// datastructure handler. We cannot send the state back to the upper layers until
/// close is completed from the datastructure/transport layer.
/// </summary>
private Queue<PSInvocationStateInfo> _stateInfoQueue = new Queue<PSInvocationStateInfo>();
private readonly Queue<PSInvocationStateInfo> _stateInfoQueue = new Queue<PSInvocationStateInfo>();

private PSConnectionRetryStatus _connectionRetryStatus = PSConnectionRetryStatus.None;

Expand Down
20 changes: 10 additions & 10 deletions src/System.Management.Automation/engine/remoting/client/Job.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public JobState CurrentState
/// State of job when exception was thrown.
/// </summary>
[NonSerialized]
private JobState _currState = 0;
private readonly JobState _currState = 0;
}

/// <summary>
Expand Down Expand Up @@ -2055,7 +2055,7 @@ private void SubmitAndWaitForConnect(List<IThrottleOperation> connectJobOperatio
/// </summary>
private class ConnectJobOperation : IThrottleOperation
{
private PSRemotingChildJob _psRemoteChildJob;
private readonly PSRemotingChildJob _psRemoteChildJob;

internal ConnectJobOperation(PSRemotingChildJob job)
{
Expand Down Expand Up @@ -2666,7 +2666,7 @@ private void HandleJobUnblocked(object sender, EventArgs eventArgs)

#region Private Members

private ThrottleManager _throttleManager = new ThrottleManager();
private readonly ThrottleManager _throttleManager = new ThrottleManager();

private readonly object _syncObject = new object(); // sync object

Expand Down Expand Up @@ -3824,7 +3824,7 @@ private void HandleRunspaceAvailabilityChanged(object sender, RunspaceAvailabili
#region Private Members

// helper associated with this job object
private RemotePipeline _remotePipeline = null;
private readonly RemotePipeline _remotePipeline = null;

// object used for synchronization
protected object SyncObject = new object();
Expand All @@ -3849,9 +3849,9 @@ internal sealed class RemotingJobDebugger : Debugger
{
#region Members

private Debugger _wrappedDebugger;
private Runspace _runspace;
private string _jobName;
private readonly Debugger _wrappedDebugger;
private readonly Runspace _runspace;
private readonly string _jobName;

#endregion

Expand Down Expand Up @@ -4171,9 +4171,9 @@ internal class PSInvokeExpressionSyncJob : PSRemotingChildJob
{
#region Private Members

private List<ExecutionCmdletHelper> _helpers = new List<ExecutionCmdletHelper>();
private ThrottleManager _throttleManager;
private Dictionary<Guid, PowerShell> _powershells = new Dictionary<Guid, PowerShell>();
private readonly List<ExecutionCmdletHelper> _helpers = new List<ExecutionCmdletHelper>();
private readonly ThrottleManager _throttleManager;
private readonly Dictionary<Guid, PowerShell> _powershells = new Dictionary<Guid, PowerShell>();

private int _pipelineFinishedCount;
private int _pipelineDisconnectedCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ public override void StartJob()
_tracer.WriteMessage(TraceClassName, "StartJob", Guid.Empty, this, "Exiting method", null);
}

private static Tracer s_structuredTracer = new Tracer();
private static readonly Tracer s_structuredTracer = new Tracer();

/// <summary>
/// Starts all child jobs asynchronously.
Expand Down Expand Up @@ -2166,14 +2166,14 @@ protected JobFailedException(SerializationInfo serializationInfo, StreamingConte
/// </summary>
public Exception Reason { get { return _reason; } }

private Exception _reason;
private readonly Exception _reason;

/// <summary>
/// The user-focused location from where this error originated.
/// </summary>
public ScriptExtent DisplayScriptPosition { get { return _displayScriptPosition; } }

private ScriptExtent _displayScriptPosition;
private readonly ScriptExtent _displayScriptPosition;

/// <summary>
/// Gets the information for serialization.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ internal override void PropagateApplicationPrivateData(Runspace runspace)
}

private PSPrimitiveDictionary _applicationPrivateData;
private ManualResetEvent _applicationPrivateDataReceived = new ManualResetEvent(false);
private readonly ManualResetEvent _applicationPrivateDataReceived = new ManualResetEvent(false);

/// <summary>
/// This event is raised, when a host call is for a remote runspace
Expand Down Expand Up @@ -1881,7 +1881,7 @@ private void WaitAndRaiseConnectEventsProc(object state)

#region Private Members

private RunspaceConnectionInfo _connectionInfo; // connection info with which this
private readonly RunspaceConnectionInfo _connectionInfo; // connection info with which this
// runspace is created
// data structure handler handling
private RunspacePoolAsyncResult _openAsyncResult;// async result object generated on
Expand All @@ -1898,7 +1898,7 @@ private void WaitAndRaiseConnectEventsProc(object state)
private bool _canReconnect;
private string _friendlyName = string.Empty;

private System.Collections.Concurrent.ConcurrentStack<PowerShell> _runningPowerShells;
private readonly System.Collections.Concurrent.ConcurrentStack<PowerShell> _runningPowerShells;

#endregion Private Members

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public OriginInfo OriginInfo
}
}

private OriginInfo _originInfo;
private readonly OriginInfo _originInfo;

/// <summary>
/// Constructor.
Expand Down Expand Up @@ -302,7 +302,7 @@ public string PSComputerName
}

[DataMemberAttribute()]
private string _computerName;
private readonly string _computerName;

/// <summary>
/// Runspace instance ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -863,21 +863,21 @@ private void HandleSessionCreateCompleted(object sender, CreateCompleteEventArgs
#region Private Members

private Guid _clientRunspacePoolId;
private object _syncObject = new object();
private readonly object _syncObject = new object();
private bool _createRunspaceCalled = false;
private Exception _closingReason;
private int _minRunspaces;
private int _maxRunspaces;
private PSHost _host;
private PSPrimitiveDictionary _applicationArguments;
private readonly int _minRunspaces;
private readonly int _maxRunspaces;
private readonly PSHost _host;
private readonly PSPrimitiveDictionary _applicationArguments;

private Dictionary<Guid, ClientPowerShellDataStructureHandler> _associatedPowerShellDSHandlers
private readonly Dictionary<Guid, ClientPowerShellDataStructureHandler> _associatedPowerShellDSHandlers
= new Dictionary<Guid, ClientPowerShellDataStructureHandler>();
// data structure handlers of all ClientRemotePowerShell which are
// associated with this runspace pool
private object _associationSyncObject = new object();
private readonly object _associationSyncObject = new object();
// object to synchronize operations to above
private BaseClientSessionTransportManager _transportManager;
private readonly BaseClientSessionTransportManager _transportManager;
// session transport manager associated with this runspace

private List<BaseClientCommandTransportManager> _preparingForDisconnectList;
Expand Down Expand Up @@ -1604,7 +1604,7 @@ private void SetupTransportManager(bool inDisconnectMode)

// object for synchronizing input to be sent
// to server powershell
private object _inputSyncObject = new object();
private readonly object _inputSyncObject = new object();

private enum connectionStates
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ internal class RunspaceRef
/// <summary>
/// Runspace ref.
/// </summary>
private ObjectRef<Runspace> _runspaceRef;
private readonly ObjectRef<Runspace> _runspaceRef;
private bool _stopInvoke;
private object _localSyncObject;
private static RobustConnectionProgress s_RCProgress = new RobustConnectionProgress();
private readonly object _localSyncObject;
private static readonly RobustConnectionProgress s_RCProgress = new RobustConnectionProgress();

/// <summary>
/// Constructor for RunspaceRef.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal class ClientRemoteSessionContext
internal abstract class ClientRemoteSession : RemoteSession
{
[TraceSourceAttribute("CRSession", "ClientRemoteSession")]
private static PSTraceSource s_trace = PSTraceSource.GetTracer("CRSession", "ClientRemoteSession");
private static readonly PSTraceSource s_trace = PSTraceSource.GetTracer("CRSession", "ClientRemoteSession");

#region Public_Method_API

Expand Down Expand Up @@ -178,7 +178,7 @@ internal RemoteRunspacePoolInternal GetRunspacePool(Guid clientRunspacePoolId)
internal class ClientRemoteSessionImpl : ClientRemoteSession, IDisposable
{
[TraceSourceAttribute("CRSessionImpl", "ClientRemoteSessionImpl")]
private static PSTraceSource s_trace = PSTraceSource.GetTracer("CRSessionImpl", "ClientRemoteSessionImpl");
private static readonly PSTraceSource s_trace = PSTraceSource.GetTracer("CRSessionImpl", "ClientRemoteSessionImpl");

private PSRemotingCryptoHelperClient _cryptoHelper = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@ namespace System.Management.Automation.Remoting
internal class ClientRemoteSessionDSHandlerStateMachine
{
[TraceSourceAttribute("CRSessionFSM", "CRSessionFSM")]
private static PSTraceSource s_trace = PSTraceSource.GetTracer("CRSessionFSM", "CRSessionFSM");
private static readonly PSTraceSource s_trace = PSTraceSource.GetTracer("CRSessionFSM", "CRSessionFSM");

/// <summary>
/// Event handling matrix. It defines what action to take when an event occur.
/// [State,Event]=>Action.
/// </summary>
private EventHandler<RemoteSessionStateMachineEventArgs>[,] _stateMachineHandle;
private Queue<RemoteSessionStateEventArgs> _clientRemoteSessionStateChangeQueue;
private readonly EventHandler<RemoteSessionStateMachineEventArgs>[,] _stateMachineHandle;
private readonly Queue<RemoteSessionStateEventArgs> _clientRemoteSessionStateChangeQueue;

/// <summary>
/// Current state of session.
/// </summary>
private RemoteSessionState _state;

private Queue<RemoteSessionStateMachineEventArgs> _processPendingEventsQueue
private readonly Queue<RemoteSessionStateMachineEventArgs> _processPendingEventsQueue
= new Queue<RemoteSessionStateMachineEventArgs>();
// all events raised through the state machine
// will be queued in this
private object _syncObject = new object();
private readonly object _syncObject = new object();
// object for synchronizing access to the above
// queue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ internal class RemotePipeline : Pipeline
#region Private Members

private PowerShell _powershell;
private bool _addToHistory;
private readonly bool _addToHistory;
private bool _isNested;
private bool _isSteppable;
private Runspace _runspace;
private object _syncRoot = new object();
private readonly Runspace _runspace;
private readonly object _syncRoot = new object();
private bool _disposed = false;
private string _historyString;
private PipelineStateInfo _pipelineStateInfo = new PipelineStateInfo(PipelineState.NotStarted);
private CommandCollection _commands = new CommandCollection();
private string _computerName;
private readonly CommandCollection _commands = new CommandCollection();
private readonly string _computerName;
private Guid _runspaceId;
private ConnectCommandInfo _connectCmdInfo = null;
private readonly ConnectCommandInfo _connectCmdInfo = null;

/// <summary>
/// This is queue of all the state change event which have occured for
Expand All @@ -56,7 +56,7 @@ public ExecutionEventQueueItem(PipelineStateInfo pipelineStateInfo, RunspaceAvai
public RunspaceAvailability NewRunspaceAvailability;
}

private bool _performNestedCheck = true;
private readonly bool _performNestedCheck = true;

#endregion Private Members

Expand Down Expand Up @@ -360,12 +360,12 @@ public bool AddToHistory
// Stream and Collection go together...a stream wraps
// a corresponding collection to support
// streaming behavior of the pipeline.
private PSDataCollection<PSObject> _outputCollection;
private PSDataCollectionStream<PSObject> _outputStream;
private PSDataCollection<ErrorRecord> _errorCollection;
private PSDataCollectionStream<ErrorRecord> _errorStream;
private PSDataCollection<object> _inputCollection;
private PSDataCollectionStream<object> _inputStream;
private readonly PSDataCollection<PSObject> _outputCollection;
private readonly PSDataCollectionStream<PSObject> _outputStream;
private readonly PSDataCollection<ErrorRecord> _errorCollection;
private readonly PSDataCollectionStream<ErrorRecord> _errorStream;
private readonly PSDataCollection<object> _inputCollection;
private readonly PSDataCollectionStream<object> _inputStream;

/// <summary>
/// Stream for providing input to PipelineProcessor. Host will write on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ internal class RemoteRunspace : Runspace, IDisposable
{
#region Private Members

private List<RemotePipeline> _runningPipelines = new List<RemotePipeline>();
private object _syncRoot = new object();
private readonly List<RemotePipeline> _runningPipelines = new List<RemotePipeline>();
private readonly object _syncRoot = new object();
private RunspaceStateInfo _runspaceStateInfo = new RunspaceStateInfo(RunspaceState.BeforeOpen);
private bool _bSessionStateProxyCallInProgress = false;
private RunspaceConnectionInfo _connectionInfo;
private readonly bool _bSessionStateProxyCallInProgress = false;
private readonly RunspaceConnectionInfo _connectionInfo;
private RemoteDebugger _remoteDebugger;
private PSPrimitiveDictionary _applicationPrivateData;

Expand Down Expand Up @@ -1792,7 +1792,7 @@ internal sealed class RemoteDebugger : Debugger, IDisposable
{
#region Members

private RemoteRunspace _runspace;
private readonly RemoteRunspace _runspace;
private PowerShell _psDebuggerCommand;
private bool _remoteDebugSupported;
private bool _isActive;
Expand Down Expand Up @@ -2933,7 +2933,7 @@ private void CheckRemoteBreakpointManagementSupport(string breakpointCommandName

internal class RemoteSessionStateProxy : SessionStateProxy
{
private RemoteRunspace _runspace;
private readonly RemoteRunspace _runspace;

internal RemoteSessionStateProxy(RemoteRunspace runspace)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ namespace System.Management.Automation.Remoting
internal class ClientRemoteSessionDSHandlerImpl : ClientRemoteSessionDataStructureHandler, IDisposable
{
[TraceSourceAttribute("CRSDSHdlerImpl", "ClientRemoteSessionDSHandlerImpl")]
private static PSTraceSource s_trace = PSTraceSource.GetTracer("CRSDSHdlerImpl", "ClientRemoteSessionDSHandlerImpl");
private static readonly PSTraceSource s_trace = PSTraceSource.GetTracer("CRSDSHdlerImpl", "ClientRemoteSessionDSHandlerImpl");

private const string resBaseName = "remotingerroridstrings";

private BaseClientSessionTransportManager _transportManager;
private ClientRemoteSessionDSHandlerStateMachine _stateMachine;
private ClientRemoteSession _session;
private RunspaceConnectionInfo _connectionInfo;
private readonly BaseClientSessionTransportManager _transportManager;
private readonly ClientRemoteSessionDSHandlerStateMachine _stateMachine;
private readonly ClientRemoteSession _session;
private readonly RunspaceConnectionInfo _connectionInfo;
// used for connection redirection.
private Uri _redirectUri;
private int _maxUriRedirectionCount;
private bool _isCloseCalled;
private object _syncObject = new object();
private PSRemotingCryptoHelper _cryptoHelper;
private readonly object _syncObject = new object();
private readonly PSRemotingCryptoHelper _cryptoHelper;

private ClientRemoteSession.URIDirectionReported _uriRedirectionHandler;
private readonly ClientRemoteSession.URIDirectionReported _uriRedirectionHandler;

internal override BaseClientSessionTransportManager TransportManager
{
Expand Down
Loading