diff --git a/.globalconfig b/.globalconfig
index d7fb942772c..67733422919 100644
--- a/.globalconfig
+++ b/.globalconfig
@@ -408,7 +408,7 @@ dotnet_diagnostic.CA1821.severity = warning
# CA1822: Mark members as static
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822
dotnet_diagnostic.CA1822.severity = warning
-dotnet_code_quality.CA1822.api_surface = private
+dotnet_code_quality.CA1822.api_surface = private, internal
# CA1823: Avoid unused private fields
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1823
diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimSessionOperations.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimSessionOperations.cs
index c22db2087e4..41e137387f3 100644
--- a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimSessionOperations.cs
+++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimSessionOperations.cs
@@ -389,7 +389,7 @@ internal PSObject AddObjectToCache(
///
///
///
- internal string GetRemoveSessionObjectTarget(PSObject psObject)
+ internal static string GetRemoveSessionObjectTarget(PSObject psObject)
{
string message = string.Empty;
if (psObject.BaseObject is CimSession)
@@ -1192,7 +1192,7 @@ public void RemoveCimSession(RemoveCimSessionCommand cmdlet)
{
foreach (PSObject psobject in sessionToRemove)
{
- if (cmdlet.ShouldProcess(this.sessionState.GetRemoveSessionObjectTarget(psobject), RemoveCimSessionActionName))
+ if (cmdlet.ShouldProcess(CimSessionState.GetRemoveSessionObjectTarget(psobject), RemoveCimSessionActionName))
{
this.sessionState.RemoveOneSessionObjectFromCache(psobject);
}
diff --git a/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs b/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs
index f04c8ceff0f..15561e57ed8 100644
--- a/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs
@@ -377,7 +377,7 @@ private void ProcessListSetPerMachine(string machine)
categoryType = PerformanceCounterCategoryType.SingleInstance;
}
- string setHelp = _pdhHelper.GetCounterSetHelp(machine, counterSet);
+ string setHelp = PdhHelper.GetCounterSetHelp(machine, counterSet);
CounterSet setObj = new(counterSet, machine, categoryType, setHelp, ref counterInstanceMapping);
WriteObject(setObj);
@@ -422,7 +422,7 @@ private void ProcessGetCounter()
string localizedPath = path;
if (_defaultCounters)
{
- res = _pdhHelper.TranslateLocalCounterPath(path, out localizedPath);
+ res = PdhHelper.TranslateLocalCounterPath(path, out localizedPath);
if (res != PdhResults.PDH_CSTATUS_VALID_DATA)
{
string msg = string.Format(CultureInfo.CurrentCulture, _resourceMgr.GetString("CounterPathTranslationFailed"), res);
diff --git a/src/Microsoft.PowerShell.Commands.Diagnostics/PdhHelper.cs b/src/Microsoft.PowerShell.Commands.Diagnostics/PdhHelper.cs
index 97eff22db0d..a35119b5daf 100644
--- a/src/Microsoft.PowerShell.Commands.Diagnostics/PdhHelper.cs
+++ b/src/Microsoft.PowerShell.Commands.Diagnostics/PdhHelper.cs
@@ -927,7 +927,7 @@ private static uint ParsePath(string fullPath, ref PDH_COUNTER_PATH_ELEMENTS pCo
// requires a different firewall exception.
// This function checks and Asserts if the path is not valid.
//
- public uint TranslateLocalCounterPath(string englishPath, out string localizedPath)
+ public static uint TranslateLocalCounterPath(string englishPath, out string localizedPath)
{
uint res = PdhResults.PDH_CSTATUS_VALID_DATA;
localizedPath = string.Empty;
@@ -1016,7 +1016,7 @@ public uint TranslateLocalCounterPath(string englishPath, out string localizedPa
return res;
}
- public uint LookupPerfNameByIndex(string machineName, uint index, out string locName)
+ public static uint LookupPerfNameByIndex(string machineName, uint index, out string locName)
{
//
// NOTE: to make PdhLookupPerfNameByIndex() work,
@@ -1133,7 +1133,7 @@ public uint AddCounters(ref StringCollection validPaths, bool bFlushOldCounters)
return bAtLeastOneAdded ? PdhResults.PDH_CSTATUS_VALID_DATA : res;
}
- public string GetCounterSetHelp(string szMachineName, string szObjectName)
+ public static string GetCounterSetHelp(string szMachineName, string szObjectName)
{
// API not available to retrieve
return string.Empty;
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs
index a089f204654..9d3a434edb9 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs
@@ -304,7 +304,7 @@ public ServiceController[] InputObject
private ServiceController[] _allServices;
- internal ServiceController GetOneService(string nameOfService)
+ internal static ServiceController GetOneService(string nameOfService)
{
Dbg.Assert(!WildcardPattern.ContainsWildcardCharacters(nameOfService), "Caller should verify that nameOfService doesn't contain wildcard characters");
@@ -1085,7 +1085,7 @@ private static bool HaveAllDependentServicesStopped(ServiceController[] dependen
/// This removes all services that are not stopped from a list of services.
///
/// A list of services.
- internal void RemoveNotStoppedServices(List services)
+ internal static void RemoveNotStoppedServices(List services)
{
// You shall not modify a collection during enumeration.
services.RemoveAll(service =>
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs
index d772258227b..7058dadee5d 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs
@@ -543,7 +543,7 @@ public string[] FormatTypeName
#region Localized errors and messages
- internal ErrorDetails GetErrorDetails(string errorId, params object[] args)
+ internal static ErrorDetails GetErrorDetails(string errorId, params object[] args)
{
if (string.IsNullOrEmpty(errorId))
{
@@ -557,11 +557,11 @@ internal ErrorDetails GetErrorDetails(string errorId, params object[] args)
args);
}
- private ErrorRecord GetErrorNoCommandsImportedBecauseOfSkipping()
+ private static ErrorRecord GetErrorNoCommandsImportedBecauseOfSkipping()
{
const string errorId = "ErrorNoCommandsImportedBecauseOfSkipping";
- ErrorDetails details = this.GetErrorDetails(errorId);
+ ErrorDetails details = GetErrorDetails(errorId);
ErrorRecord errorRecord = new(
new ArgumentException(details.Message),
@@ -573,7 +573,7 @@ private ErrorRecord GetErrorNoCommandsImportedBecauseOfSkipping()
return errorRecord;
}
- private ErrorRecord GetErrorMalformedDataFromRemoteCommand(string commandName)
+ private static ErrorRecord GetErrorMalformedDataFromRemoteCommand(string commandName)
{
if (string.IsNullOrEmpty(commandName))
{
@@ -582,7 +582,7 @@ private ErrorRecord GetErrorMalformedDataFromRemoteCommand(string commandName)
const string errorId = "ErrorMalformedDataFromRemoteCommand";
- ErrorDetails details = this.GetErrorDetails(errorId, commandName);
+ ErrorDetails details = GetErrorDetails(errorId, commandName);
ErrorRecord errorRecord = new(
new ArgumentException(details.Message),
@@ -594,7 +594,7 @@ private ErrorRecord GetErrorMalformedDataFromRemoteCommand(string commandName)
return errorRecord;
}
- private ErrorRecord GetErrorCommandSkippedBecauseOfShadowing(string commandNames)
+ private static ErrorRecord GetErrorCommandSkippedBecauseOfShadowing(string commandNames)
{
if (string.IsNullOrEmpty(commandNames))
{
@@ -603,7 +603,7 @@ private ErrorRecord GetErrorCommandSkippedBecauseOfShadowing(string commandNames
const string errorId = "ErrorCommandSkippedBecauseOfShadowing";
- ErrorDetails details = this.GetErrorDetails(errorId, commandNames);
+ ErrorDetails details = GetErrorDetails(errorId, commandNames);
ErrorRecord errorRecord = new(
new InvalidOperationException(details.Message),
@@ -615,7 +615,7 @@ private ErrorRecord GetErrorCommandSkippedBecauseOfShadowing(string commandNames
return errorRecord;
}
- private ErrorRecord GetErrorSkippedNonRequestedCommand(string commandName)
+ private static ErrorRecord GetErrorSkippedNonRequestedCommand(string commandName)
{
if (string.IsNullOrEmpty(commandName))
{
@@ -624,7 +624,7 @@ private ErrorRecord GetErrorSkippedNonRequestedCommand(string commandName)
const string errorId = "ErrorSkippedNonRequestedCommand";
- ErrorDetails details = this.GetErrorDetails(errorId, commandName);
+ ErrorDetails details = GetErrorDetails(errorId, commandName);
ErrorRecord errorRecord = new(
new InvalidOperationException(details.Message),
@@ -636,7 +636,7 @@ private ErrorRecord GetErrorSkippedNonRequestedCommand(string commandName)
return errorRecord;
}
- private ErrorRecord GetErrorSkippedNonRequestedTypeDefinition(string typeName)
+ private static ErrorRecord GetErrorSkippedNonRequestedTypeDefinition(string typeName)
{
if (string.IsNullOrEmpty(typeName))
{
@@ -645,7 +645,7 @@ private ErrorRecord GetErrorSkippedNonRequestedTypeDefinition(string typeName)
const string errorId = "ErrorSkippedNonRequestedTypeDefinition";
- ErrorDetails details = this.GetErrorDetails(errorId, typeName);
+ ErrorDetails details = GetErrorDetails(errorId, typeName);
ErrorRecord errorRecord = new(
new InvalidOperationException(details.Message),
@@ -657,7 +657,7 @@ private ErrorRecord GetErrorSkippedNonRequestedTypeDefinition(string typeName)
return errorRecord;
}
- private ErrorRecord GetErrorSkippedUnsafeCommandName(string commandName)
+ private static ErrorRecord GetErrorSkippedUnsafeCommandName(string commandName)
{
if (string.IsNullOrEmpty(commandName))
{
@@ -666,7 +666,7 @@ private ErrorRecord GetErrorSkippedUnsafeCommandName(string commandName)
const string errorId = "ErrorSkippedUnsafeCommandName";
- ErrorDetails details = this.GetErrorDetails(errorId, commandName);
+ ErrorDetails details = GetErrorDetails(errorId, commandName);
ErrorRecord errorRecord = new(
new InvalidOperationException(details.Message),
@@ -678,7 +678,7 @@ private ErrorRecord GetErrorSkippedUnsafeCommandName(string commandName)
return errorRecord;
}
- private ErrorRecord GetErrorSkippedUnsafeNameInMetadata(string commandName, string nameType, string name)
+ private static ErrorRecord GetErrorSkippedUnsafeNameInMetadata(string commandName, string nameType, string name)
{
if (string.IsNullOrEmpty(commandName))
{
@@ -698,7 +698,7 @@ private ErrorRecord GetErrorSkippedUnsafeNameInMetadata(string commandName, stri
string errorId = "ErrorSkippedUnsafe" + nameType + "Name";
- ErrorDetails details = this.GetErrorDetails(errorId, commandName, name);
+ ErrorDetails details = GetErrorDetails(errorId, commandName, name);
ErrorRecord errorRecord = new(
new InvalidOperationException(details.Message),
@@ -735,7 +735,7 @@ private ErrorRecord GetErrorFromRemoteCommand(string commandName, RuntimeExcepti
if (Deserializer.IsInstanceOfType(remoteException.SerializedRemoteException, typeof(CommandNotFoundException)))
{
errorId = "ErrorRequiredRemoteCommandNotFound";
- errorDetails = this.GetErrorDetails(errorId, this.MyInvocation.MyCommand.Name);
+ errorDetails = GetErrorDetails(errorId, this.MyInvocation.MyCommand.Name);
errorRecord = new ErrorRecord(
new RuntimeException(errorDetails.Message, runtimeException),
@@ -752,7 +752,7 @@ private ErrorRecord GetErrorFromRemoteCommand(string commandName, RuntimeExcepti
// output a generic error message if exception is not recognized
//
errorId = "ErrorFromRemoteCommand";
- errorDetails = this.GetErrorDetails(errorId, commandName, runtimeException.Message);
+ errorDetails = GetErrorDetails(errorId, commandName, runtimeException.Message);
errorRecord = new ErrorRecord(
new RuntimeException(errorDetails.Message, runtimeException),
@@ -764,7 +764,7 @@ private ErrorRecord GetErrorFromRemoteCommand(string commandName, RuntimeExcepti
return errorRecord;
}
- private ErrorRecord GetErrorCouldntResolvedAlias(string aliasName)
+ private static ErrorRecord GetErrorCouldntResolvedAlias(string aliasName)
{
if (string.IsNullOrEmpty(aliasName))
{
@@ -773,7 +773,7 @@ private ErrorRecord GetErrorCouldntResolvedAlias(string aliasName)
const string errorId = "ErrorCouldntResolveAlias";
- ErrorDetails details = this.GetErrorDetails(errorId, aliasName);
+ ErrorDetails details = GetErrorDetails(errorId, aliasName);
ErrorRecord errorRecord = new(
new ArgumentException(details.Message),
@@ -785,7 +785,7 @@ private ErrorRecord GetErrorCouldntResolvedAlias(string aliasName)
return errorRecord;
}
- private ErrorRecord GetErrorNoResultsFromRemoteEnd(string commandName)
+ private static ErrorRecord GetErrorNoResultsFromRemoteEnd(string commandName)
{
if (string.IsNullOrEmpty(commandName))
{
@@ -794,7 +794,7 @@ private ErrorRecord GetErrorNoResultsFromRemoteEnd(string commandName)
const string errorId = "ErrorNoResultsFromRemoteEnd";
- ErrorDetails details = this.GetErrorDetails(errorId, commandName);
+ ErrorDetails details = GetErrorDetails(errorId, commandName);
ErrorRecord errorRecord = new(
new ArgumentException(details.Message),
@@ -813,7 +813,7 @@ private void ReportSkippedCommands()
if (_commandsSkippedBecauseOfShadowing.Count != 0)
{
string skippedCommands = string.Join(", ", _commandsSkippedBecauseOfShadowing.ToArray());
- ErrorRecord errorRecord = this.GetErrorCommandSkippedBecauseOfShadowing(skippedCommands);
+ ErrorRecord errorRecord = GetErrorCommandSkippedBecauseOfShadowing(skippedCommands);
this.WriteWarning(errorRecord.ErrorDetails.Message);
}
}
@@ -999,14 +999,14 @@ private T ConvertTo(string commandName, object value, bool nullOk)
}
else
{
- this.ThrowTerminatingError(this.GetErrorMalformedDataFromRemoteCommand(commandName));
+ this.ThrowTerminatingError(GetErrorMalformedDataFromRemoteCommand(commandName));
}
}
T t;
if (!LanguagePrimitives.TryConvertTo(value, out t))
{
- this.ThrowTerminatingError(this.GetErrorMalformedDataFromRemoteCommand(commandName));
+ this.ThrowTerminatingError(GetErrorMalformedDataFromRemoteCommand(commandName));
}
return t;
@@ -1022,7 +1022,7 @@ private T GetPropertyValue(string commandName, PSObject pso, string propertyN
PSPropertyInfo property = pso.Properties[propertyName];
if (property == null)
{
- this.ThrowTerminatingError(this.GetErrorMalformedDataFromRemoteCommand(commandName));
+ this.ThrowTerminatingError(GetErrorMalformedDataFromRemoteCommand(commandName));
}
return ConvertTo(commandName, property.Value, nullOk);
@@ -1188,20 +1188,20 @@ private bool IsSafeCommandMetadata(CommandMetadata commandMetadata)
{
if (!IsCommandNameMatchingParameters(commandMetadata.Name))
{
- this.WriteError(this.GetErrorSkippedNonRequestedCommand(commandMetadata.Name));
+ this.WriteError(GetErrorSkippedNonRequestedCommand(commandMetadata.Name));
return false;
}
if (!IsSafeNameOrIdentifier(commandMetadata.Name))
{
- this.WriteError(this.GetErrorSkippedUnsafeCommandName(commandMetadata.Name));
+ this.WriteError(GetErrorSkippedUnsafeCommandName(commandMetadata.Name));
return false;
}
if ((commandMetadata.DefaultParameterSetName != null) &&
!IsSafeNameOrIdentifier(commandMetadata.DefaultParameterSetName))
{
- this.WriteError(this.GetErrorSkippedUnsafeNameInMetadata(
+ this.WriteError(GetErrorSkippedUnsafeNameInMetadata(
commandMetadata.Name,
"ParameterSet",
commandMetadata.DefaultParameterSetName));
@@ -1226,7 +1226,7 @@ private bool IsSafeCommandMetadata(CommandMetadata commandMetadata)
if (!IsSafeParameterName(parameter.Name))
{
- this.WriteError(this.GetErrorSkippedUnsafeNameInMetadata(
+ this.WriteError(GetErrorSkippedUnsafeNameInMetadata(
commandMetadata.Name,
"Parameter",
parameter.Name));
@@ -1239,7 +1239,7 @@ private bool IsSafeCommandMetadata(CommandMetadata commandMetadata)
{
if (!IsSafeNameOrIdentifier(alias))
{
- this.WriteError(this.GetErrorSkippedUnsafeNameInMetadata(
+ this.WriteError(GetErrorSkippedUnsafeNameInMetadata(
commandMetadata.Name,
"Alias",
alias));
@@ -1254,7 +1254,7 @@ private bool IsSafeCommandMetadata(CommandMetadata commandMetadata)
{
if (!IsSafeNameOrIdentifier(setPair.Key))
{
- this.WriteError(this.GetErrorSkippedUnsafeNameInMetadata(
+ this.WriteError(GetErrorSkippedUnsafeNameInMetadata(
commandMetadata.Name,
"ParameterSet",
setPair.Key));
@@ -1341,7 +1341,7 @@ private CommandMetadata RehydrateCommandMetadata(PSObject deserializedCommandInf
resolvedCommandName = GetPropertyValue("Get-Command", deserializedCommandInfo, "ResolvedCommandName", true);
if (string.IsNullOrEmpty(resolvedCommandName))
{
- this.WriteError(this.GetErrorCouldntResolvedAlias(name));
+ this.WriteError(GetErrorCouldntResolvedAlias(name));
}
}
else
@@ -1421,7 +1421,7 @@ private void AddRemoteCommandMetadata(
if (resolvedCommandName != null && !IsSafeNameOrIdentifier(commandMetadata.Name))
{
- this.WriteError(this.GetErrorSkippedUnsafeCommandName(resolvedCommandName));
+ this.WriteError(GetErrorSkippedUnsafeCommandName(resolvedCommandName));
return;
}
@@ -1468,7 +1468,7 @@ private bool IsSafeTypeDefinition(ExtendedTypeDefinition typeDefinition)
{
if (!IsTypeNameMatchingParameters(typeDefinition.TypeName))
{
- this.WriteError(this.GetErrorSkippedNonRequestedTypeDefinition(typeDefinition.TypeName));
+ this.WriteError(GetErrorSkippedNonRequestedTypeDefinition(typeDefinition.TypeName));
return false;
}
@@ -1644,7 +1644,7 @@ internal List GetRemoteFormatData()
if ((numberOfReceivedObjects == 0) && (_formatTypeNamesSpecified))
{
- this.ThrowTerminatingError(this.GetErrorNoResultsFromRemoteEnd("Get-FormatData"));
+ this.ThrowTerminatingError(GetErrorNoResultsFromRemoteEnd("Get-FormatData"));
}
return result;
@@ -1770,7 +1770,7 @@ internal List GetRemoteCommandMetadata(out Dictionary(name2commandMetadata.Values);
@@ -1889,7 +1889,7 @@ internal List GenerateProxyModule(
if (listOfCommandMetadata.Count == 0)
{
- ErrorRecord error = this.GetErrorNoCommandsImportedBecauseOfSkipping();
+ ErrorRecord error = GetErrorNoCommandsImportedBecauseOfSkipping();
this.ThrowTerminatingError(error);
}
}
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Join-String.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Join-String.cs
index 0aebabe94c7..5f751e307eb 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Join-String.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Join-String.cs
@@ -201,7 +201,7 @@ void AddMatching(string completionText)
return res;
}
- private IEnumerable CompleteSeparator(string wordToComplete)
+ private static IEnumerable CompleteSeparator(string wordToComplete)
{
var res = new List(10);
@@ -223,7 +223,7 @@ void AddMatching(string completionText, string listText, string toolTip)
return res;
}
- public string NewLineText
+ public static string NewLineText
{
get
{
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
index 604582661a0..62e28e54193 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
@@ -1656,7 +1656,7 @@ protected override void StopProcessing()
/// Because this function sets the request's ContentLength property and writes content data into the requests's stream,
/// it should be called one time maximum on a given request.
///
- internal long SetRequestContent(HttpRequestMessage request, byte[] content)
+ internal static long SetRequestContent(HttpRequestMessage request, byte[] content)
{
if (request == null)
throw new ArgumentNullException(nameof(request));
@@ -1728,7 +1728,7 @@ internal long SetRequestContent(HttpRequestMessage request, string content)
return byteArrayContent.Headers.ContentLength.Value;
}
- internal long SetRequestContent(HttpRequestMessage request, XmlNode xmlNode)
+ internal static long SetRequestContent(HttpRequestMessage request, XmlNode xmlNode)
{
if (request == null)
throw new ArgumentNullException(nameof(request));
@@ -1765,7 +1765,7 @@ internal long SetRequestContent(HttpRequestMessage request, XmlNode xmlNode)
/// Because this function sets the request's ContentLength property and writes content data into the requests's stream,
/// it should be called one time maximum on a given request.
///
- internal long SetRequestContent(HttpRequestMessage request, Stream contentStream)
+ internal static long SetRequestContent(HttpRequestMessage request, Stream contentStream)
{
if (request == null)
throw new ArgumentNullException(nameof(request));
@@ -1788,7 +1788,7 @@ internal long SetRequestContent(HttpRequestMessage request, Stream contentStream
/// Because this function sets the request's ContentLength property and writes content data into the requests's stream,
/// it should be called one time maximum on a given request.
///
- internal long SetRequestContent(HttpRequestMessage request, MultipartFormDataContent multipartContent)
+ internal static long SetRequestContent(HttpRequestMessage request, MultipartFormDataContent multipartContent)
{
if (request == null)
{
diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
index 167186ae0c6..8b552d6595e 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
+++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
@@ -2446,7 +2446,7 @@ internal void Run(bool inputLoopIsNested)
if (ui.SupportsVirtualTerminal)
{
// need to re-enable VT mode if it was previously enabled as native commands may have turned it off
- ui.TryTurnOnVtMode();
+ ConsoleHostUserInterface.TryTurnOnVtMode();
}
#endif
diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs
index 822daa12828..f026b6ed748 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs
+++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs
@@ -94,7 +94,7 @@ internal ConsoleHostUserInterface(ConsoleHost parent)
}
}
- internal bool TryTurnOnVtMode()
+ internal static bool TryTurnOnVtMode()
{
#if UNIX
return true;
diff --git a/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs b/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs
index 1292ecb9b55..76f4c9570b2 100644
--- a/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs
+++ b/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs
@@ -462,7 +462,7 @@ public IntPtr GetCertByName(string Name)
return certContext;
}
- public void FreeCert(IntPtr certContext)
+ public static void FreeCert(IntPtr certContext)
{
Security.NativeMethods.CertFreeCertificateContext(certContext);
}
@@ -1081,7 +1081,7 @@ protected override bool HasChildItems(string path)
IntPtr certContext = store.GetFirstCert();
if (certContext != IntPtr.Zero)
{
- store.FreeCert(certContext);
+ X509NativeStore.FreeCert(certContext);
result = true;
}
}
@@ -2112,7 +2112,7 @@ private object GetItemAtPath(string path, bool test, out bool isContainer)
item = new X509Certificate2(certContext);
}
- store.FreeCert(certContext);
+ X509NativeStore.FreeCert(certContext);
break;
@@ -2914,7 +2914,7 @@ string ICmdletProviderSupportsHelp.GetHelpMaml(string helpItemName, string path)
CultureInfo currentUICulture = CultureInfo.CurrentUICulture;
string fullHelpPath = Path.Combine(
- this.ProviderInfo.ApplicationBase,
+ ProviderInfo.ApplicationBase,
currentUICulture.ToString(),
this.ProviderInfo.HelpFile);
XmlReaderSettings settings = new();
@@ -3219,7 +3219,7 @@ public static void WriteSendAsTrustedIssuerProperty(X509Certificate2 cert, strin
if (certContext != IntPtr.Zero)
{
certFromStore = new X509Certificate2(certContext);
- store.FreeCert(certContext);
+ X509NativeStore.FreeCert(certContext);
}
}
diff --git a/src/Microsoft.WSMan.Management/ConfigProvider.cs b/src/Microsoft.WSMan.Management/ConfigProvider.cs
index de99812b01d..9c7edc3a5ac 100644
--- a/src/Microsoft.WSMan.Management/ConfigProvider.cs
+++ b/src/Microsoft.WSMan.Management/ConfigProvider.cs
@@ -195,7 +195,7 @@ protected override PSDriveInfo NewDrive(PSDriveInfo drive)
if (!string.IsNullOrEmpty(drive.Root))
{
- AssertError(helper.GetResourceMsgFromResourcetext("NewDriveRootDoesNotExist"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("NewDriveRootDoesNotExist"), false);
return null;
}
@@ -210,7 +210,7 @@ protected override Collection InitializeDefaultDrives()
{
Collection drives = new Collection();
drives.Add(new PSDriveInfo(WSManStringLiterals.rootpath, ProviderInfo, string.Empty,
- helper.GetResourceMsgFromResourcetext("ConfigStorage"), null));
+ WSManHelper.GetResourceMsgFromResourcetext("ConfigStorage"), null));
return drives;
}
@@ -875,14 +875,14 @@ protected override void SetItem(string path, object value)
{
if (value == null)
{
- throw new ArgumentException(helper.GetResourceMsgFromResourcetext("value"));
+ throw new ArgumentException(WSManHelper.GetResourceMsgFromResourcetext("value"));
}
string ChildName = string.Empty;
if (path.Length == 0 && string.IsNullOrEmpty(ChildName))
{
- AssertError(helper.GetResourceMsgFromResourcetext("SetItemNotSupported"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("SetItemNotSupported"), false);
return;
}
@@ -898,7 +898,7 @@ protected override void SetItem(string path, object value)
if (ChildName.Equals(path, StringComparison.OrdinalIgnoreCase))
{
- AssertError(helper.GetResourceMsgFromResourcetext("SetItemNotSupported"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("SetItemNotSupported"), false);
return;
}
@@ -920,12 +920,12 @@ protected override void SetItem(string path, object value)
// if he intends to disable RunAs on the Plugin.
if (string.Equals(ChildName, WSManStringLiterals.ConfigRunAsPasswordName, StringComparison.OrdinalIgnoreCase))
{
- AssertError(helper.GetResourceMsgFromResourcetext("ClearItemOnRunAsPassword"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("ClearItemOnRunAsPassword"), false);
return;
}
}
- string whatIfMessage = string.Format(CultureInfo.CurrentUICulture, helper.GetResourceMsgFromResourcetext("SetItemWhatIfAndConfirmText"), path, value);
+ string whatIfMessage = string.Format(CultureInfo.CurrentUICulture, WSManHelper.GetResourceMsgFromResourcetext("SetItemWhatIfAndConfirmText"), path, value);
if (!ShouldProcess(whatIfMessage, string.Empty, string.Empty))
{
return;
@@ -977,7 +977,7 @@ protected override void SetItem(string path, object value)
{
if (path.EndsWith(strPathChk + WSManStringLiterals.containerPlugin, StringComparison.OrdinalIgnoreCase))
{
- AssertError(helper.GetResourceMsgFromResourcetext("SetItemNotSupported"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("SetItemNotSupported"), false);
}
try
@@ -990,7 +990,7 @@ protected override void SetItem(string path, object value)
if (!this.clearItemIsCalled)
{
// Don't need an error if ClearItem is called.
- AssertError(helper.GetResourceMsgFromResourcetext("ItemDoesNotExist"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("ItemDoesNotExist"), false);
}
return;
@@ -1047,7 +1047,7 @@ protected override void SetItem(string path, object value)
WSManStringLiterals.ConfigRunAsUserName))))
{
// User Cannot set RunAsPassword if, RunAsUser is not present.
- AssertError(helper.GetResourceMsgFromResourcetext("SetItemOnRunAsPasswordNoRunAsUser"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("SetItemOnRunAsPasswordNoRunAsUser"), false);
}
value = GetStringFromSecureString(value);
@@ -1061,7 +1061,7 @@ protected override void SetItem(string path, object value)
{
if (path.EndsWith(strPathChk + WSManStringLiterals.containerResources, StringComparison.OrdinalIgnoreCase))
{
- AssertError(helper.GetResourceMsgFromResourcetext("SetItemNotSupported"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("SetItemNotSupported"), false);
return;
}
@@ -1088,7 +1088,7 @@ protected override void SetItem(string path, object value)
if (ChildName.Equals(WSManStringLiterals.ConfigResourceUriName, StringComparison.OrdinalIgnoreCase))
{
- AssertError(helper.GetResourceMsgFromResourcetext("NoChangeValue"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("NoChangeValue"), false);
return;
}
@@ -1112,7 +1112,7 @@ protected override void SetItem(string path, object value)
}
else
{
- AssertError(helper.GetResourceMsgFromResourcetext("NoChangeValue"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("NoChangeValue"), false);
}
}
}
@@ -1123,7 +1123,7 @@ protected override void SetItem(string path, object value)
{
if (path.EndsWith(strPathChk + WSManStringLiterals.containerSecurity, StringComparison.OrdinalIgnoreCase))
{
- AssertError(helper.GetResourceMsgFromResourcetext("NoChangeValue"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("NoChangeValue"), false);
return;
}
@@ -1144,9 +1144,9 @@ protected override void SetItem(string path, object value)
{
if (!Force)
{
- string query = helper.GetResourceMsgFromResourcetext("ShouldContinueSecurityQuery");
+ string query = WSManHelper.GetResourceMsgFromResourcetext("ShouldContinueSecurityQuery");
query = string.Format(CultureInfo.CurrentCulture, query, currentpluginname);
- if (!ShouldContinue(query, helper.GetResourceMsgFromResourcetext("ShouldContinueSecurityCaption")))
+ if (!ShouldContinue(query, WSManHelper.GetResourceMsgFromResourcetext("ShouldContinueSecurityCaption")))
{
return;
}
@@ -1221,7 +1221,7 @@ protected override void SetItem(string path, object value)
WSManStringLiterals.containerShell,
adjustedChileName);
- warningMessage.Add(string.Format(helper.GetResourceMsgFromResourcetext("SetItemWarnigForPPQ"), pathForGlobalQuota));
+ warningMessage.Add(string.Format(WSManHelper.GetResourceMsgFromResourcetext("SetItemWarnigForPPQ"), pathForGlobalQuota));
}
}
@@ -1241,11 +1241,11 @@ protected override void SetItem(string path, object value)
{
if (IsPathLocalMachine(host))
{
- warningMessage.Add(helper.GetResourceMsgFromResourcetext("SetItemServiceRestartWarning"));
+ warningMessage.Add(WSManHelper.GetResourceMsgFromResourcetext("SetItemServiceRestartWarning"));
}
else
{
- warningMessage.Add(string.Format(helper.GetResourceMsgFromResourcetext("SetItemServiceRestartWarningRemote"), host));
+ warningMessage.Add(string.Format(WSManHelper.GetResourceMsgFromResourcetext("SetItemServiceRestartWarningRemote"), host));
}
}
}
@@ -1259,17 +1259,17 @@ protected override void SetItem(string path, object value)
}
catch (PSArgumentException)
{
- AssertError(helper.GetResourceMsgFromResourcetext("ItemDoesNotExist"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("ItemDoesNotExist"), false);
return;
}
catch (PSArgumentNullException)
{
- AssertError(helper.GetResourceMsgFromResourcetext("ItemDoesNotExist"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("ItemDoesNotExist"), false);
return;
}
catch (NullReferenceException)
{
- AssertError(helper.GetResourceMsgFromResourcetext("ItemDoesNotExist"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("ItemDoesNotExist"), false);
return;
}
}
@@ -1285,14 +1285,14 @@ protected override void SetItem(string path, object value)
if (!Force)
{
string query = string.Empty;
- string caption = helper.GetResourceMsgFromResourcetext("SetItemGeneralSecurityCaption");
+ string caption = WSManHelper.GetResourceMsgFromResourcetext("SetItemGeneralSecurityCaption");
if (ChildName.Equals("TrustedHosts", StringComparison.OrdinalIgnoreCase))
{
- query = helper.GetResourceMsgFromResourcetext("SetItemTrustedHostsWarningQuery");
+ query = WSManHelper.GetResourceMsgFromResourcetext("SetItemTrustedHostsWarningQuery");
}
else if (ChildName.Equals("RootSDDL", StringComparison.OrdinalIgnoreCase))
{
- query = helper.GetResourceMsgFromResourcetext("SetItemRootSDDLWarningQuery");
+ query = WSManHelper.GetResourceMsgFromResourcetext("SetItemRootSDDLWarningQuery");
}
if (!ShouldContinue(query, caption))
@@ -1318,7 +1318,7 @@ protected override void SetItem(string path, object value)
}
else
{
- AssertError(helper.GetResourceMsgFromResourcetext("TrustedHostValueTypeError"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("TrustedHostValueTypeError"), false);
}
}
else
@@ -1327,7 +1327,7 @@ protected override void SetItem(string path, object value)
if (globalWarningUris.Contains(uri) && globalWarningConfigurations.Contains(ChildName.ToLowerInvariant()))
{
- warningMessage.Add(string.Format(helper.GetResourceMsgFromResourcetext("SetItemWarningForGlobalQuota"), value));
+ warningMessage.Add(string.Format(WSManHelper.GetResourceMsgFromResourcetext("SetItemWarningForGlobalQuota"), value));
}
}
@@ -1625,7 +1625,7 @@ protected override void RemoveItem(string path, bool recurse)
bool throwerror = true;
if (path.Length == 0)
{
- AssertError(helper.GetResourceMsgFromResourcetext("RemoveItemNotSupported"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("RemoveItemNotSupported"), false);
return;
}
@@ -1645,10 +1645,10 @@ protected override void RemoveItem(string path, bool recurse)
{
if (ChildName.Equals("localhost", StringComparison.OrdinalIgnoreCase))
{
- AssertError(helper.GetResourceMsgFromResourcetext("LocalHost"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("LocalHost"), false);
}
- helper.RemoveFromDictionary(ChildName);
+ WSManHelper.RemoveFromDictionary(ChildName);
return;
}
@@ -1758,7 +1758,7 @@ protected override void RemoveItem(string path, bool recurse)
if (throwerror)
{
- AssertError(helper.GetResourceMsgFromResourcetext("RemoveItemNotSupported"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("RemoveItemNotSupported"), false);
return;
}
@@ -1788,7 +1788,7 @@ protected override void RemoveItem(string path, bool recurse)
if (throwerror)
{
- AssertError(helper.GetResourceMsgFromResourcetext("RemoveItemNotSupported"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("RemoveItemNotSupported"), false);
return;
}
}
@@ -1823,7 +1823,7 @@ protected override void NewItem(string path, string itemTypeName, object newItem
if (string.IsNullOrEmpty(host))
{
- throw new ArgumentException(helper.GetResourceMsgFromResourcetext("InvalidPath"));
+ throw new ArgumentException(WSManHelper.GetResourceMsgFromResourcetext("InvalidPath"));
}
// Chk for Winrm Service
@@ -1875,7 +1875,7 @@ protected override void NewItem(string path, string itemTypeName, object newItem
listenerparams.Add("CertificateThumbPrint", niParams.CertificateThumbPrint);
}
- NewItemContainerListenerOrCertMapping(sessionobj, path, uri, host, listenerparams, WSManStringLiterals.containerListener, helper.GetResourceMsgFromResourcetext("NewItemShouldContinueListenerQuery"), helper.GetResourceMsgFromResourcetext("NewItemShouldContinueListenerCaption"));
+ NewItemContainerListenerOrCertMapping(sessionobj, path, uri, host, listenerparams, WSManStringLiterals.containerListener, WSManHelper.GetResourceMsgFromResourcetext("NewItemShouldContinueListenerQuery"), WSManHelper.GetResourceMsgFromResourcetext("NewItemShouldContinueListenerCaption"));
}
else if (path.EndsWith(strPathChk + WSManStringLiterals.containerClientCertificate, StringComparison.OrdinalIgnoreCase))
{
@@ -1893,11 +1893,11 @@ protected override void NewItem(string path, string itemTypeName, object newItem
}
Certparams.Add("Enabled", dynParams.Enabled);
- NewItemContainerListenerOrCertMapping(sessionobj, path, uri, host, Certparams, WSManStringLiterals.containerClientCertificate, helper.GetResourceMsgFromResourcetext("NewItemShouldContinueClientCertQuery"), helper.GetResourceMsgFromResourcetext("NewItemShouldContinueClientCertCaption"));
+ NewItemContainerListenerOrCertMapping(sessionobj, path, uri, host, Certparams, WSManStringLiterals.containerClientCertificate, WSManHelper.GetResourceMsgFromResourcetext("NewItemShouldContinueClientCertQuery"), WSManHelper.GetResourceMsgFromResourcetext("NewItemShouldContinueClientCertCaption"));
}
else
{
- AssertError(helper.GetResourceMsgFromResourcetext("NewItemNotSupported"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("NewItemNotSupported"), false);
return;
}
}
@@ -2115,7 +2115,7 @@ private void NewItemPluginOrPluginChild(object sessionobj, string path, string h
}
else
{
- ErrorRecord er = new ErrorRecord(new InvalidOperationException(helper.GetResourceMsgFromResourcetext("NewItemNotSupported")), "InvalidOperationException", ErrorCategory.InvalidOperation, null);
+ ErrorRecord er = new ErrorRecord(new InvalidOperationException(WSManHelper.GetResourceMsgFromResourcetext("NewItemNotSupported")), "InvalidOperationException", ErrorCategory.InvalidOperation, null);
WriteError(er);
return;
}
@@ -2195,9 +2195,9 @@ private void NewItemPluginOrPluginChild(object sessionobj, string path, string h
{
if (!Force)
{
- string query = helper.GetResourceMsgFromResourcetext("ShouldContinueSecurityQuery");
+ string query = WSManHelper.GetResourceMsgFromResourcetext("ShouldContinueSecurityQuery");
query = string.Format(CultureInfo.CurrentCulture, query, pName);
- if (!ShouldContinue(query, helper.GetResourceMsgFromResourcetext("ShouldContinueSecurityCaption")))
+ if (!ShouldContinue(query, WSManHelper.GetResourceMsgFromResourcetext("ShouldContinueSecurityCaption")))
{
return;
}
@@ -2206,7 +2206,7 @@ private void NewItemPluginOrPluginChild(object sessionobj, string path, string h
PSObject resourceDirProperties = GetItemValue(strPathChk);
if ((resourceDirProperties == null) || (resourceDirProperties.Properties["ResourceUri"] == null))
{
- string message = helper.FormatResourceMsgFromResourcetext("ResourceURIMissingInResourceDir",
+ string message = WSManHelper.FormatResourceMsgFromResourcetext("ResourceURIMissingInResourceDir",
"ResourceUri", strPathChk);
AssertError(message, false);
return; // AssertError is going to throw - return silences some static analysis tools
@@ -2356,7 +2356,7 @@ private void SetItemListenerOrClientCertificate(object sessionObj, string Resour
if (xmlResource == null)
{
- AssertError(helper.GetResourceMsgFromResourcetext("InvalidPath"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("InvalidPath"), false);
}
if (ResourceURI.EndsWith(WSManStringLiterals.containerListener, StringComparison.OrdinalIgnoreCase))
@@ -2370,13 +2370,13 @@ private void SetItemListenerOrClientCertificate(object sessionObj, string Resour
if (path.EndsWith(host + WSManStringLiterals.DefaultPathSeparator + parent, StringComparison.OrdinalIgnoreCase))
{
- AssertError(helper.GetResourceMsgFromResourcetext("SetItemNotSupported"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("SetItemNotSupported"), false);
}
else
{
if (!Force)
{
- if (!ShouldContinue(helper.GetResourceMsgFromResourcetext("SetItemShouldContinueQuery"), helper.GetResourceMsgFromResourcetext("SetItemShouldContinueCaption")))
+ if (!ShouldContinue(WSManHelper.GetResourceMsgFromResourcetext("SetItemShouldContinueQuery"), WSManHelper.GetResourceMsgFromResourcetext("SetItemShouldContinueCaption")))
{
return;
}
@@ -2690,7 +2690,7 @@ private void PutResourceValue(object sessionobj, string ResourceURI, Hashtable v
}
else
{
- AssertError(helper.GetResourceMsgFromResourcetext("ItemDoesNotExist"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("ItemDoesNotExist"), false);
return;
}
}
@@ -4610,10 +4610,10 @@ private void StartWSManService(bool force)
{
string startserviceScript = string.Format(CultureInfo.InvariantCulture, WSManStringLiterals.StartWinrmServiceSBFormat);
ScriptBlock startserviceSb = ScriptBlock.Create(startserviceScript);
- Collection result = startserviceSb.Invoke(force, helper.GetResourceMsgFromResourcetext("WSManServiceStartCaption"), helper.GetResourceMsgFromResourcetext("WSManServiceStartQuery"));
+ Collection result = startserviceSb.Invoke(force, WSManHelper.GetResourceMsgFromResourcetext("WSManServiceStartCaption"), WSManHelper.GetResourceMsgFromResourcetext("WSManServiceStartQuery"));
if (!(bool)result[0].ImmediateBaseObject)
{
- AssertError(helper.GetResourceMsgFromResourcetext("WinRMServiceError"), false);
+ AssertError(WSManHelper.GetResourceMsgFromResourcetext("WinRMServiceError"), false);
}
}
catch (CmdletInvocationException)
@@ -5153,7 +5153,7 @@ private object ValidateAndGetUserObject(string configurationName, object value)
else
{
string error = string.Format(
- helper.GetResourceMsgFromResourcetext("InvalidValueType"),
+ WSManHelper.GetResourceMsgFromResourcetext("InvalidValueType"),
WSManStringLiterals.ConfigRunAsPasswordName,
typeof(SecureString).FullName);
@@ -5174,7 +5174,7 @@ private object ValidateAndGetUserObject(string configurationName, object value)
else
{
string error = string.Format(
- helper.GetResourceMsgFromResourcetext("InvalidValueType"),
+ WSManHelper.GetResourceMsgFromResourcetext("InvalidValueType"),
WSManStringLiterals.ConfigRunAsUserName,
typeof(PSCredential).FullName);
diff --git a/src/Microsoft.WSMan.Management/CredSSP.cs b/src/Microsoft.WSMan.Management/CredSSP.cs
index cd5e6d3fc4d..59dcf88c2ea 100644
--- a/src/Microsoft.WSMan.Management/CredSSP.cs
+++ b/src/Microsoft.WSMan.Management/CredSSP.cs
@@ -128,7 +128,7 @@ private void DisableClientSideSettings()
if (xNode is null)
{
InvalidOperationException ex = new InvalidOperationException();
- ErrorRecord er = new ErrorRecord(ex, helper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null);
+ ErrorRecord er = new ErrorRecord(ex, WSManHelper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null);
WriteError(er);
return;
}
@@ -152,7 +152,7 @@ private void DisableClientSideSettings()
if (!helper.ValidateCreadSSPRegistryRetry(false, null, applicationname))
{
- helper.AssertError(helper.GetResourceMsgFromResourcetext("DisableCredSSPPolicyValidateError"), false, null);
+ helper.AssertError(WSManHelper.GetResourceMsgFromResourcetext("DisableCredSSPPolicyValidateError"), false, null);
}
}
catch (System.Xml.XPath.XPathException ex)
@@ -194,7 +194,7 @@ private void DisableServerSideSettings()
{
InvalidOperationException ex = new InvalidOperationException();
ErrorRecord er = new ErrorRecord(ex,
- helper.GetResourceMsgFromResourcetext("WinrmNotConfigured"),
+ WSManHelper.GetResourceMsgFromResourcetext("WinrmNotConfigured"),
ErrorCategory.InvalidOperation, null);
WriteError(er);
return;
@@ -442,7 +442,7 @@ protected override void BeginProcessing()
// DelegateComputer cannot be specified when Role is other than client
if ((delegatecomputer != null) && !Role.Equals(Client, StringComparison.OrdinalIgnoreCase))
{
- string message = helper.FormatResourceMsgFromResourcetext("CredSSPRoleAndDelegateCannotBeSpecified",
+ string message = WSManHelper.FormatResourceMsgFromResourcetext("CredSSPRoleAndDelegateCannotBeSpecified",
"DelegateComputer",
"Role",
Role,
@@ -454,7 +454,7 @@ protected override void BeginProcessing()
// DelegateComputer must be specified when Role is client
if (Role.Equals(Client, StringComparison.OrdinalIgnoreCase) && (delegatecomputer == null))
{
- string message = helper.FormatResourceMsgFromResourcetext("CredSSPClientAndDelegateMustBeSpecified",
+ string message = WSManHelper.FormatResourceMsgFromResourcetext("CredSSPClientAndDelegateMustBeSpecified",
"DelegateComputer",
"Role",
Client);
@@ -481,8 +481,8 @@ protected override void BeginProcessing()
///
private void EnableClientSideSettings()
{
- string query = helper.GetResourceMsgFromResourcetext("CredSSPContinueQuery");
- string caption = helper.GetResourceMsgFromResourcetext("CredSSPContinueCaption");
+ string query = WSManHelper.GetResourceMsgFromResourcetext("CredSSPContinueQuery");
+ string caption = WSManHelper.GetResourceMsgFromResourcetext("CredSSPContinueCaption");
if (!force && !ShouldContinue(query, caption))
{
return;
@@ -498,12 +498,12 @@ private void EnableClientSideSettings()
{
// get the credssp node to check if wsman is configured on this machine
string result = m_SessionObj.Get(helper.CredSSP_RUri, 0);
- XmlNode node = helper.GetXmlNode(result, helper.CredSSP_SNode, helper.CredSSP_XMLNmsp);
+ XmlNode node = WSManHelper.GetXmlNode(result, helper.CredSSP_SNode, helper.CredSSP_XMLNmsp);
if (node == null)
{
InvalidOperationException ex = new InvalidOperationException();
- ErrorRecord er = new ErrorRecord(ex, helper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null);
+ ErrorRecord er = new ErrorRecord(ex, WSManHelper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null);
WriteError(er);
return;
}
@@ -535,7 +535,7 @@ private void EnableClientSideSettings()
}
else
{
- helper.AssertError(helper.GetResourceMsgFromResourcetext("EnableCredSSPPolicyValidateError"), false, delegatecomputer);
+ helper.AssertError(WSManHelper.GetResourceMsgFromResourcetext("EnableCredSSPPolicyValidateError"), false, delegatecomputer);
}
}
catch (COMException)
@@ -559,8 +559,8 @@ private void EnableClientSideSettings()
private void EnableServerSideSettings()
{
- string query = helper.GetResourceMsgFromResourcetext("CredSSPServerContinueQuery");
- string caption = helper.GetResourceMsgFromResourcetext("CredSSPContinueCaption");
+ string query = WSManHelper.GetResourceMsgFromResourcetext("CredSSPServerContinueQuery");
+ string caption = WSManHelper.GetResourceMsgFromResourcetext("CredSSPContinueCaption");
if (!force && !ShouldContinue(query, caption))
{
return;
@@ -576,14 +576,14 @@ private void EnableServerSideSettings()
{
// get the credssp node to check if wsman is configured on this machine
string result = m_SessionObj.Get(helper.Service_CredSSP_Uri, 0);
- XmlNode node = helper.GetXmlNode(result,
+ XmlNode node = WSManHelper.GetXmlNode(result,
helper.CredSSP_SNode,
helper.Service_CredSSP_XMLNmsp);
if (node == null)
{
InvalidOperationException ex = new InvalidOperationException();
- ErrorRecord er = new ErrorRecord(ex, helper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null);
+ ErrorRecord er = new ErrorRecord(ex, WSManHelper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null);
WriteError(er);
return;
}
@@ -817,11 +817,11 @@ protected override void BeginProcessing()
IWSManEx wsmanObject = (IWSManEx)new WSManClass();
m_SessionObj = (IWSManSession)wsmanObject.CreateSession(null, 0, null);
string result = m_SessionObj.Get(helper.CredSSP_RUri, 0);
- XmlNode node = helper.GetXmlNode(result, helper.CredSSP_SNode, helper.CredSSP_XMLNmsp);
+ XmlNode node = WSManHelper.GetXmlNode(result, helper.CredSSP_SNode, helper.CredSSP_XMLNmsp);
if (node == null)
{
InvalidOperationException ex = new InvalidOperationException();
- ErrorRecord er = new ErrorRecord(ex, helper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null);
+ ErrorRecord er = new ErrorRecord(ex, WSManHelper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null);
WriteError(er);
return;
}
@@ -831,31 +831,31 @@ protected override void BeginProcessing()
string credsspResult = GetDelegateSettings(applicationname);
if (string.IsNullOrEmpty(credsspResult))
{
- WriteObject(helper.GetResourceMsgFromResourcetext("NoDelegateFreshCred"));
+ WriteObject(WSManHelper.GetResourceMsgFromResourcetext("NoDelegateFreshCred"));
}
else
{
- WriteObject(helper.GetResourceMsgFromResourcetext("DelegateFreshCred") + credsspResult);
+ WriteObject(WSManHelper.GetResourceMsgFromResourcetext("DelegateFreshCred") + credsspResult);
}
// Get the server side settings
result = m_SessionObj.Get(helper.Service_CredSSP_Uri, 0);
- node = helper.GetXmlNode(result, helper.CredSSP_SNode, helper.Service_CredSSP_XMLNmsp);
+ node = WSManHelper.GetXmlNode(result, helper.CredSSP_SNode, helper.Service_CredSSP_XMLNmsp);
if (node == null)
{
InvalidOperationException ex = new InvalidOperationException();
- ErrorRecord er = new ErrorRecord(ex, helper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null);
+ ErrorRecord er = new ErrorRecord(ex, WSManHelper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null);
WriteError(er);
return;
}
if (node.InnerText.Equals("true", StringComparison.OrdinalIgnoreCase))
{
- WriteObject(helper.GetResourceMsgFromResourcetext("CredSSPServiceConfigured"));
+ WriteObject(WSManHelper.GetResourceMsgFromResourcetext("CredSSPServiceConfigured"));
}
else
{
- WriteObject(helper.GetResourceMsgFromResourcetext("CredSSPServiceNotConfigured"));
+ WriteObject(WSManHelper.GetResourceMsgFromResourcetext("CredSSPServiceNotConfigured"));
}
}
catch (UnauthorizedAccessException ex)
diff --git a/src/Microsoft.WSMan.Management/InvokeWSManAction.cs b/src/Microsoft.WSMan.Management/InvokeWSManAction.cs
index 16e91cceae9..9e849d1f5e1 100644
--- a/src/Microsoft.WSMan.Management/InvokeWSManAction.cs
+++ b/src/Microsoft.WSMan.Management/InvokeWSManAction.cs
@@ -261,7 +261,7 @@ protected override void BeginProcessing()
helper.WSManOp = "invoke";
// create the connection string
- connectionStr = helper.CreateConnectionString(connectionuri, port, computername, applicationname);
+ connectionStr = WSManHelper.CreateConnectionString(connectionuri, port, computername, applicationname);
}
///
@@ -277,7 +277,7 @@ protected override void ProcessRecord()
// create the session object
m_session = helper.CreateSessionObject(m_wsmanObject, Authentication, sessionoption, Credential, connectionStr, CertificateThumbprint, usessl.IsPresent);
- string rootNode = helper.GetRootNodeName(helper.WSManOp, m_resource.ResourceUri, action);
+ string rootNode = WSManHelper.GetRootNodeName(helper.WSManOp, m_resource.ResourceUri, action);
string input = helper.ProcessInput(m_wsmanObject, filepath, helper.WSManOp, rootNode, valueset, m_resource, m_session);
string resultXml = m_session.Invoke(action, m_resource, input, 0);
diff --git a/src/Microsoft.WSMan.Management/NewWSManSession.cs b/src/Microsoft.WSMan.Management/NewWSManSession.cs
index 25f5bdd5989..33e806e7d2c 100644
--- a/src/Microsoft.WSMan.Management/NewWSManSession.cs
+++ b/src/Microsoft.WSMan.Management/NewWSManSession.cs
@@ -263,7 +263,7 @@ protected override void BeginProcessing()
{
if (_proxycredential == null)
{
- InvalidOperationException ex = new InvalidOperationException(helper.GetResourceMsgFromResourcetext("NewWSManSessionOptionCred"));
+ InvalidOperationException ex = new InvalidOperationException(WSManHelper.GetResourceMsgFromResourcetext("NewWSManSessionOptionCred"));
ErrorRecord er = new ErrorRecord(ex, "InvalidOperationException", ErrorCategory.InvalidOperation, null);
WriteError(er);
return;
@@ -272,7 +272,7 @@ protected override void BeginProcessing()
if ((_proxycredential != null) && (proxyauthentication == 0))
{
- InvalidOperationException ex = new InvalidOperationException(helper.GetResourceMsgFromResourcetext("NewWSManSessionOptionAuth"));
+ InvalidOperationException ex = new InvalidOperationException(WSManHelper.GetResourceMsgFromResourcetext("NewWSManSessionOptionAuth"));
ErrorRecord er = new ErrorRecord(ex, "InvalidOperationException", ErrorCategory.InvalidOperation, null);
WriteError(er);
return;
diff --git a/src/Microsoft.WSMan.Management/PingWSMan.cs b/src/Microsoft.WSMan.Management/PingWSMan.cs
index b9a0e21f1f4..9e400e6f128 100644
--- a/src/Microsoft.WSMan.Management/PingWSMan.cs
+++ b/src/Microsoft.WSMan.Management/PingWSMan.cs
@@ -145,7 +145,7 @@ protected override void ProcessRecord()
WSManHelper helper = new WSManHelper(this);
IWSManEx wsmanObject = (IWSManEx)new WSManClass();
string connectionStr = string.Empty;
- connectionStr = helper.CreateConnectionString(null, port, computername, applicationname);
+ connectionStr = WSManHelper.CreateConnectionString(null, port, computername, applicationname);
IWSManSession m_SessionObj = null;
try
{
diff --git a/src/Microsoft.WSMan.Management/Set-QuickConfig.cs b/src/Microsoft.WSMan.Management/Set-QuickConfig.cs
index c318ea76477..e5ee2f70390 100644
--- a/src/Microsoft.WSMan.Management/Set-QuickConfig.cs
+++ b/src/Microsoft.WSMan.Management/Set-QuickConfig.cs
@@ -86,8 +86,8 @@ protected override void BeginProcessing()
// If not running elevated, then throw an "elevation required" error message.
WSManHelper.ThrowIfNotAdministrator();
helper = new WSManHelper(this);
- string query = helper.GetResourceMsgFromResourcetext("QuickConfigContinueQuery");
- string caption = helper.GetResourceMsgFromResourcetext("QuickConfigContinueCaption");
+ string query = WSManHelper.GetResourceMsgFromResourcetext("QuickConfigContinueQuery");
+ string caption = WSManHelper.GetResourceMsgFromResourcetext("QuickConfigContinueCaption");
if (!force && !ShouldContinue(query, caption))
{
return;
diff --git a/src/Microsoft.WSMan.Management/WSManConnections.cs b/src/Microsoft.WSMan.Management/WSManConnections.cs
index c83ed7e9e10..6ad55ee4a65 100644
--- a/src/Microsoft.WSMan.Management/WSManConnections.cs
+++ b/src/Microsoft.WSMan.Management/WSManConnections.cs
@@ -277,7 +277,7 @@ protected override void BeginProcessing()
}
catch (IndexOutOfRangeException)
{
- helper.AssertError(helper.GetResourceMsgFromResourcetext("NotProperURI"), false, connectionuri);
+ helper.AssertError(WSManHelper.GetResourceMsgFromResourcetext("NotProperURI"), false, connectionuri);
}
}
@@ -285,7 +285,7 @@ protected override void BeginProcessing()
if (this.SessionState.Path.CurrentProviderLocation(WSManStringLiterals.rootpath).Path.StartsWith(this.SessionState.Drive.Current.Name + ":" + WSManStringLiterals.DefaultPathSeparator + crtComputerName, StringComparison.OrdinalIgnoreCase))
{
- helper.AssertError(helper.GetResourceMsgFromResourcetext("ConnectFailure"), false, computername);
+ helper.AssertError(WSManHelper.GetResourceMsgFromResourcetext("ConnectFailure"), false, computername);
}
helper.CreateWsManConnection(ParameterSetName, connectionuri, port, computername, applicationname, usessl.IsPresent, Authentication, sessionoption, Credential, CertificateThumbprint);
@@ -367,22 +367,22 @@ protected override void BeginProcessing()
if (this.SessionState.Path.CurrentProviderLocation(WSManStringLiterals.rootpath).Path.StartsWith(WSManStringLiterals.rootpath + ":" + WSManStringLiterals.DefaultPathSeparator + computername, StringComparison.OrdinalIgnoreCase))
{
- helper.AssertError(helper.GetResourceMsgFromResourcetext("DisconnectFailure"), false, computername);
+ helper.AssertError(WSManHelper.GetResourceMsgFromResourcetext("DisconnectFailure"), false, computername);
}
if (computername.Equals("localhost", StringComparison.OrdinalIgnoreCase))
{
- helper.AssertError(helper.GetResourceMsgFromResourcetext("LocalHost"), false, computername);
+ helper.AssertError(WSManHelper.GetResourceMsgFromResourcetext("LocalHost"), false, computername);
}
- object _ws = helper.RemoveFromDictionary(computername);
+ object _ws = WSManHelper.RemoveFromDictionary(computername);
if (_ws != null)
{
Dispose(_ws);
}
else
{
- helper.AssertError(helper.GetResourceMsgFromResourcetext("InvalidComputerName"), false, computername);
+ helper.AssertError(WSManHelper.GetResourceMsgFromResourcetext("InvalidComputerName"), false, computername);
}
}
}
diff --git a/src/Microsoft.WSMan.Management/WSManInstance.cs b/src/Microsoft.WSMan.Management/WSManInstance.cs
index a60ba270104..d831b4e9a9a 100644
--- a/src/Microsoft.WSMan.Management/WSManInstance.cs
+++ b/src/Microsoft.WSMan.Management/WSManInstance.cs
@@ -569,7 +569,7 @@ protected override void ProcessRecord()
helper = new WSManHelper(this);
helper.WSManOp = "Get";
string connectionStr = null;
- connectionStr = helper.CreateConnectionString(connectionuri, port, computername, applicationname);
+ connectionStr = WSManHelper.CreateConnectionString(connectionuri, port, computername, applicationname);
if (connectionuri != null)
{
try
@@ -581,7 +581,7 @@ protected override void ProcessRecord()
}
catch (IndexOutOfRangeException)
{
- helper.AssertError(helper.GetResourceMsgFromResourcetext("NotProperURI"), false, connectionuri);
+ helper.AssertError(WSManHelper.GetResourceMsgFromResourcetext("NotProperURI"), false, connectionuri);
}
}
@@ -950,7 +950,7 @@ protected override void ProcessRecord()
try
{
string connectionStr = string.Empty;
- connectionStr = helper.CreateConnectionString(connectionuri, port, computername, applicationname);
+ connectionStr = WSManHelper.CreateConnectionString(connectionuri, port, computername, applicationname);
if (connectionuri != null)
{
try
@@ -962,13 +962,13 @@ protected override void ProcessRecord()
}
catch (IndexOutOfRangeException)
{
- helper.AssertError(helper.GetResourceMsgFromResourcetext("NotProperURI"), false, connectionuri);
+ helper.AssertError(WSManHelper.GetResourceMsgFromResourcetext("NotProperURI"), false, connectionuri);
}
}
IWSManResourceLocator m_resource = helper.InitializeResourceLocator(optionset, selectorset, fragment, dialect, m_wsmanObject, resourceuri);
m_session = helper.CreateSessionObject(m_wsmanObject, Authentication, sessionoption, Credential, connectionStr, CertificateThumbprint, usessl.IsPresent);
- string rootNode = helper.GetRootNodeName(helper.WSManOp, m_resource.ResourceUri, null);
+ string rootNode = WSManHelper.GetRootNodeName(helper.WSManOp, m_resource.ResourceUri, null);
string input = helper.ProcessInput(m_wsmanObject, filepath, helper.WSManOp, rootNode, valueset, m_resource, m_session);
XmlDocument xmldoc = new XmlDocument();
@@ -1245,7 +1245,7 @@ protected override void ProcessRecord()
try
{
string connectionStr = string.Empty;
- connectionStr = helper.CreateConnectionString(connectionuri, port, computername, applicationname);
+ connectionStr = WSManHelper.CreateConnectionString(connectionuri, port, computername, applicationname);
if (connectionuri != null)
{
try
@@ -1257,13 +1257,13 @@ protected override void ProcessRecord()
}
catch (IndexOutOfRangeException)
{
- helper.AssertError(helper.GetResourceMsgFromResourcetext("NotProperURI"), false, connectionuri);
+ helper.AssertError(WSManHelper.GetResourceMsgFromResourcetext("NotProperURI"), false, connectionuri);
}
}
IWSManResourceLocator m_resource = helper.InitializeResourceLocator(optionset, selectorset, null, null, m_wsmanObject, resourceuri);
m_session = helper.CreateSessionObject(m_wsmanObject, Authentication, sessionoption, Credential, connectionStr, CertificateThumbprint, usessl.IsPresent);
- string ResourceURI = helper.GetURIWithFilter(resourceuri.ToString(), null, selectorset, helper.WSManOp);
+ string ResourceURI = WSManHelper.GetURIWithFilter(resourceuri.ToString(), null, selectorset, helper.WSManOp);
try
{
((IWSManSession)m_session).Delete(ResourceURI, 0);
@@ -1536,7 +1536,7 @@ protected override void BeginProcessing()
{
helper = new WSManHelper(this);
helper.WSManOp = "new";
- connectionStr = helper.CreateConnectionString(connectionuri, port, computername, applicationname);
+ connectionStr = WSManHelper.CreateConnectionString(connectionuri, port, computername, applicationname);
if (connectionuri != null)
{
try
@@ -1548,7 +1548,7 @@ protected override void BeginProcessing()
}
catch (IndexOutOfRangeException)
{
- helper.AssertError(helper.GetResourceMsgFromResourcetext("NotProperURI"), false, connectionuri);
+ helper.AssertError(WSManHelper.GetResourceMsgFromResourcetext("NotProperURI"), false, connectionuri);
}
}
}
@@ -1563,7 +1563,7 @@ protected override void ProcessRecord()
IWSManResourceLocator m_resource = helper.InitializeResourceLocator(optionset, selectorset, null, null, m_wsmanObject, resourceuri);
// create the session object
m_session = helper.CreateSessionObject(m_wsmanObject, Authentication, sessionoption, Credential, connectionStr, CertificateThumbprint, usessl.IsPresent);
- string rootNode = helper.GetRootNodeName(helper.WSManOp, m_resource.ResourceUri, null);
+ string rootNode = WSManHelper.GetRootNodeName(helper.WSManOp, m_resource.ResourceUri, null);
string input = helper.ProcessInput(m_wsmanObject, filepath, helper.WSManOp, rootNode, valueset, m_resource, m_session);
try
diff --git a/src/Microsoft.WSMan.Management/WsManHelper.cs b/src/Microsoft.WSMan.Management/WsManHelper.cs
index 000cb871abb..f42d75b6921 100644
--- a/src/Microsoft.WSMan.Management/WsManHelper.cs
+++ b/src/Microsoft.WSMan.Management/WsManHelper.cs
@@ -156,7 +156,7 @@ internal static void ThrowIfNotAdministrator()
}
}
- internal string GetResourceMsgFromResourcetext(string rscname)
+ internal static string GetResourceMsgFromResourcetext(string rscname)
{
return _resourceMgr.GetString(rscname);
}
@@ -167,7 +167,7 @@ internal static string FormatResourceMsgFromResourcetextS(string rscname,
return FormatResourceMsgFromResourcetextS(_resourceMgr, rscname, args);
}
- internal string FormatResourceMsgFromResourcetext(string resourceName,
+ internal static string FormatResourceMsgFromResourcetext(string resourceName,
params object[] args)
{
return FormatResourceMsgFromResourcetextS(_resourceMgr, resourceName, args);
@@ -205,7 +205,7 @@ private static string FormatResourceMsgFromResourcetextS(
///
/// Connection string.
/// Session object.
- internal void AddtoDictionary(string key, object value)
+ internal static void AddtoDictionary(string key, object value)
{
key = key.ToLowerInvariant();
lock (Sessions.SessionObjCache)
@@ -233,7 +233,7 @@ internal void AddtoDictionary(string key, object value)
}
}
- internal object RemoveFromDictionary(string computer)
+ internal static object RemoveFromDictionary(string computer)
{
object objsession = null;
computer = computer.ToLowerInvariant();
@@ -288,7 +288,7 @@ internal static Dictionary GetSessionObjCache()
return Sessions.SessionObjCache;
}
- internal string GetRootNodeName(string operation, string resourceUri, string actionStr)
+ internal static string GetRootNodeName(string operation, string resourceUri, string actionStr)
{
string resultStr = null, sfx = null;
if (resourceUri != null)
@@ -319,7 +319,7 @@ internal string GetRootNodeName(string operation, string resourceUri, string act
return resultStr;
}
- internal string StripParams(string uri)
+ internal static string StripParams(string uri)
{
int pos = uri.IndexOf('?');
if (pos > 0)
@@ -500,12 +500,12 @@ internal string ProcessInput(IWSManEx wsman, string filepath, string operation,
return resultString;
}
- internal string GetXmlNs(string resUri)
+ internal static string GetXmlNs(string resUri)
{
return (@"xmlns:p=""" + StripParams(resUri) + @"""");
}
- internal XmlNode GetXmlNode(string xmlString, string xpathpattern, string xmlnamespace)
+ internal static XmlNode GetXmlNode(string xmlString, string xpathpattern, string xmlnamespace)
{
XmlNode node = null;
XmlDocument xDoc = new XmlDocument();
@@ -520,7 +520,7 @@ internal XmlNode GetXmlNode(string xmlString, string xpathpattern, string xmlnam
return node;
}
- internal string CreateConnectionString(Uri ConnUri, int port, string computername, string applicationname)
+ internal static string CreateConnectionString(Uri ConnUri, int port, string computername, string applicationname)
{
string ConnectionString = null;
if (ConnUri != null)
@@ -863,7 +863,7 @@ internal void CleanUp()
}
}
- internal string GetFilterString(Hashtable seletorset)
+ internal static string GetFilterString(Hashtable seletorset)
{
StringBuilder filter = new StringBuilder();
foreach (DictionaryEntry entry in seletorset)
@@ -913,7 +913,7 @@ internal void AssertError(string ErrorMessage, bool IsWSManError, object targeto
}
}
- internal string GetURIWithFilter(string uri, string filter, Hashtable selectorset, string operation)
+ internal static string GetURIWithFilter(string uri, string filter, Hashtable selectorset, string operation)
{
StringBuilder sburi = new StringBuilder();
sburi.Append(uri);
diff --git a/src/System.Management.Automation/CoreCLR/CorePsStub.cs b/src/System.Management.Automation/CoreCLR/CorePsStub.cs
index d99bcbb398b..c0b4db255b1 100644
--- a/src/System.Management.Automation/CoreCLR/CorePsStub.cs
+++ b/src/System.Management.Automation/CoreCLR/CorePsStub.cs
@@ -66,7 +66,7 @@ internal sealed class PSTransactionManager : IDisposable
///
/// Always return false in CoreCLR
///
- internal bool HasTransaction
+ internal static bool HasTransaction
{
get
{
diff --git a/src/System.Management.Automation/FormatAndOutput/common/BaseFormattingCommand.cs b/src/System.Management.Automation/FormatAndOutput/common/BaseFormattingCommand.cs
index 18b74cbcfe1..7ab056a2e83 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/BaseFormattingCommand.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/BaseFormattingCommand.cs
@@ -509,7 +509,7 @@ private void PushGroup(PSObject firstObjectInGroup)
///
private void PopGroup()
{
- GroupEndData endGroup = _viewManager.ViewGenerator.GenerateGroupEndData();
+ GroupEndData endGroup = ViewGenerator.GenerateGroupEndData();
this.WriteObject(endGroup);
contextManager.Pop();
}
diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs
index 8c1c251f149..2ecd30e0e1d 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs
@@ -719,7 +719,7 @@ private ExpressionToken LoadExpressionFromObjectModel(DisplayEntry displayEntry,
// For faster startup, we don't validate any of the built-in formatting script blocks, where isFullyTrusted == built-in.
if (!LoadingInfo.isFullyTrusted)
{
- this.expressionFactory.VerifyScriptBlockText(token.expressionValue);
+ PSPropertyExpressionFactory.VerifyScriptBlockText(token.expressionValue);
}
}
catch (ParseException e)
@@ -1924,7 +1924,7 @@ internal bool VerifyScriptBlock(string scriptBlockText)
{
try
{
- this.expressionFactory.VerifyScriptBlockText(scriptBlockText);
+ PSPropertyExpressionFactory.VerifyScriptBlockText(scriptBlockText);
}
catch (ParseException e)
{
diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator.cs b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator.cs
index f29033e3c8d..748bf07a067 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator.cs
@@ -283,7 +283,7 @@ internal bool UpdateGroupingKeyValue(PSObject so)
return _groupingManager.UpdateGroupingKeyValue(so);
}
- internal GroupEndData GenerateGroupEndData()
+ internal static GroupEndData GenerateGroupEndData()
{
return new GroupEndData();
}
diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormattingObjectsDeserializer.cs b/src/System.Management.Automation/FormatAndOutput/common/FormattingObjectsDeserializer.cs
index 962cf6f5ff1..aa0b78de6d0 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/FormattingObjectsDeserializer.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/FormattingObjectsDeserializer.cs
@@ -293,7 +293,7 @@ internal bool DeserializeBoolMemberVariable(PSObject so, string property, bool c
return val != null && (bool)val;
}
- internal WriteStreamType DeserializeWriteStreamTypeMemberVariable(PSObject so)
+ internal static WriteStreamType DeserializeWriteStreamTypeMemberVariable(PSObject so)
{
object wsTypeValue = GetProperty(so, "writeStream");
if (wsTypeValue == null)
@@ -563,7 +563,7 @@ internal override void Deserialize(PSObject so, FormatObjectDeserializer deseria
base.Deserialize(so, deserializer);
this.formatEntryInfo = (FormatEntryInfo)deserializer.DeserializeMandatoryMemberObject(so, "formatEntryInfo");
this.outOfBand = deserializer.DeserializeBoolMemberVariable(so, "outOfBand");
- this.writeStream = deserializer.DeserializeWriteStreamTypeMemberVariable(so);
+ this.writeStream = FormatObjectDeserializer.DeserializeWriteStreamTypeMemberVariable(so);
this.isHelpObject = so.IsHelpObject;
}
}
diff --git a/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshObjectUtil.cs b/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshObjectUtil.cs
index 7760e86b13d..812099df479 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshObjectUtil.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshObjectUtil.cs
@@ -561,7 +561,7 @@ internal sealed class StringFormatError : FormattingError
internal sealed class PSPropertyExpressionFactory
{
///
- internal void VerifyScriptBlockText(string scriptText)
+ internal static void VerifyScriptBlockText(string scriptText)
{
ScriptBlock.Create(scriptText);
}
diff --git a/src/System.Management.Automation/engine/COM/ComProperty.cs b/src/System.Management.Automation/engine/COM/ComProperty.cs
index 9ac1a28656b..be18d4220da 100644
--- a/src/System.Management.Automation/engine/COM/ComProperty.cs
+++ b/src/System.Management.Automation/engine/COM/ComProperty.cs
@@ -115,7 +115,7 @@ private int GetFuncDescIndex()
/// Returns the number of parameters in this property.
/// This is applicable only for parameterized properties.
///
- internal int ParamCount
+ internal static int ParamCount
{
get
{
diff --git a/src/System.Management.Automation/engine/ComInterop/ComTypeLibDesc.cs b/src/System.Management.Automation/engine/ComInterop/ComTypeLibDesc.cs
index 2b81c76b6eb..a031f39d6e2 100644
--- a/src/System.Management.Automation/engine/ComInterop/ComTypeLibDesc.cs
+++ b/src/System.Management.Automation/engine/ComInterop/ComTypeLibDesc.cs
@@ -37,7 +37,7 @@ public override string ToString()
return string.Format(CultureInfo.CurrentCulture, "", Name);
}
- public string Documentation
+ public static string Documentation
{
get { return string.Empty; }
}
diff --git a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
index 69f24c243cc..c936797b65d 100644
--- a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
+++ b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
@@ -2377,7 +2377,7 @@ private static Hashtable GetBoundArgumentsAsHashtable(CompletionContext context)
var switchPair = boundArgument.Value as SwitchPair;
if (switchPair != null)
{
- result[boundArgument.Key] = switchPair.Argument;
+ result[boundArgument.Key] = SwitchPair.Argument;
continue;
}
// Ignored:
diff --git a/src/System.Management.Automation/engine/CommandCompletion/PseudoParameterBinder.cs b/src/System.Management.Automation/engine/CommandCompletion/PseudoParameterBinder.cs
index c98be4ccac8..a856bb57e72 100644
--- a/src/System.Management.Automation/engine/CommandCompletion/PseudoParameterBinder.cs
+++ b/src/System.Management.Automation/engine/CommandCompletion/PseudoParameterBinder.cs
@@ -159,7 +159,7 @@ internal SwitchPair(CommandParameterAst parameterAst)
///
/// Get the argument.
///
- public bool Argument
+ public static bool Argument
{
get { return true; }
}
diff --git a/src/System.Management.Automation/engine/CommandMetadata.cs b/src/System.Management.Automation/engine/CommandMetadata.cs
index eb59f9140a2..4ecba7f5ea5 100644
--- a/src/System.Management.Automation/engine/CommandMetadata.cs
+++ b/src/System.Management.Automation/engine/CommandMetadata.cs
@@ -1061,7 +1061,7 @@ internal string GetBeginBlock()
return result;
}
- internal string GetProcessBlock()
+ internal static string GetProcessBlock()
{
return @"
try {
@@ -1102,7 +1102,7 @@ internal string GetDynamicParamBlock()
_wrappedCommandType);
}
- internal string GetEndBlock()
+ internal static string GetEndBlock()
{
return @"
try {
diff --git a/src/System.Management.Automation/engine/CommandProcessor.cs b/src/System.Management.Automation/engine/CommandProcessor.cs
index fb1fe81fc54..267b77da54e 100644
--- a/src/System.Management.Automation/engine/CommandProcessor.cs
+++ b/src/System.Management.Automation/engine/CommandProcessor.cs
@@ -270,7 +270,7 @@ protected override void OnRestorePreviousScope()
PSScriptCmdlet scriptCmdlet = this.Command as PSScriptCmdlet;
if (scriptCmdlet != null && !UseLocalScope)
{
- scriptCmdlet.PopDottedScope(CommandSessionState.CurrentScope);
+ PSScriptCmdlet.PopDottedScope(CommandSessionState.CurrentScope);
}
}
diff --git a/src/System.Management.Automation/engine/CommandProcessorBase.cs b/src/System.Management.Automation/engine/CommandProcessorBase.cs
index c6825cc6925..8f370398ab7 100644
--- a/src/System.Management.Automation/engine/CommandProcessorBase.cs
+++ b/src/System.Management.Automation/engine/CommandProcessorBase.cs
@@ -855,7 +855,7 @@ internal PipelineStoppedException ManageInvocationException(Exception e)
// Rollback the transaction in the case of errors.
if (
- _context.TransactionManager.HasTransaction
+ PSTransactionManager.HasTransaction
&&
_context.TransactionManager.RollbackPreference != RollbackSeverity.Never
)
diff --git a/src/System.Management.Automation/engine/CoreAdapter.cs b/src/System.Management.Automation/engine/CoreAdapter.cs
index bf9775b35ef..6f62789b2e9 100644
--- a/src/System.Management.Automation/engine/CoreAdapter.cs
+++ b/src/System.Management.Automation/engine/CoreAdapter.cs
@@ -3582,7 +3582,7 @@ private static CacheTable GetInstanceMethodReflectionTable(Type type)
}
}
- internal IEnumerable