Mark private members as static part 8 (#14233)
https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822
This commit is contained in:
parent
8c8487cc78
commit
94597deb39
|
@ -132,7 +132,7 @@ namespace System.Management.Automation.Remoting
|
|||
/// <summary>
|
||||
/// Is runspace pushed.
|
||||
/// </summary>
|
||||
private bool IsRunspacePushed(PSHost host)
|
||||
private static bool IsRunspacePushed(PSHost host)
|
||||
{
|
||||
if (!(host is IHostSupportsInteractiveSession host2)) { return false; }
|
||||
|
||||
|
|
|
@ -663,7 +663,7 @@ namespace System.Management.Automation.Runspaces.Internal
|
|||
}
|
||||
}
|
||||
|
||||
private bool IsFinished(PSInvocationState state)
|
||||
private static bool IsFinished(PSInvocationState state)
|
||||
{
|
||||
return (state == PSInvocationState.Completed ||
|
||||
state == PSInvocationState.Failed ||
|
||||
|
|
|
@ -2016,7 +2016,7 @@ namespace System.Management.Automation
|
|||
SubmitAndWaitForConnect(connectJobOperations);
|
||||
}
|
||||
|
||||
private void SubmitAndWaitForConnect(List<IThrottleOperation> connectJobOperations)
|
||||
private static void SubmitAndWaitForConnect(List<IThrottleOperation> connectJobOperations)
|
||||
{
|
||||
using (ThrottleManager connectThrottleManager = new ThrottleManager())
|
||||
{
|
||||
|
@ -4122,7 +4122,7 @@ namespace System.Management.Automation
|
|||
return null;
|
||||
}
|
||||
|
||||
private void RestoreRemoteOutput(Pipeline runningCmd)
|
||||
private static void RestoreRemoteOutput(Pipeline runningCmd)
|
||||
{
|
||||
if (runningCmd != null)
|
||||
{
|
||||
|
|
|
@ -616,7 +616,7 @@ namespace System.Management.Automation
|
|||
/// <param name="sourceAdapter"></param>
|
||||
/// <param name="jobSourceAdapterTypes"></param>
|
||||
/// <returns></returns>
|
||||
private bool CheckTypeNames(JobSourceAdapter sourceAdapter, string[] jobSourceAdapterTypes)
|
||||
private static bool CheckTypeNames(JobSourceAdapter sourceAdapter, string[] jobSourceAdapterTypes)
|
||||
{
|
||||
// If no type names were specified then allow all adapter types.
|
||||
if (jobSourceAdapterTypes == null ||
|
||||
|
@ -641,7 +641,7 @@ namespace System.Management.Automation
|
|||
return false;
|
||||
}
|
||||
|
||||
private string GetAdapterName(JobSourceAdapter sourceAdapter)
|
||||
private static string GetAdapterName(JobSourceAdapter sourceAdapter)
|
||||
{
|
||||
return (!string.IsNullOrEmpty(sourceAdapter.Name) ?
|
||||
sourceAdapter.Name :
|
||||
|
|
|
@ -139,7 +139,7 @@ namespace System.Management.Automation.Remoting
|
|||
/// <summary>
|
||||
/// Creates the PSCommand when the runspace is not overridden.
|
||||
/// </summary>
|
||||
private PSCommand CreatePsCommandNotOverridden(string line, bool isScript, bool? useNewScope)
|
||||
private static PSCommand CreatePsCommandNotOverridden(string line, bool isScript, bool? useNewScope)
|
||||
{
|
||||
PSCommand command = new PSCommand();
|
||||
|
||||
|
@ -407,7 +407,7 @@ namespace System.Management.Automation.Remoting
|
|||
}
|
||||
}
|
||||
|
||||
private void StopProgressBar(
|
||||
private static void StopProgressBar(
|
||||
long sourceId)
|
||||
{
|
||||
s_RCProgress.StopProgress(sourceId);
|
||||
|
|
|
@ -776,7 +776,7 @@ namespace System.Management.Automation.Remoting
|
|||
|
||||
#endregion Event Handlers
|
||||
|
||||
private void CleanAll()
|
||||
private static void CleanAll()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -347,7 +347,7 @@ namespace System.Management.Automation.Runspaces
|
|||
/// </summary>
|
||||
/// <param name="shell">Shell configuration name.</param>
|
||||
/// <returns>Display shell name.</returns>
|
||||
private string GetDisplayShellName(string shell)
|
||||
private static string GetDisplayShellName(string shell)
|
||||
{
|
||||
string shellPrefix = System.Management.Automation.Remoting.Client.WSManNativeApi.ResourceURIPrefix;
|
||||
int index = shell.IndexOf(shellPrefix, StringComparison.OrdinalIgnoreCase);
|
||||
|
|
|
@ -641,7 +641,7 @@ else
|
|||
/// 1. New shell successfully registered. However cannot delete temporary plugin file {0}.
|
||||
/// Reason for failure: {1}.
|
||||
/// </exception>
|
||||
private void DeleteFile(string tmpFileName)
|
||||
private static void DeleteFile(string tmpFileName)
|
||||
{
|
||||
Dbg.Assert(!string.IsNullOrEmpty(tmpFileName), "tmpFile cannot be null or empty.");
|
||||
|
||||
|
@ -693,7 +693,7 @@ else
|
|||
/// 2. Cannot write shell configuration data into temporary file {0}. Try again.
|
||||
/// Reason for failure: {1}.
|
||||
/// </exception>
|
||||
private string ConstructTemporaryFile(string pluginContent)
|
||||
private static string ConstructTemporaryFile(string pluginContent)
|
||||
{
|
||||
// Path.GetTempFileName creates a temporary file whereas GetRandomFileName does not.
|
||||
string tmpFileName = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetRandomFileName()) + "psshell.xml";
|
||||
|
|
|
@ -237,7 +237,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
return debuggableJobFound;
|
||||
}
|
||||
|
||||
private bool GetJobDebuggable(Job job)
|
||||
private static bool GetJobDebuggable(Job job)
|
||||
{
|
||||
if (job is IJobDebugger)
|
||||
{
|
||||
|
|
|
@ -363,7 +363,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
return true;
|
||||
}
|
||||
|
||||
private string GetLocalhostWithNetworkAccessEnabled(Dictionary<Guid, PSSession> psSessions)
|
||||
private static string GetLocalhostWithNetworkAccessEnabled(Dictionary<Guid, PSSession> psSessions)
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||||
|
||||
|
|
|
@ -292,7 +292,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
return remoteRunspace;
|
||||
}
|
||||
|
||||
private void PrepareRunspace(Runspace runspace)
|
||||
private static void PrepareRunspace(Runspace runspace)
|
||||
{
|
||||
string promptFn = StringUtil.Format(RemotingErrorIdStrings.EnterPSHostProcessPrompt,
|
||||
@"function global:prompt { """,
|
||||
|
@ -574,7 +574,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
|
||||
#region Private Methods
|
||||
|
||||
private int[] GetProcIdsFromProcs(Process[] processes)
|
||||
private static int[] GetProcIdsFromProcs(Process[] processes)
|
||||
{
|
||||
List<int> returnIds = new List<int>();
|
||||
foreach (Process process in processes)
|
||||
|
@ -585,7 +585,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
return returnIds.ToArray();
|
||||
}
|
||||
|
||||
private int[] GetProcIdsFromNames(string[] names)
|
||||
private static int[] GetProcIdsFromNames(string[] names)
|
||||
{
|
||||
if ((names == null) || (names.Length == 0))
|
||||
{
|
||||
|
|
|
@ -1875,7 +1875,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
this.Host);
|
||||
}
|
||||
|
||||
private void StopProgressBar(
|
||||
private static void StopProgressBar(
|
||||
long sourceId)
|
||||
{
|
||||
s_RCProgress.StopProgress(sourceId);
|
||||
|
@ -1954,7 +1954,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
/// Process the stream object before writing it in the specified collection.
|
||||
/// </summary>
|
||||
/// <param name="streamObject">Stream object to process.</param>
|
||||
private void PreProcessStreamObject(PSStreamObject streamObject)
|
||||
private static void PreProcessStreamObject(PSStreamObject streamObject)
|
||||
{
|
||||
ErrorRecord errorRecord = streamObject.Value as ErrorRecord;
|
||||
|
||||
|
|
|
@ -1879,7 +1879,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
/// <summary>
|
||||
/// Check the powershell version of the remote server.
|
||||
/// </summary>
|
||||
private string GetRemoteServerPsVersion(RemoteRunspace remoteRunspace)
|
||||
private static string GetRemoteServerPsVersion(RemoteRunspace remoteRunspace)
|
||||
{
|
||||
if (remoteRunspace.ConnectionInfo is NewProcessConnectionInfo)
|
||||
{
|
||||
|
@ -2427,7 +2427,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
/// </summary>
|
||||
/// <param name="localScriptBlock"></param>
|
||||
/// <returns>A list of UsingExpressionAsts ordered by the StartOffset.</returns>
|
||||
private List<VariableExpressionAst> GetUsingVariables(ScriptBlock localScriptBlock)
|
||||
private static List<VariableExpressionAst> GetUsingVariables(ScriptBlock localScriptBlock)
|
||||
{
|
||||
if (localScriptBlock == null)
|
||||
{
|
||||
|
|
|
@ -1084,7 +1084,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
/// <summary>
|
||||
/// Create temporary remote runspace.
|
||||
/// </summary>
|
||||
private RemoteRunspace CreateTemporaryRemoteRunspaceForPowerShellDirect(PSHost host, RunspaceConnectionInfo connectionInfo)
|
||||
private static RemoteRunspace CreateTemporaryRemoteRunspaceForPowerShellDirect(PSHost host, RunspaceConnectionInfo connectionInfo)
|
||||
{
|
||||
// Create and open the runspace.
|
||||
TypeTable typeTable = TypeTable.LoadDefaultTypeFiles();
|
||||
|
|
|
@ -1115,7 +1115,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
/// <param name="session">Session to connect.</param>
|
||||
/// <param name="ex">Optional exception object.</param>
|
||||
/// <returns>Connected session or null.</returns>
|
||||
private PSSession ConnectSession(PSSession session, out Exception ex)
|
||||
private static PSSession ConnectSession(PSSession session, out Exception ex)
|
||||
{
|
||||
ex = null;
|
||||
|
||||
|
|
|
@ -540,7 +540,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
/// <param name="matches"></param>
|
||||
/// <param name="jobsToSearch"></param>
|
||||
/// <returns></returns>
|
||||
private bool FindJobsMatchingByFilterHelper(List<Job> matches, List<Job> jobsToSearch)
|
||||
private static bool FindJobsMatchingByFilterHelper(List<Job> matches, List<Job> jobsToSearch)
|
||||
{
|
||||
// check that filter only has job properties
|
||||
// if so, filter on one at a time using helpers.
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace System.Management.Automation.Remoting
|
|||
/// Check lengths non negative.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
private bool CheckLengthsNonNegative(int[] lengths)
|
||||
private static bool CheckLengthsNonNegative(int[] lengths)
|
||||
{
|
||||
for (int i = 0; i < lengths.Length; ++i)
|
||||
{
|
||||
|
|
|
@ -466,7 +466,7 @@ namespace System.Management.Automation.Remoting
|
|||
/// <param name="coreName">Named pipe core name.</param>
|
||||
/// <param name="securityDesc"></param>
|
||||
/// <returns>NamedPipeServerStream.</returns>
|
||||
private NamedPipeServerStream CreateNamedPipe(
|
||||
private static NamedPipeServerStream CreateNamedPipe(
|
||||
string serverName,
|
||||
string namespaceName,
|
||||
string coreName,
|
||||
|
|
|
@ -1096,7 +1096,7 @@ namespace System.Management.Automation.Runspaces
|
|||
|
||||
#region Private Methods
|
||||
|
||||
private string ResolveShellUri(string shell)
|
||||
private static string ResolveShellUri(string shell)
|
||||
{
|
||||
string resolvedShellUri = shell;
|
||||
if (string.IsNullOrEmpty(resolvedShellUri))
|
||||
|
@ -3493,7 +3493,7 @@ namespace System.Management.Automation.Runspaces
|
|||
/// <summary>
|
||||
/// Run some tasks on MTA thread if needed.
|
||||
/// </summary>
|
||||
private void RunOnMTAThread(ThreadStart threadProc)
|
||||
private static void RunOnMTAThread(ThreadStart threadProc)
|
||||
{
|
||||
if (Thread.CurrentThread.GetApartmentState() == ApartmentState.MTA)
|
||||
{
|
||||
|
@ -3512,7 +3512,7 @@ namespace System.Management.Automation.Runspaces
|
|||
/// <summary>
|
||||
/// Get error message from the thrown exception.
|
||||
/// </summary>
|
||||
private string GetErrorMessageFromException(Exception e)
|
||||
private static string GetErrorMessageFromException(Exception e)
|
||||
{
|
||||
string errorMessage = e.Message;
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ namespace System.Management.Automation.Remoting
|
|||
/// <summary>
|
||||
/// Get remote runspace to close.
|
||||
/// </summary>
|
||||
private RemoteRunspace GetRemoteRunspaceToClose(PSHost clientHost)
|
||||
private static RemoteRunspace GetRemoteRunspaceToClose(PSHost clientHost)
|
||||
{
|
||||
// Figure out if we need to close the remote runspace. Return null if we don't.
|
||||
|
||||
|
@ -440,7 +440,7 @@ namespace System.Management.Automation.Remoting
|
|||
/// </summary>
|
||||
/// <param name="caption">Caption to modify.</param>
|
||||
/// <returns>New modified caption.</returns>
|
||||
private string ModifyCaption(string caption)
|
||||
private static string ModifyCaption(string caption)
|
||||
{
|
||||
string pscaption = CredUI.PromptForCredential_DefaultCaption;
|
||||
|
||||
|
@ -465,7 +465,7 @@ namespace System.Management.Automation.Remoting
|
|||
/// <param name="computerName">computername to include in the
|
||||
/// message</param>
|
||||
/// <returns>Message which contains a warning as well.</returns>
|
||||
private string ModifyMessage(string message, string computerName)
|
||||
private static string ModifyMessage(string message, string computerName)
|
||||
{
|
||||
string modifiedMessage = PSRemotingErrorInvariants.FormatResourceString(
|
||||
RemotingErrorIdStrings.RemoteHostPromptForCredentialModifiedMessage,
|
||||
|
@ -485,7 +485,7 @@ namespace System.Management.Automation.Remoting
|
|||
/// <param name="resourceString">Resource string to use.</param>
|
||||
/// <returns>A constructed remote host call message
|
||||
/// which will display the warning.</returns>
|
||||
private RemoteHostCall ConstructWarningMessageForSecureString(string computerName,
|
||||
private static RemoteHostCall ConstructWarningMessageForSecureString(string computerName,
|
||||
string resourceString)
|
||||
{
|
||||
string warning = PSRemotingErrorInvariants.FormatResourceString(
|
||||
|
@ -506,7 +506,7 @@ namespace System.Management.Automation.Remoting
|
|||
/// in warning</param>
|
||||
/// <returns>A constructed remote host call message
|
||||
/// which will display the warning.</returns>
|
||||
private RemoteHostCall ConstructWarningMessageForGetBufferContents(string computerName)
|
||||
private static RemoteHostCall ConstructWarningMessageForGetBufferContents(string computerName)
|
||||
{
|
||||
string warning = PSRemotingErrorInvariants.FormatResourceString(
|
||||
RemotingErrorIdStrings.RemoteHostGetBufferContents,
|
||||
|
|
|
@ -213,7 +213,7 @@ namespace System.Management.Automation.Remoting
|
|||
return;
|
||||
}
|
||||
|
||||
private void SerializeUInt(uint data, Stream streamToWriteTo)
|
||||
private static void SerializeUInt(uint data, Stream streamToWriteTo)
|
||||
{
|
||||
Dbg.Assert(streamToWriteTo != null, "stream to write to cannot be null");
|
||||
|
||||
|
@ -241,7 +241,7 @@ namespace System.Management.Automation.Remoting
|
|||
return result;
|
||||
}
|
||||
|
||||
private void SerializeGuid(Guid guid, Stream streamToWriteTo)
|
||||
private static void SerializeGuid(Guid guid, Stream streamToWriteTo)
|
||||
{
|
||||
Dbg.Assert(streamToWriteTo != null, "stream to write to cannot be null");
|
||||
|
||||
|
|
|
@ -757,7 +757,7 @@ namespace System.Management.Automation.Remoting.Client
|
|||
/// </summary>
|
||||
/// <param name="remoteObject">Remote data object.</param>
|
||||
/// <returns>True if remote data object requires a user response.</returns>
|
||||
private bool CheckForInteractiveHostCall(RemoteDataObject<PSObject> remoteObject)
|
||||
private static bool CheckForInteractiveHostCall(RemoteDataObject<PSObject> remoteObject)
|
||||
{
|
||||
bool interactiveHostCall = false;
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ namespace System.Management.Automation.Remoting
|
|||
/// <exception cref="ArgumentException">
|
||||
/// 1. "optionName" is already defined
|
||||
/// </exception>
|
||||
private void AssertValueNotAssigned(string optionName, object originalValue)
|
||||
private static void AssertValueNotAssigned(string optionName, object originalValue)
|
||||
{
|
||||
if (originalValue != null)
|
||||
{
|
||||
|
@ -1896,7 +1896,7 @@ namespace System.Management.Automation.Remoting
|
|||
}
|
||||
}
|
||||
|
||||
private string GetRoleCapabilityPath(string roleCapability)
|
||||
private static string GetRoleCapabilityPath(string roleCapability)
|
||||
{
|
||||
string moduleName = "*";
|
||||
if (roleCapability.Contains('\\'))
|
||||
|
@ -2620,7 +2620,7 @@ namespace System.Management.Automation.Remoting
|
|||
/// <summary>
|
||||
/// Creates an alias entry.
|
||||
/// </summary>
|
||||
private SessionStateAliasEntry CreateSessionStateAliasEntry(Hashtable alias, bool isAliasVisibilityDefined)
|
||||
private static SessionStateAliasEntry CreateSessionStateAliasEntry(Hashtable alias, bool isAliasVisibilityDefined)
|
||||
{
|
||||
string name = TryGetValue(alias, ConfigFileConstants.AliasNameToken);
|
||||
|
||||
|
@ -2660,7 +2660,7 @@ namespace System.Management.Automation.Remoting
|
|||
/// Creates a function entry.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private SessionStateFunctionEntry CreateSessionStateFunctionEntry(Hashtable function, bool isFunctionVisibilityDefined)
|
||||
private static SessionStateFunctionEntry CreateSessionStateFunctionEntry(Hashtable function, bool isFunctionVisibilityDefined)
|
||||
{
|
||||
string name = TryGetValue(function, ConfigFileConstants.FunctionNameToken);
|
||||
|
||||
|
@ -2700,7 +2700,7 @@ namespace System.Management.Automation.Remoting
|
|||
/// <summary>
|
||||
/// Creates a variable entry.
|
||||
/// </summary>
|
||||
private SessionStateVariableEntry CreateSessionStateVariableEntry(Hashtable variable, PSLanguageMode languageMode)
|
||||
private static SessionStateVariableEntry CreateSessionStateVariableEntry(Hashtable variable, PSLanguageMode languageMode)
|
||||
{
|
||||
string name = TryGetValue(variable, ConfigFileConstants.VariableNameToken);
|
||||
|
||||
|
|
|
@ -640,7 +640,7 @@ namespace System.Management.Automation.Remoting
|
|||
/// <param name="shellContext"></param>
|
||||
/// <param name="inputFunctionName"></param>
|
||||
/// <returns></returns>
|
||||
private bool validateIncomingContexts(
|
||||
private static bool validateIncomingContexts(
|
||||
WSManNativeApi.WSManPluginRequest requestDetails,
|
||||
IntPtr shellContext,
|
||||
string inputFunctionName)
|
||||
|
@ -1111,7 +1111,7 @@ namespace System.Management.Automation.Remoting
|
|||
/// </summary>
|
||||
/// <param name="senderDetails"></param>
|
||||
/// <returns></returns>
|
||||
private PSSenderInfo GetPSSenderInfo(
|
||||
private static PSSenderInfo GetPSSenderInfo(
|
||||
WSManNativeApi.WSManSenderDetails senderDetails)
|
||||
{
|
||||
// senderDetails will not be null.
|
||||
|
@ -1168,7 +1168,7 @@ namespace System.Management.Automation.Remoting
|
|||
/// environment variable, which is set in the WSMan layer for Virtual or RunAs accounts.
|
||||
/// </summary>
|
||||
/// <returns>ClientToken IntPtr.</returns>
|
||||
private IntPtr GetRunAsClientToken()
|
||||
private static IntPtr GetRunAsClientToken()
|
||||
{
|
||||
string clientTokenStr = System.Environment.GetEnvironmentVariable(WSManRunAsClientTokenName);
|
||||
if (clientTokenStr != null)
|
||||
|
|
|
@ -1002,7 +1002,7 @@ namespace System.Management.Automation.Remoting
|
|||
/// It can also be used for graceful shutdown of the server process, which is not currently
|
||||
/// implemented.
|
||||
/// </summary>
|
||||
private void CleanAll()
|
||||
private static void CleanAll()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue