Code redundancy fixes (#12916)
* Autofix `RCS1036: Remove redundant empty line` * Autofix `RCS1037: Remove trailing white-space` * Autofix `RCS1033: Remove redundant boolean literal` * Autofix: `RCS1038: Remove empty statement` * Autofix `RCS1041: Remove empty initializer` * Autofix `RCS1097: Remove redundant 'ToString' call * Autofix: `RCS1420: Operator is unnecessary`
This commit is contained in:
parent
eaee9a3f21
commit
0d5d017f0f
|
@ -511,7 +511,6 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
|
|||
/// </summary>
|
||||
public class CimBaseCommand : Cmdlet, IDisposable
|
||||
{
|
||||
|
||||
#region resolve parameter set name
|
||||
/// <summary>
|
||||
/// <para>
|
||||
|
@ -982,7 +981,6 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
|
|||
NetworkCredential networkCredential = psCredentials.GetNetworkCredential();
|
||||
DebugHelper.WriteLog("Domain:{0}; UserName:{1}; Password:{2}.", 1, networkCredential.Domain, networkCredential.UserName, psCredentials.Password);
|
||||
credentials = new CimCredential(passwordAuthentication, networkCredential.Domain, networkCredential.UserName, psCredentials.Password);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -79,7 +79,6 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
|
|||
cmdlet.Key,
|
||||
cmdlet.Property,
|
||||
cmdlet);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -92,7 +91,6 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
|
|||
cmdlet.Key,
|
||||
cmdlet.Property,
|
||||
cmdlet);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -103,7 +101,6 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
|
|||
cimInstance = CreateCimInstance(cmdlet.CimClass,
|
||||
cmdlet.Property,
|
||||
cmdlet);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -313,7 +310,6 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
|
|||
flag);
|
||||
cimInstance.CimInstanceProperties.Add(newProperty);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return cimInstance;
|
||||
|
|
|
@ -12,7 +12,6 @@ using System.Threading;
|
|||
|
||||
namespace Microsoft.Management.Infrastructure.CimCmdlets
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// <para>
|
||||
/// Subscription result event args
|
||||
|
|
|
@ -50,5 +50,4 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
|
|||
private object result;
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -619,7 +619,6 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
|
|||
new ParameterDefinitionEntry(CimBaseCommand.QueryComputerSet, false),
|
||||
new ParameterDefinitionEntry(CimBaseCommand.ClassNameSessionSet, false),
|
||||
new ParameterDefinitionEntry(CimBaseCommand.ClassNameComputerSet, false),
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -371,7 +371,6 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
|
|||
{
|
||||
writer.WriteLineAsync(spaces[indent] + sourceInformation + @" " + message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,8 +56,7 @@ namespace Microsoft.Management.UI.Internal
|
|||
|
||||
private static bool HasTimeComponent(DateTime value)
|
||||
{
|
||||
bool hasNoTimeComponent = true
|
||||
&& value.Hour == 0
|
||||
bool hasNoTimeComponent = value.Hour == 0
|
||||
&& value.Minute == 0
|
||||
&& value.Second == 0
|
||||
&& value.Millisecond == 0;
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Microsoft.Management.UI.Internal
|
|||
return;
|
||||
}
|
||||
|
||||
if ((bool)e.OldValue == true)
|
||||
if ((bool)e.OldValue)
|
||||
{
|
||||
tb.SizeChanged -= OnTextBlockSizeChanged;
|
||||
}
|
||||
|
|
|
@ -168,8 +168,7 @@ namespace Microsoft.Management.UI.Internal
|
|||
throw new ArgumentNullException("typeToParseTo");
|
||||
}
|
||||
|
||||
bool isNumericType = false
|
||||
|| typeToParseTo == typeof(byte)
|
||||
bool isNumericType = typeToParseTo == typeof(byte)
|
||||
|| typeToParseTo == typeof(sbyte)
|
||||
|| typeToParseTo == typeof(short)
|
||||
|| typeToParseTo == typeof(ushort)
|
||||
|
|
|
@ -39,11 +39,9 @@ namespace Microsoft.PowerShell.Commands.Diagnostics.Common
|
|||
[DllImport(LibraryLoadDllName)]
|
||||
private static extern bool FreeLibrary(IntPtr hModule);
|
||||
|
||||
|
||||
[DllImport(LocalizationDllName, EntryPoint = "GetUserDefaultLangID", CallingConvention = CallingConvention.Winapi, SetLastError = true)]
|
||||
private static extern ushort GetUserDefaultLangID();
|
||||
|
||||
|
||||
public static uint FormatMessageFromModule(uint lastError, string moduleName, out String msg)
|
||||
{
|
||||
Debug.Assert(!string.IsNullOrEmpty(moduleName));
|
||||
|
|
|
@ -212,7 +212,6 @@ namespace Microsoft.PowerShell.Commands
|
|||
//
|
||||
protected override void BeginProcessing()
|
||||
{
|
||||
|
||||
if (Platform.IsIoT)
|
||||
{
|
||||
// IoT does not have the '$env:windir\System32\pdh.dll' assembly which is required by this cmdlet.
|
||||
|
|
|
@ -2018,7 +2018,6 @@ namespace Microsoft.PowerShell.Commands
|
|||
_providersByLogMap.Add(logLink.LogName.ToLowerInvariant(), provColl);
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
//
|
||||
// Log is there: add provider, if needed
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace Microsoft.PowerShell.Cmdletization.Cim
|
|||
else
|
||||
{
|
||||
#if DEBUG
|
||||
Dbg.Assert(_createInstanceOperationGotStarted == true, "GetInstance should be started *after* CreateInstance");
|
||||
Dbg.Assert(_createInstanceOperationGotStarted, "GetInstance should be started *after* CreateInstance");
|
||||
Dbg.Assert(_getInstanceOperationGotStarted == false, "Should not start GetInstance operation twice");
|
||||
Dbg.Assert(_resultFromGetInstance == null, "GetInstance operation shouldn't happen twice");
|
||||
_getInstanceOperationGotStarted = true;
|
||||
|
|
|
@ -1876,7 +1876,7 @@ $result
|
|||
{
|
||||
if (logicalDrive.DriveType.Equals(DriveType.Fixed))
|
||||
{
|
||||
if (drive.ToString().Equals(logicalDrive.Name.ToString(), System.StringComparison.OrdinalIgnoreCase))
|
||||
if (drive.Equals(logicalDrive.Name, System.StringComparison.OrdinalIgnoreCase))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
private ManagementObjectSearcher _searchProcess;
|
||||
|
||||
private bool _inputContainsWildcard = false;
|
||||
private readonly ConnectionOptions _connectionOptions = new ConnectionOptions { };
|
||||
private readonly ConnectionOptions _connectionOptions = new ConnectionOptions();
|
||||
|
||||
/// <summary>
|
||||
/// Sets connection options.
|
||||
|
|
|
@ -144,7 +144,6 @@ namespace Microsoft.PowerShell.Commands
|
|||
StringUtil.Format(ServiceResources.CouldNotSetServiceSecurityDescriptorSddl, service.ServiceName, exception.Message),
|
||||
accessDenied ? ErrorCategory.PermissionDenied : ErrorCategory.InvalidOperation);
|
||||
}
|
||||
|
||||
}
|
||||
#endregion Internal
|
||||
}
|
||||
|
@ -2749,7 +2748,6 @@ namespace Microsoft.PowerShell.Commands
|
|||
[In] IntPtr lpPassword
|
||||
);
|
||||
|
||||
|
||||
[DllImport(PinvokeDllNames.SetServiceObjectSecurityDllName, CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern
|
||||
|
|
|
@ -577,7 +577,6 @@ namespace Microsoft.PowerShell.Commands
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
if (_loadAssembly)
|
||||
{
|
||||
// File extension is ".DLL" (ParameterSetName = FromPathParameterSetName or FromLiteralPathParameterSetName).
|
||||
|
|
|
@ -1738,7 +1738,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
case "UseCulture":
|
||||
case "CulturePath":
|
||||
case "CultureLiteralPath":
|
||||
if (useCulture == true)
|
||||
if (useCulture)
|
||||
{
|
||||
// ListSeparator is apparently always a character even though the property returns a string, checked via:
|
||||
// [CultureInfo]::GetCultures("AllCultures") | % { ([CultureInfo]($_.Name)).TextInfo.ListSeparator } | ? Length -ne 1
|
||||
|
|
|
@ -648,7 +648,7 @@ namespace System.Management.Automation
|
|||
if (property != null)
|
||||
{
|
||||
WriteStartElement(_writer, CustomSerializationStrings.Properties);
|
||||
WriteAttribute(_writer, CustomSerializationStrings.NameAttribute, property.ToString());
|
||||
WriteAttribute(_writer, CustomSerializationStrings.NameAttribute, property);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1063,9 +1063,9 @@ namespace System.Management.Automation
|
|||
XmlWriter writer, PSPropertyInfo source, int depth)
|
||||
{
|
||||
WriteStartElement(writer, CustomSerializationStrings.Properties);
|
||||
WriteAttribute(writer, CustomSerializationStrings.NameAttribute, ((PSPropertyInfo)source).Name.ToString());
|
||||
WriteAttribute(writer, CustomSerializationStrings.NameAttribute, ((PSPropertyInfo)source).Name);
|
||||
if (!_notypeinformation)
|
||||
WriteAttribute(writer, CustomSerializationStrings.TypeAttribute, ((PSPropertyInfo)source).TypeNameOfValue.ToString());
|
||||
WriteAttribute(writer, CustomSerializationStrings.TypeAttribute, ((PSPropertyInfo)source).TypeNameOfValue);
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
|
@ -1075,7 +1075,7 @@ namespace System.Management.Automation
|
|||
if (property != null)
|
||||
{
|
||||
WriteStartElement(writer, CustomSerializationStrings.Properties);
|
||||
WriteAttribute(writer, CustomSerializationStrings.NameAttribute, property.ToString());
|
||||
WriteAttribute(writer, CustomSerializationStrings.NameAttribute, property);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -112,9 +112,9 @@ namespace Microsoft.PowerShell.Commands
|
|||
|
||||
// During remoting, remain compatible with v5.0- clients by default.
|
||||
// Passing a -PowerShellVersion argument allows overriding the client version.
|
||||
bool writeOldWay =
|
||||
bool writeOldWay =
|
||||
(remotingClientInfo != null && clientVersion == null) // To be safe: Remoting client version could unexpectedly not be determined.
|
||||
||
|
||||
||
|
||||
(clientVersion != null
|
||||
&&
|
||||
(clientVersion.Major < 5
|
||||
|
|
|
@ -20,7 +20,6 @@ using System.Xml;
|
|||
|
||||
using Dbg = System.Management.Automation.Diagnostics;
|
||||
|
||||
|
||||
namespace Microsoft.PowerShell.Commands
|
||||
{
|
||||
using PowerShell = System.Management.Automation.PowerShell;
|
||||
|
@ -800,7 +799,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
if (_commandsSkippedBecauseOfShadowing.Count != 0)
|
||||
{
|
||||
string skippedCommands = string.Join(", ", _commandsSkippedBecauseOfShadowing.ToArray());
|
||||
ErrorRecord errorRecord = this.GetErrorCommandSkippedBecauseOfShadowing(skippedCommands.ToString());
|
||||
ErrorRecord errorRecord = this.GetErrorCommandSkippedBecauseOfShadowing(skippedCommands);
|
||||
this.WriteWarning(errorRecord.ErrorDetails.Message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -465,7 +465,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
|
||||
thread.Join();
|
||||
|
||||
if (createInfo.success == true)
|
||||
if (createInfo.success)
|
||||
{
|
||||
return createInfo.objectCreated;
|
||||
}
|
||||
|
|
|
@ -377,7 +377,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
finally
|
||||
{
|
||||
_mSmtpClient.Dispose();
|
||||
|
||||
|
||||
// If we don't dispose the attachments, the sender can't modify or use the files sent.
|
||||
_mMailMessage.Attachments.Dispose();
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
/// Big Endian UTF32 encoding.
|
||||
/// </summary>
|
||||
BigEndianUTF32,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// UTF8 encoding.
|
||||
/// </summary>
|
||||
|
|
|
@ -1070,7 +1070,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
if (!string.IsNullOrEmpty(CustomMethod))
|
||||
{
|
||||
// set the method if the parameter was provided
|
||||
httpMethod = new HttpMethod(CustomMethod.ToString().ToUpperInvariant());
|
||||
httpMethod = new HttpMethod(CustomMethod.ToUpperInvariant());
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1478,7 +1478,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
&&
|
||||
PreserveAuthorizationOnRedirect.IsPresent
|
||||
&&
|
||||
WebSession.Headers.ContainsKey(HttpKnownHeaderNames.Authorization.ToString());
|
||||
WebSession.Headers.ContainsKey(HttpKnownHeaderNames.Authorization);
|
||||
|
||||
using (HttpClient client = GetHttpClient(keepAuthorization))
|
||||
{
|
||||
|
@ -1845,7 +1845,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
if (url != string.Empty && rel != string.Empty && !_relationLink.ContainsKey(rel))
|
||||
{
|
||||
Uri absoluteUri = new Uri(requestUri, url);
|
||||
_relationLink.Add(rel, absoluteUri.AbsoluteUri.ToString());
|
||||
_relationLink.Add(rel, absoluteUri.AbsoluteUri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1899,7 +1899,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
}
|
||||
|
||||
// Treat the value as a collection and enumerate it if enumeration is true
|
||||
if (enumerate == true && fieldValue is IEnumerable items)
|
||||
if (enumerate && fieldValue is IEnumerable items)
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
|
|
|
@ -780,7 +780,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
if (!info2.IsDefined(typeof(T), true))
|
||||
{
|
||||
MethodInfo getMethod = info2.GetGetMethod();
|
||||
if ((getMethod != null) && (getMethod.GetParameters().Length <= 0))
|
||||
if ((getMethod != null) && (getMethod.GetParameters().Length == 0))
|
||||
{
|
||||
object value;
|
||||
try
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
|
||||
foreach (object element in enumerable)
|
||||
{
|
||||
if (printSeparator == true && Separator != null)
|
||||
if (printSeparator && Separator != null)
|
||||
{
|
||||
result.Append(Separator.ToString());
|
||||
}
|
||||
|
|
|
@ -879,7 +879,6 @@ namespace Microsoft.PowerShell
|
|||
{
|
||||
// Just toss this option, it was processed earlier...
|
||||
}
|
||||
|
||||
else if (MatchSwitch(switchKey, "modules", "mod"))
|
||||
{
|
||||
if (ConsoleHost.DefaultInitialSessionState == null)
|
||||
|
|
|
@ -1280,7 +1280,7 @@ namespace Microsoft.PowerShell
|
|||
{
|
||||
// If ShouldEndSession is already true, you can't set it back
|
||||
|
||||
Dbg.Assert(_shouldEndSession != true || value != false,
|
||||
Dbg.Assert(_shouldEndSession != true || value,
|
||||
"ShouldEndSession can only be set from false to true");
|
||||
|
||||
_shouldEndSession = value;
|
||||
|
|
|
@ -29,7 +29,6 @@ namespace Microsoft.PowerShell
|
|||
[SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
|
||||
internal partial class ConsoleHostUserInterface : System.Management.Automation.Host.PSHostUserInterface
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// This is the char that is echoed to the console when the input is masked. This not localizable.
|
||||
/// </summary>
|
||||
|
|
|
@ -241,7 +241,7 @@ namespace Microsoft.PowerShell
|
|||
// hence the Input pipe.
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
des.End();
|
||||
}
|
||||
|
||||
|
|
|
@ -685,7 +685,7 @@ namespace System.Diagnostics.Eventing.Reader
|
|||
case UnsafeNativeMethods.EvtChannelConfigPropertyId.EvtChannelConfigEnabled:
|
||||
{
|
||||
varVal.Type = (uint)UnsafeNativeMethods.EvtVariantType.EvtVarTypeBoolean;
|
||||
if ((bool)val == true) varVal.Bool = 1;
|
||||
if ((bool)val) varVal.Bool = 1;
|
||||
else varVal.Bool = 0;
|
||||
}
|
||||
|
||||
|
@ -730,7 +730,7 @@ namespace System.Diagnostics.Eventing.Reader
|
|||
case UnsafeNativeMethods.EvtChannelConfigPropertyId.EvtChannelLoggingConfigRetention:
|
||||
{
|
||||
varVal.Type = (uint)UnsafeNativeMethods.EvtVariantType.EvtVarTypeBoolean;
|
||||
if ((bool)val == true) varVal.Bool = 1;
|
||||
if ((bool)val) varVal.Bool = 1;
|
||||
else varVal.Bool = 0;
|
||||
}
|
||||
|
||||
|
@ -738,7 +738,7 @@ namespace System.Diagnostics.Eventing.Reader
|
|||
case UnsafeNativeMethods.EvtChannelConfigPropertyId.EvtChannelLoggingConfigAutoBackup:
|
||||
{
|
||||
varVal.Type = (uint)UnsafeNativeMethods.EvtVariantType.EvtVarTypeBoolean;
|
||||
if ((bool)val == true) varVal.Bool = 1;
|
||||
if ((bool)val) varVal.Bool = 1;
|
||||
else varVal.Bool = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -823,7 +823,7 @@ namespace Microsoft.WSMan.Management
|
|||
try
|
||||
{
|
||||
PSObject mshObject = null;
|
||||
if (!uri.Equals(WinrmRootName[0].ToString(), StringComparison.OrdinalIgnoreCase))
|
||||
if (!uri.Equals(WinrmRootName[0], StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
foreach (XmlNode innerResourceNodes in xmlResource.ChildNodes)
|
||||
{
|
||||
|
@ -2259,7 +2259,7 @@ namespace Microsoft.WSMan.Management
|
|||
inputStr = ConstructPluginXml(ps, uri, host, "Set", ResourceArray, SecurityArray, InitParamArray);
|
||||
try
|
||||
{
|
||||
((IWSManSession)sessionobj).Put(uri + "?" + "Name=" + pName, inputStr.ToString(), 0);
|
||||
((IWSManSession)sessionobj).Put(uri + "?" + "Name=" + pName, inputStr, 0);
|
||||
if (path.EndsWith(strPathChk + WSManStringLiterals.containerInitParameters, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
WriteItemObject(GetItemPSObjectWithTypeName(mshObj.Properties[NewItem].Name, mshObj.Properties[NewItem].TypeNameOfValue, mshObj.Properties[NewItem].Value, null, "InitParams", WsManElementObjectTypes.WSManConfigLeafElement), path + WSManStringLiterals.DefaultPathSeparator + mshObj.Properties[NewItem].Name, false);
|
||||
|
@ -2536,7 +2536,7 @@ namespace Microsoft.WSMan.Management
|
|||
MatchCollection regexmatch = objregex.Matches(ResourceURI);
|
||||
if (regexmatch.Count > 0)
|
||||
{
|
||||
tempuri = regexmatch[0].Value.ToString();
|
||||
tempuri = regexmatch[0].Value;
|
||||
}
|
||||
|
||||
return tempuri;
|
||||
|
@ -2686,7 +2686,7 @@ namespace Microsoft.WSMan.Management
|
|||
if (Itemfound)
|
||||
{
|
||||
ResourceURI = GetURIWithFilter(ResourceURI, value);
|
||||
((IWSManSession)sessionobj).Put(ResourceURI, node.OuterXml.ToString(), 0);
|
||||
((IWSManSession)sessionobj).Put(ResourceURI, node.OuterXml, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3344,7 +3344,7 @@ namespace Microsoft.WSMan.Management
|
|||
|
||||
if (path.Equals(host, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
uri = WinrmRootName[0].ToString();
|
||||
uri = WinrmRootName[0];
|
||||
return uri;
|
||||
}
|
||||
|
||||
|
@ -3353,19 +3353,19 @@ namespace Microsoft.WSMan.Management
|
|||
string host_prefix = host + WSManStringLiterals.DefaultPathSeparator;
|
||||
if (path.StartsWith(host_prefix + WSManStringLiterals.containerClientCertificate, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
uri = WinrmRootName[0].ToString() + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerCertMapping;
|
||||
uri = WinrmRootName[0] + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerCertMapping;
|
||||
}
|
||||
else if (path.StartsWith(host_prefix + WSManStringLiterals.containerPlugin, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
uri = WinrmRootName[0].ToString() + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerPlugin;
|
||||
uri = WinrmRootName[0] + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerPlugin;
|
||||
}
|
||||
else if (path.StartsWith(host_prefix + WSManStringLiterals.containerShell, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
uri = WinrmRootName[0].ToString() + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerWinrs;
|
||||
uri = WinrmRootName[0] + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerWinrs;
|
||||
}
|
||||
else if (path.StartsWith(host_prefix + WSManStringLiterals.containerListener, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
uri = WinrmRootName[0].ToString() + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerListener;
|
||||
uri = WinrmRootName[0] + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerListener;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3380,7 +3380,7 @@ namespace Microsoft.WSMan.Management
|
|||
}
|
||||
}
|
||||
|
||||
uri = WinrmRootName[0].ToString() + uri;
|
||||
uri = WinrmRootName[0] + uri;
|
||||
}
|
||||
|
||||
return uri;
|
||||
|
@ -3795,7 +3795,6 @@ namespace Microsoft.WSMan.Management
|
|||
if (path.EndsWith(host + WSManStringLiterals.DefaultPathSeparator + ContainerListenerOrClientCert, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (Objcache.ContainsKey(childname))
|
||||
|
||||
WriteItemObject(GetItemPSObjectWithTypeName(childname, WSManStringLiterals.ContainerChildValue, null, (string[])Keyscache[childname], null, WsManElementObjectTypes.WSManConfigContainerElement), path + WSManStringLiterals.DefaultPathSeparator + childname, true);
|
||||
}
|
||||
else
|
||||
|
@ -5491,8 +5490,8 @@ namespace Microsoft.WSMan.Management
|
|||
/// </summary>
|
||||
private static readonly List<string> globalWarningUris =
|
||||
new List<string> {
|
||||
WinrmRootName[0].ToString() + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerWinrs,
|
||||
WinrmRootName[0].ToString() + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerService};
|
||||
WinrmRootName[0] + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerWinrs,
|
||||
WinrmRootName[0] + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerService};
|
||||
|
||||
#endregion def
|
||||
|
||||
|
|
|
@ -480,7 +480,6 @@ namespace Microsoft.WSMan.Management
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -233,7 +233,7 @@ namespace Microsoft.WSMan.Management
|
|||
xpathResult = "/cfg:EnableRemoting_OUTPUT/cfg:Results";
|
||||
}
|
||||
|
||||
if (finalxml.SelectSingleNode(xpathStatus, nsmgr).InnerText.ToString().Equals("succeeded"))
|
||||
if (finalxml.SelectSingleNode(xpathStatus, nsmgr).InnerText.Equals("succeeded"))
|
||||
{
|
||||
if (serviceonly)
|
||||
{
|
||||
|
|
|
@ -419,7 +419,7 @@ namespace Microsoft.WSMan.Management
|
|||
}
|
||||
|
||||
filter = filter + "</wsman:SelectorSet>";
|
||||
return (filter.ToString());
|
||||
return (filter);
|
||||
}
|
||||
|
||||
private void ReturnEnumeration(IWSManEx wsmanObject, IWSManResourceLocator wsmanResourceLocator, IWSManSession wsmanSession)
|
||||
|
|
|
@ -1028,7 +1028,7 @@ namespace Microsoft.WSMan.Management
|
|||
}
|
||||
|
||||
string[] valuenames = rGPOLocalMachineKey.GetValueNames();
|
||||
if (valuenames.Length <= 0)
|
||||
if (valuenames.Length == 0)
|
||||
{
|
||||
return !AllowFreshCredentialsValueShouldBePresent;
|
||||
}
|
||||
|
@ -1119,7 +1119,7 @@ namespace Microsoft.WSMan.Management
|
|||
internal static string GetResourceString(string Key)
|
||||
{
|
||||
// Checks whether resource values already loaded and loads.
|
||||
if (ResourceValueCache.Count <= 0)
|
||||
if (ResourceValueCache.Count == 0)
|
||||
{
|
||||
LoadResourceData();
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
|
|||
else
|
||||
{
|
||||
resourceReference.assemblyLocation = loadResult.a.Location;
|
||||
};
|
||||
}
|
||||
|
||||
// load now the resource from the resource manager cache
|
||||
try
|
||||
|
|
|
@ -98,7 +98,6 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
|
|||
mainControlFound = true;
|
||||
view.mainControl = LoadListControl(n);
|
||||
}
|
||||
|
||||
else if (MatchNodeName(n, XmlTags.WideControlNode))
|
||||
{
|
||||
if (mainControlFound)
|
||||
|
|
|
@ -516,7 +516,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
|
|||
}
|
||||
|
||||
// we must check we have enough properties for a list view
|
||||
if (new PSPropertyExpression("*").ResolveNames(so).Count <= 0)
|
||||
if (new PSPropertyExpression("*").ResolveNames(so).Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace System.Management.Automation
|
|||
/// Implementation of WriteDebug - just discards the input.
|
||||
/// </summary>
|
||||
/// <param name="text">Text to write.</param>
|
||||
public void WriteDebug(string text) {; }
|
||||
public void WriteDebug(string text) { }
|
||||
|
||||
/// <summary>
|
||||
/// Default implementation of WriteError - if the error record contains
|
||||
|
@ -97,38 +97,38 @@ namespace System.Management.Automation
|
|||
/// Default implementation - just discards it's arguments.
|
||||
/// </summary>
|
||||
/// <param name="progressRecord">Progress record to write.</param>
|
||||
public void WriteProgress(ProgressRecord progressRecord) {; }
|
||||
public void WriteProgress(ProgressRecord progressRecord) { }
|
||||
|
||||
/// <summary>
|
||||
/// Default implementation - just discards it's arguments.
|
||||
/// </summary>
|
||||
/// <param name="sourceId">Source ID to write for.</param>
|
||||
/// <param name="progressRecord">Record to write.</param>
|
||||
public void WriteProgress(Int64 sourceId, ProgressRecord progressRecord) {; }
|
||||
public void WriteProgress(Int64 sourceId, ProgressRecord progressRecord) { }
|
||||
|
||||
/// <summary>
|
||||
/// Default implementation - just discards it's arguments.
|
||||
/// </summary>
|
||||
/// <param name="text">Text to write.</param>
|
||||
public void WriteVerbose(string text) {; }
|
||||
public void WriteVerbose(string text) { }
|
||||
|
||||
/// <summary>
|
||||
/// Default implementation - just discards it's arguments.
|
||||
/// </summary>
|
||||
/// <param name="text">Text to write.</param>
|
||||
public void WriteWarning(string text) {; }
|
||||
public void WriteWarning(string text) { }
|
||||
|
||||
/// <summary>
|
||||
/// Default implementation - just discards it's arguments.
|
||||
/// </summary>
|
||||
/// <param name="text">Text to write.</param>
|
||||
public void WriteCommandDetail(string text) {; }
|
||||
public void WriteCommandDetail(string text) { }
|
||||
|
||||
/// <summary>
|
||||
/// Default implementation - just discards it's arguments.
|
||||
/// </summary>
|
||||
/// <param name="informationRecord">Record to write.</param>
|
||||
public void WriteInformation(InformationRecord informationRecord) {; }
|
||||
public void WriteInformation(InformationRecord informationRecord) { }
|
||||
|
||||
#endregion Write
|
||||
|
||||
|
|
|
@ -4703,7 +4703,7 @@ namespace System.Management.Automation
|
|||
}
|
||||
|
||||
availableProperties.Append("[" + p.Name + " <" + p.TypeNameOfValue + ">]");
|
||||
if (first == true)
|
||||
if (first)
|
||||
{
|
||||
first = false;
|
||||
}
|
||||
|
@ -5250,7 +5250,7 @@ namespace System.Management.Automation
|
|||
internal static Tuple<PSConverter<object>, ConversionRank> FigureIEnumerableConstructorConversion(Type fromType, Type toType)
|
||||
{
|
||||
// Win8: 653180. If toType is an Abstract type then we cannot construct it anyway. So, bailing out fast.
|
||||
if (toType.IsAbstract == true)
|
||||
if (toType.IsAbstract)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -738,7 +738,7 @@ namespace System.Management.Automation
|
|||
private void Serialize(string filename)
|
||||
{
|
||||
AnalysisCacheData fromOtherProcess = null;
|
||||
Diagnostics.Assert(_saveCacheToDisk != false, "Serialize should never be called without going through QueueSerialization which has a check");
|
||||
Diagnostics.Assert(_saveCacheToDisk, "Serialize should never be called without going through QueueSerialization which has a check");
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -1920,7 +1920,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
|
@ -1957,7 +1957,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
|
||||
// moduleName can be just a module name and it also can be a full path to psd1 from which we need to extract the module name
|
||||
string coreModuleToLoad = ModuleIntrinsics.GetModuleName(moduleSpec == null ? moduleName : moduleSpec.Name);
|
||||
|
||||
|
||||
var isModuleToLoadEngineModule = InitialSessionState.IsEngineModule(coreModuleToLoad);
|
||||
string[] noClobberModuleList = PowerShellConfig.Instance.GetWindowsPowerShellCompatibilityNoClobberModuleList();
|
||||
if (isModuleToLoadEngineModule || ((noClobberModuleList != null) && noClobberModuleList.Contains(coreModuleToLoad, StringComparer.OrdinalIgnoreCase)))
|
||||
|
|
|
@ -786,7 +786,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
}
|
||||
|
||||
// The rooted files wasn't found, so don't search anymore...
|
||||
if (found == false && wasRooted == true)
|
||||
if (found == false && wasRooted)
|
||||
return null;
|
||||
|
||||
if (searchModulePath && found == false && moduleFileFound == false)
|
||||
|
@ -3162,7 +3162,6 @@ namespace Microsoft.PowerShell.Commands
|
|||
|
||||
newManifestInfo.ExperimentalFeatures = manifestInfo.ExperimentalFeatures;
|
||||
|
||||
|
||||
// If we are in module discovery, then fix the path.
|
||||
if (ss == null)
|
||||
{
|
||||
|
|
|
@ -420,7 +420,6 @@ namespace System.Management.Automation
|
|||
return modulesMatched.OrderBy(m => m.Name).ToList();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Check if a given module info object matches a given module specification.
|
||||
/// </summary>
|
||||
|
|
|
@ -538,7 +538,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
{
|
||||
if (name == null)
|
||||
return "''";
|
||||
return ("'" + name.ToString().Replace("'", "''") + "'");
|
||||
return ("'" + name.Replace("'", "''") + "'");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -776,7 +776,6 @@ namespace System.Management.Automation
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Method collection, or the members that are actually methods.
|
||||
/// </summary>
|
||||
|
|
|
@ -1246,7 +1246,7 @@ namespace System.Management.Automation
|
|||
|
||||
// In minishell scenario, if output is redirected
|
||||
// then error should also be redirected.
|
||||
if (redirectError == false && redirectOutput == true && _isMiniShell)
|
||||
if (redirectError == false && redirectOutput && _isMiniShell)
|
||||
{
|
||||
redirectError = true;
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace System.Management.Automation
|
|||
s_psVersionTable[PSVersionInfo.PSRemotingProtocolVersionName] = RemotingConstants.ProtocolVersion;
|
||||
s_psVersionTable[PSVersionInfo.WSManStackVersionName] = GetWSManStackVersion();
|
||||
s_psVersionTable[PSPlatformName] = Environment.OSVersion.Platform.ToString();
|
||||
s_psVersionTable[PSOSName] = Runtime.InteropServices.RuntimeInformation.OSDescription.ToString();
|
||||
s_psVersionTable[PSOSName] = Runtime.InteropServices.RuntimeInformation.OSDescription;
|
||||
}
|
||||
|
||||
internal static PSVersionHashTable GetPSVersionTable()
|
||||
|
|
|
@ -434,7 +434,7 @@ namespace System.Management.Automation
|
|||
foreach (PSObject remark in remarks)
|
||||
{
|
||||
string remarkText = GetProperty<string>(remark, "text");
|
||||
exsb.Append(remarkText.ToString());
|
||||
exsb.Append(remarkText);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ namespace System.Management.Automation
|
|||
foreach (string providerPath in providerPaths)
|
||||
{
|
||||
result = ItemExists(providerInstance, providerPath, context);
|
||||
if (result == true)
|
||||
if (result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -3889,7 +3889,7 @@ namespace System.Management.Automation
|
|||
foreach (string providerPath in providerPaths)
|
||||
{
|
||||
result = HasChildItems(providerInstance, providerPath, context);
|
||||
if (result == true)
|
||||
if (result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -120,8 +120,8 @@ namespace System.Management.Automation
|
|||
|
||||
set
|
||||
{
|
||||
Dbg.Assert((value == true), "This property should never be set/reset to false");
|
||||
if (value == true)
|
||||
Dbg.Assert((value), "This property should never be set/reset to false");
|
||||
if (value)
|
||||
{
|
||||
_functionsExportedWithWildcard = value;
|
||||
}
|
||||
|
|
|
@ -1269,7 +1269,7 @@ namespace System.Management.Automation
|
|||
// An exception during initialization should remove the provider from
|
||||
// session state.
|
||||
|
||||
Providers.Remove(provider.Name.ToString());
|
||||
Providers.Remove(provider.Name);
|
||||
ProvidersCurrentWorkingDrive.Remove(provider);
|
||||
provider = null;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
|
||||
using Dbg = System.Management.Automation;
|
||||
|
||||
#pragma warning disable 1634, 1691 // Stops compiler from warning about unknown warnings
|
||||
|
|
|
@ -38,7 +38,6 @@ namespace System.Management.Automation.Runspaces
|
|||
|
||||
return s_valueFactoryCache[cacheIndex];
|
||||
|
||||
|
||||
// Local helper function to avoid creating an instance of the generated delegate helper class
|
||||
// every time 'GetValueFactoryBasedOnInitCapacity' is invoked.
|
||||
static Func<string, PSMemberInfoInternalCollection<PSMemberInfo>> CreateValueFactory(int capacity)
|
||||
|
|
|
@ -1043,7 +1043,7 @@ namespace System.Management.Automation.Runspaces
|
|||
// Concurrency check should be done under runspace lock
|
||||
lock (SyncRoot)
|
||||
{
|
||||
if (_bSessionStateProxyCallInProgress == true)
|
||||
if (_bSessionStateProxyCallInProgress)
|
||||
{
|
||||
throw PSTraceSource.NewInvalidOperationException(RunspaceStrings.NoPipelineWhenSessionStateProxyInProgress);
|
||||
}
|
||||
|
@ -1151,7 +1151,7 @@ namespace System.Management.Automation.Runspaces
|
|||
throw e;
|
||||
}
|
||||
|
||||
if (_bSessionStateProxyCallInProgress == true)
|
||||
if (_bSessionStateProxyCallInProgress)
|
||||
{
|
||||
throw PSTraceSource.NewInvalidOperationException(RunspaceStrings.AnotherSessionStateProxyInProgress);
|
||||
}
|
||||
|
|
|
@ -141,7 +141,6 @@ namespace Microsoft.PowerShell.Commands
|
|||
/// </summary>
|
||||
private long _pipelineId;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a clone of this object.
|
||||
/// </summary>
|
||||
|
@ -331,7 +330,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
if (firstId <= 1) break;
|
||||
// if entry is null , continue the loop with the next entry
|
||||
if (_buffer[GetIndexFromId(i)] == null) continue;
|
||||
if (_buffer[GetIndexFromId(i)].Cleared == true)
|
||||
if (_buffer[GetIndexFromId(i)].Cleared)
|
||||
{
|
||||
// we have to clear count entries before an id, so if an entry is null,decrement
|
||||
// first id as long as its is greater than the lowest entry in the buffer.
|
||||
|
@ -344,7 +343,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
{
|
||||
// if an entry is null after being cleared by clear-history cmdlet,
|
||||
// continue with the next entry
|
||||
if (_buffer[GetIndexFromId(i)] == null || _buffer[GetIndexFromId(i)].Cleared == true)
|
||||
if (_buffer[GetIndexFromId(i)] == null || _buffer[GetIndexFromId(i)].Cleared)
|
||||
continue;
|
||||
entriesList.Add(_buffer[GetIndexFromId(i)].Clone());
|
||||
}
|
||||
|
@ -364,7 +363,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
if (firstId >= _countEntriesAdded) break;
|
||||
// if entry is null , continue the loop with the next entry
|
||||
if (_buffer[GetIndexFromId(i)] == null) continue;
|
||||
if (_buffer[GetIndexFromId(i)].Cleared == true)
|
||||
if (_buffer[GetIndexFromId(i)].Cleared)
|
||||
{
|
||||
// we have to clear count entries before an id, so if an entry is null,increment first id
|
||||
firstId++;
|
||||
|
@ -376,7 +375,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
{
|
||||
// if an entry is null after being cleared by clear-history cmdlet,
|
||||
// continue with the next entry
|
||||
if (_buffer[GetIndexFromId(i)] == null || _buffer[GetIndexFromId(i)].Cleared == true)
|
||||
if (_buffer[GetIndexFromId(i)] == null || _buffer[GetIndexFromId(i)].Cleared)
|
||||
continue;
|
||||
entriesList.Add(_buffer[GetIndexFromId(i)].Clone());
|
||||
}
|
||||
|
@ -406,7 +405,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
{
|
||||
if (index > _countEntriesAdded) break;
|
||||
if ((index <= 0 || GetIndexFromId(index) >= _buffer.Length) ||
|
||||
(_buffer[GetIndexFromId(index)].Cleared == true))
|
||||
(_buffer[GetIndexFromId(index)].Cleared))
|
||||
{
|
||||
index++; continue;
|
||||
}
|
||||
|
@ -435,7 +434,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
|
||||
if (index < 1) break;
|
||||
if ((index <= 0 || GetIndexFromId(index) >= _buffer.Length) ||
|
||||
(_buffer[GetIndexFromId(index)].Cleared == true))
|
||||
(_buffer[GetIndexFromId(index)].Cleared))
|
||||
{ index--; continue; }
|
||||
else
|
||||
{
|
||||
|
@ -1020,7 +1019,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
{
|
||||
// Invoke-history can execute only one command. If multiple
|
||||
// ids were provided, throw exception
|
||||
if (_multipleIdProvided == true)
|
||||
if (_multipleIdProvided)
|
||||
{
|
||||
Exception ex =
|
||||
new ArgumentException
|
||||
|
@ -1717,7 +1716,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
protected override void ProcessRecord()
|
||||
{
|
||||
// case statement to identify the parameter set
|
||||
switch (ParameterSetName.ToString())
|
||||
switch (ParameterSetName)
|
||||
{
|
||||
case "IDParameter":
|
||||
ClearHistoryByID();
|
||||
|
|
|
@ -1395,7 +1395,7 @@ namespace System.Management.Automation.Runspaces
|
|||
PipelineProcessor[] copyStack;
|
||||
lock (_syncRoot)
|
||||
{
|
||||
if (_stopping == true)
|
||||
if (_stopping)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -740,7 +740,7 @@ namespace System.Management.Automation.PSTasks
|
|||
{
|
||||
item.Value.Dispose();
|
||||
}
|
||||
|
||||
|
||||
_activeRunspaces.Clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -3759,7 +3759,7 @@ namespace System.Management.Automation
|
|||
|
||||
if ((psAsyncResult == null) ||
|
||||
(psAsyncResult.OwnerId != InstanceId) ||
|
||||
(psAsyncResult.IsAssociatedWithAsyncInvoke != false))
|
||||
(psAsyncResult.IsAssociatedWithAsyncInvoke))
|
||||
{
|
||||
throw PSTraceSource.NewArgumentException(nameof(asyncResult),
|
||||
PowerShellStrings.AsyncResultNotOwned, "IAsyncResult", "BeginStop");
|
||||
|
@ -3940,7 +3940,7 @@ namespace System.Management.Automation
|
|||
(
|
||||
Runspace.DefaultRunspace.ExecutionContext,
|
||||
false,
|
||||
IsNested == true ? CommandOrigin.Internal : CommandOrigin.Runspace
|
||||
IsNested ? CommandOrigin.Internal : CommandOrigin.Runspace
|
||||
);
|
||||
|
||||
commandProcessorBase.RedirectShellErrorOutputPipe = RedirectShellErrorOutputPipe;
|
||||
|
|
|
@ -1332,7 +1332,7 @@ namespace System.Management.Automation.Runspaces.Internal
|
|||
Runspace runspaceToDestroy = null;
|
||||
lock (pool)
|
||||
{
|
||||
if (pool.Count <= 0)
|
||||
if (pool.Count == 0)
|
||||
{
|
||||
break; // break from while
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace System.Management.Automation.Runspaces
|
|||
// to add cmd to CommandCollection again (Initialize does this).. because of this
|
||||
// I am handling history here..
|
||||
Initialize(runspace, null, false, isNested);
|
||||
if (true == addToHistory)
|
||||
if (addToHistory)
|
||||
{
|
||||
// get command text for history..
|
||||
string cmdText = command.GetCommandStringForHistory();
|
||||
|
|
|
@ -2034,7 +2034,7 @@ namespace System.Management.Automation.Interpreter
|
|||
case ExpressionType.PostDecrementAssign:
|
||||
CompileReducibleExpression(expr); break;
|
||||
default: throw Assert.Unreachable;
|
||||
};
|
||||
}
|
||||
Debug.Assert(_instructions.CurrentStackDepth == startingStackDepth + (expr.Type == typeof(void) ? 0 : 1));
|
||||
}
|
||||
|
||||
|
|
|
@ -905,7 +905,6 @@ namespace System.Management.Automation
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The implementation of the PowerShell -replace operator....
|
||||
/// </summary>
|
||||
|
|
|
@ -361,7 +361,6 @@ namespace System.Management.Automation
|
|||
public SteppablePipeline GetSteppablePipeline()
|
||||
=> GetSteppablePipelineImpl(commandOrigin: CommandOrigin.Internal, args: null);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get a steppable pipeline object.
|
||||
/// </summary>
|
||||
|
|
|
@ -622,7 +622,6 @@ namespace System.Management.Automation.Language
|
|||
internal static readonly MethodInfo VariableOps_SetVariableValue =
|
||||
typeof(VariableOps).GetMethod(nameof(VariableOps.SetVariableValue), StaticFlags);
|
||||
|
||||
|
||||
internal static readonly MethodInfo Utils_IsComObject =
|
||||
typeof(Utils).GetMethod(nameof(Utils.IsComObject), StaticFlags);
|
||||
|
||||
|
|
|
@ -435,7 +435,6 @@ namespace System.Management.Automation.Language
|
|||
|
||||
public object VisitDynamicKeywordStatement(DynamicKeywordStatementAst dynamicKeywordAst) { return AutomationNull.Value; }
|
||||
|
||||
|
||||
public object VisitStatementBlock(StatementBlockAst statementBlockAst)
|
||||
{
|
||||
CheckIsConstant(statementBlockAst, "Caller to verify ast is constant");
|
||||
|
|
|
@ -349,7 +349,6 @@ namespace System.Management.Automation.Language
|
|||
// fall to the default base type
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
if (baseClass.IsSealed)
|
||||
{
|
||||
|
|
|
@ -4243,7 +4243,6 @@ namespace System.Management.Automation.Language
|
|||
return NewToken(TokenKind.LBracket);
|
||||
}
|
||||
|
||||
|
||||
if (ExperimentalFeature.IsEnabled("PSNullConditionalOperators") && c == '?')
|
||||
{
|
||||
_tokenStart = _currentIndex;
|
||||
|
|
|
@ -240,7 +240,7 @@ namespace System.Management.Automation.Internal
|
|||
{
|
||||
// We check to see if the command is needs writing (or if there is anything in the buffer)
|
||||
// before we flush it. Flushing the empty buffer causes a measurable performance degradation.
|
||||
if (_commands == null || _commands.Count <= 0 || _eventLogBuffer.Count == 0)
|
||||
if (_commands == null || _commands.Count == 0 || _eventLogBuffer.Count == 0)
|
||||
return;
|
||||
|
||||
MshLog.LogPipelineExecutionDetailEvent(_commands[0].Command.Context,
|
||||
|
|
|
@ -2463,7 +2463,7 @@ namespace System.Management.Automation
|
|||
{
|
||||
SetJobState(JobState.Failed);
|
||||
}
|
||||
else if (_stopIsCalled == true)
|
||||
else if (_stopIsCalled)
|
||||
{
|
||||
SetJobState(JobState.Stopped);
|
||||
}
|
||||
|
@ -3241,12 +3241,12 @@ namespace System.Management.Automation
|
|||
/// </summary>
|
||||
protected virtual void DoFinish()
|
||||
{
|
||||
if (_doFinishCalled == true)
|
||||
if (_doFinishCalled)
|
||||
return;
|
||||
|
||||
lock (SyncObject)
|
||||
{
|
||||
if (_doFinishCalled == true)
|
||||
if (_doFinishCalled)
|
||||
return;
|
||||
|
||||
_doFinishCalled = true;
|
||||
|
@ -4387,12 +4387,12 @@ namespace System.Management.Automation
|
|||
/// </summary>
|
||||
protected override void DoFinish()
|
||||
{
|
||||
if (_doFinishCalled == true)
|
||||
if (_doFinishCalled)
|
||||
return;
|
||||
|
||||
lock (SyncObject)
|
||||
{
|
||||
if (_doFinishCalled == true)
|
||||
if (_doFinishCalled)
|
||||
return;
|
||||
|
||||
_doFinishCalled = true;
|
||||
|
|
|
@ -545,7 +545,7 @@ namespace System.Management.Automation
|
|||
catch (ObjectDisposedException)
|
||||
{
|
||||
throw PSTraceSource.NewObjectDisposedException("Pipeline");
|
||||
};
|
||||
}
|
||||
|
||||
asyncresult.AsyncWaitHandle.WaitOne();
|
||||
}
|
||||
|
|
|
@ -1190,7 +1190,7 @@ namespace System.Management.Automation
|
|||
// Concurrency check should be done under runspace lock
|
||||
lock (_syncRoot)
|
||||
{
|
||||
if (_bSessionStateProxyCallInProgress == true)
|
||||
if (_bSessionStateProxyCallInProgress)
|
||||
{
|
||||
throw PSTraceSource.NewInvalidOperationException(RunspaceStrings.NoPipelineWhenSessionStateProxyInProgress);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ namespace System.Management.Automation.Remoting
|
|||
{
|
||||
#region Strings
|
||||
|
||||
|
||||
internal const string NamedPipeNamePrefix = "PSHost.";
|
||||
#if UNIX
|
||||
internal const string DefaultAppDomainName = "None";
|
||||
|
|
|
@ -2454,7 +2454,7 @@ namespace System.Management.Automation.Runspaces
|
|||
|
||||
if ((ex != null) ||
|
||||
(sshProcess == null) ||
|
||||
(sshProcess.HasExited == true))
|
||||
(sshProcess.HasExited))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
StringUtil.Format(RemotingErrorIdStrings.CannotStartSSHClient, (ex != null) ? ex.Message : string.Empty),
|
||||
|
@ -2552,8 +2552,8 @@ namespace System.Management.Automation.Runspaces
|
|||
{
|
||||
// Create process start command line with filename and argument list.
|
||||
var cmdLine = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
@"""{0}"" {1}",
|
||||
CultureInfo.InvariantCulture,
|
||||
@"""{0}"" {1}",
|
||||
startInfo.FileName,
|
||||
string.Join(' ', startInfo.ArgumentList));
|
||||
|
||||
|
|
|
@ -818,7 +818,7 @@ namespace System.Management.Automation.Remoting.Client
|
|||
{
|
||||
// If queue is empty or if queue servicing is suspended
|
||||
// then break out of loop.
|
||||
if (_callbackNotificationQueue.Count <= 0 || _suspendQueueServicing)
|
||||
if (_callbackNotificationQueue.Count == 0 || _suspendQueueServicing)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ namespace System.Management.Automation.Remoting
|
|||
case CONFIGFILEPATH:
|
||||
{
|
||||
AssertValueNotAssigned(CONFIGFILEPATH, ConfigFilePath);
|
||||
ConfigFilePath = optionValue.ToString();
|
||||
ConfigFilePath = optionValue;
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -763,7 +763,7 @@ namespace System.Management.Automation.Remoting
|
|||
Dbg.Assert(registryKey != null, "Caller should validate the registryKey parameter");
|
||||
|
||||
object value = registryKey.GetValue(name);
|
||||
if (value == null && mandatory == true)
|
||||
if (value == null && mandatory)
|
||||
{
|
||||
s_tracer.TraceError("Mandatory property {0} not specified for registry key {1}",
|
||||
name, registryKey.Name);
|
||||
|
@ -771,7 +771,7 @@ namespace System.Management.Automation.Remoting
|
|||
}
|
||||
|
||||
string s = value as string;
|
||||
if (string.IsNullOrEmpty(s) && mandatory == true)
|
||||
if (string.IsNullOrEmpty(s) && mandatory)
|
||||
{
|
||||
s_tracer.TraceError("Value is null or empty for mandatory property {0} in {1}",
|
||||
name, registryKey.Name);
|
||||
|
@ -2392,7 +2392,7 @@ namespace System.Management.Automation.Remoting
|
|||
// Process User Drive
|
||||
if (_configHash.ContainsKey(ConfigFileConstants.MountUserDrive))
|
||||
{
|
||||
if (Convert.ToBoolean(_configHash[ConfigFileConstants.MountUserDrive], CultureInfo.InvariantCulture) == true)
|
||||
if (Convert.ToBoolean(_configHash[ConfigFileConstants.MountUserDrive], CultureInfo.InvariantCulture))
|
||||
{
|
||||
iss.UserDriveEnabled = true;
|
||||
iss.UserDriveUserName = (senderInfo != null) ? senderInfo.UserInfo.Identity.Name : null;
|
||||
|
|
|
@ -544,7 +544,7 @@ namespace System.Management.Automation.Remoting.Client
|
|||
bool shouldRaiseCloseCompleted = false;
|
||||
lock (syncObject)
|
||||
{
|
||||
if (isClosed == true)
|
||||
if (isClosed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -2167,7 +2167,7 @@ namespace System.Management.Automation.Remoting.Client
|
|||
{
|
||||
lock (syncObject)
|
||||
{
|
||||
if (isClosed == true)
|
||||
if (isClosed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ namespace System.Management.Automation.Remoting
|
|||
|
||||
lock (_syncObject)
|
||||
{
|
||||
if (true == isClosed)
|
||||
if (isClosed)
|
||||
{
|
||||
WSManPluginInstance.ReportWSManOperationComplete(requestDetails, lastErrorReported);
|
||||
return;
|
||||
|
@ -196,7 +196,7 @@ namespace System.Management.Automation.Remoting
|
|||
WSManNativeApi.WSManStreamIDSet_UnToMan streamSet,
|
||||
WSManPluginOperationShutdownContext ctxtToReport)
|
||||
{
|
||||
if (true == isClosed)
|
||||
if (isClosed)
|
||||
{
|
||||
WSManPluginInstance.ReportWSManOperationComplete(requestDetails, lastErrorReported);
|
||||
return false;
|
||||
|
@ -241,7 +241,7 @@ namespace System.Management.Automation.Remoting
|
|||
|
||||
lock (_syncObject)
|
||||
{
|
||||
if (true == isClosed)
|
||||
if (isClosed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -688,7 +688,7 @@ namespace System.Management.Automation.Remoting
|
|||
// let command sessions to close.
|
||||
lock (shellSyncObject)
|
||||
{
|
||||
if (true == isClosed)
|
||||
if (isClosed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -788,7 +788,7 @@ namespace System.Management.Automation.Remoting
|
|||
// let command sessions to close.
|
||||
lock (cmdSyncObject)
|
||||
{
|
||||
if (true == isClosed)
|
||||
if (isClosed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ namespace System.Management.Automation.Remoting
|
|||
/// </summary>
|
||||
internal override void ReportExecutionStatusAsRunning()
|
||||
{
|
||||
if (true == _isClosed)
|
||||
if (_isClosed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ namespace System.Management.Automation.Remoting
|
|||
bool reportAsPending,
|
||||
bool reportAsDataBoundary)
|
||||
{
|
||||
if (true == _isClosed)
|
||||
if (_isClosed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1191,7 +1191,7 @@ namespace System.Management.Automation.Remoting.Client
|
|||
// let other threads release the lock before we clean up the resources.
|
||||
lock (syncObject)
|
||||
{
|
||||
if (isClosed == true)
|
||||
if (isClosed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -3105,7 +3105,7 @@ namespace System.Management.Automation.Remoting.Client
|
|||
{
|
||||
lock (syncObject)
|
||||
{
|
||||
if (isClosed == true)
|
||||
if (isClosed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -3148,7 +3148,7 @@ namespace System.Management.Automation.Remoting.Client
|
|||
// then let other threads release the lock before we cleaning up the resources.
|
||||
lock (syncObject)
|
||||
{
|
||||
if (isClosed == true)
|
||||
if (isClosed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -583,7 +583,7 @@ namespace System.Management.Automation
|
|||
=> ast is CommandAst cmdAst && cmdAst.DefiningKeyword != null;
|
||||
|
||||
private static bool IsUsingTypes(Ast ast)
|
||||
=> ast is UsingStatementAst cmdAst && cmdAst.IsUsingModuleOrAssembly() == true;
|
||||
=> ast is UsingStatementAst cmdAst && cmdAst.IsUsingModuleOrAssembly();
|
||||
|
||||
internal static void CacheScriptBlock(ScriptBlock scriptBlock, string fileName, string fileContents)
|
||||
{
|
||||
|
@ -723,7 +723,6 @@ namespace System.Management.Automation
|
|||
args);
|
||||
}
|
||||
|
||||
|
||||
internal SteppablePipeline GetSteppablePipelineImpl(CommandOrigin commandOrigin, object[] args)
|
||||
{
|
||||
var pipelineAst = GetSimplePipeline(
|
||||
|
@ -983,10 +982,10 @@ namespace System.Management.Automation
|
|||
|
||||
// Validate at the arguments are consistent. The only public API that gets you here never sets createLocalScope to false...
|
||||
Diagnostics.Assert(
|
||||
createLocalScope == true || functionsToDefine == null,
|
||||
createLocalScope || functionsToDefine == null,
|
||||
"When calling ScriptBlock.InvokeWithContext(), if 'functionsToDefine' != null then 'createLocalScope' must be true");
|
||||
Diagnostics.Assert(
|
||||
createLocalScope == true || variablesToDefine == null,
|
||||
createLocalScope || variablesToDefine == null,
|
||||
"When calling ScriptBlock.InvokeWithContext(), if 'variablesToDefine' != null then 'createLocalScope' must be true");
|
||||
|
||||
if (args == null)
|
||||
|
|
|
@ -156,7 +156,7 @@ namespace System.Management.Automation
|
|||
/// <param name="errorRecord"></param>
|
||||
internal void TraceError(ErrorRecord errorRecord)
|
||||
{
|
||||
if (_traceFrames.Count <= 0)
|
||||
if (_traceFrames.Count == 0)
|
||||
return;
|
||||
|
||||
TraceFrame traceFrame = _traceFrames[_traceFrames.Count - 1];
|
||||
|
@ -171,7 +171,7 @@ namespace System.Management.Automation
|
|||
/// <param name="errorRecords"></param>
|
||||
internal void TraceErrors(Collection<ErrorRecord> errorRecords)
|
||||
{
|
||||
if (_traceFrames.Count <= 0)
|
||||
if (_traceFrames.Count == 0)
|
||||
return;
|
||||
|
||||
TraceFrame traceFrame = _traceFrames[_traceFrames.Count - 1];
|
||||
|
@ -181,7 +181,7 @@ namespace System.Management.Automation
|
|||
|
||||
internal void PopFrame(TraceFrame traceFrame)
|
||||
{
|
||||
if (_traceFrames.Count <= 0)
|
||||
if (_traceFrames.Count == 0)
|
||||
return;
|
||||
|
||||
TraceFrame lastFrame = _traceFrames[_traceFrames.Count - 1];
|
||||
|
|
|
@ -203,7 +203,7 @@ namespace System.Management.Automation
|
|||
|
||||
if (this.FullHelp.Properties["Name"] == null)
|
||||
{
|
||||
this.FullHelp.Properties.Add(new PSNoteProperty("Name", this.Name.ToString()));
|
||||
this.FullHelp.Properties.Add(new PSNoteProperty("Name", this.Name));
|
||||
}
|
||||
|
||||
if (this.FullHelp.Properties["Category"] == null)
|
||||
|
@ -213,7 +213,7 @@ namespace System.Management.Automation
|
|||
|
||||
if (this.FullHelp.Properties["Synopsis"] == null)
|
||||
{
|
||||
this.FullHelp.Properties.Add(new PSNoteProperty("Synopsis", this.Synopsis.ToString()));
|
||||
this.FullHelp.Properties.Add(new PSNoteProperty("Synopsis", this.Synopsis));
|
||||
}
|
||||
|
||||
if (this.FullHelp.Properties["Component"] == null)
|
||||
|
|
|
@ -192,7 +192,7 @@ namespace System.Management.Automation
|
|||
/// </summary>
|
||||
internal static PSPropertyInfo GetPropertyInfo(PSObject psObject, string[] path)
|
||||
{
|
||||
if (path.Length <= 0)
|
||||
if (path.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ namespace System.Management.Automation
|
|||
/// </summary>
|
||||
internal static void EnsurePropertyInfoPathExists(PSObject psObject, string[] path)
|
||||
{
|
||||
if (path.Length <= 0)
|
||||
if (path.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -2398,7 +2398,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
if (itemType == ItemType.HardLink)
|
||||
{
|
||||
// Hard links can only be to files, not directories.
|
||||
if (isDirectory == true)
|
||||
if (isDirectory)
|
||||
{
|
||||
string message = StringUtil.Format(FileSystemProviderStrings.ItemNotFile, strTargetPath);
|
||||
WriteError(new ErrorRecord(new InvalidOperationException(message), "ItemNotFile", ErrorCategory.InvalidOperation, strTargetPath));
|
||||
|
|
|
@ -3062,7 +3062,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
if (
|
||||
expandAll ||
|
||||
((Context.SuppressWildcardExpansion == false) && (valueNameMatcher.IsMatch(valueNameToMatch))) ||
|
||||
((Context.SuppressWildcardExpansion == true) && (string.Equals(valueNameToMatch, requestedValueName, StringComparison.OrdinalIgnoreCase))))
|
||||
((Context.SuppressWildcardExpansion) && (string.Equals(valueNameToMatch, requestedValueName, StringComparison.OrdinalIgnoreCase))))
|
||||
{
|
||||
if (string.IsNullOrEmpty(valueNameToMatch))
|
||||
{
|
||||
|
@ -3833,7 +3833,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
{
|
||||
value = 0;
|
||||
}
|
||||
}; break;
|
||||
} break;
|
||||
|
||||
case RegistryValueKind.ExpandString:
|
||||
value = (value != null)
|
||||
|
@ -3870,7 +3870,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
{
|
||||
value = 0;
|
||||
}
|
||||
}; break;
|
||||
} break;
|
||||
|
||||
case RegistryValueKind.String:
|
||||
value = (value != null)
|
||||
|
|
|
@ -749,7 +749,7 @@ namespace System.Management.Automation
|
|||
catalog.CatalogItems = catalogHashes;
|
||||
catalog.PathItems = fileHashes;
|
||||
bool status = CompareDictionaries(catalogHashes, fileHashes);
|
||||
if (status == true)
|
||||
if (status)
|
||||
{
|
||||
catalog.Status = CatalogValidationStatus.Valid;
|
||||
}
|
||||
|
|
|
@ -383,7 +383,7 @@ namespace Microsoft.PowerShell
|
|||
{
|
||||
TrustPublisher(signature);
|
||||
policyCheckPassed = true;
|
||||
}; break;
|
||||
} break;
|
||||
case RunPromptDecision.DoNotRun:
|
||||
policyCheckPassed = false;
|
||||
reasonMessage = StringUtil.Format(Authenticode.Reason_DoNotRun, path);
|
||||
|
@ -395,7 +395,7 @@ namespace Microsoft.PowerShell
|
|||
reasonMessage = StringUtil.Format(Authenticode.Reason_NeverRun, path);
|
||||
reason = new UnauthorizedAccessException(reasonMessage);
|
||||
policyCheckPassed = false;
|
||||
}; break;
|
||||
} break;
|
||||
}
|
||||
|
||||
return policyCheckPassed;
|
||||
|
|
|
@ -816,7 +816,7 @@ namespace System.Management.Automation
|
|||
Dbg.Assert(mshsnapinKey != null, "Caller should validate the parameter");
|
||||
|
||||
object value = mshsnapinKey.GetValue(name);
|
||||
if (value == null && mandatory == true)
|
||||
if (value == null && mandatory)
|
||||
{
|
||||
s_mshsnapinTracer.TraceError("Mandatory property {0} not specified for registry key {1}",
|
||||
name, mshsnapinKey.Name);
|
||||
|
@ -824,7 +824,7 @@ namespace System.Management.Automation
|
|||
}
|
||||
|
||||
string s = value as string;
|
||||
if (string.IsNullOrEmpty(s) && mandatory == true)
|
||||
if (string.IsNullOrEmpty(s) && mandatory)
|
||||
{
|
||||
s_mshsnapinTracer.TraceError("Value is null or empty for mandatory property {0} in {1}",
|
||||
name, mshsnapinKey.Name);
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace System.Management.Automation
|
|||
/// <summary>
|
||||
/// Constructs a CommandNotFoundException.
|
||||
/// </summary>
|
||||
public CommandNotFoundException() : base() {; }
|
||||
public CommandNotFoundException() : base() { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a CommandNotFoundException.
|
||||
|
@ -58,7 +58,7 @@ namespace System.Management.Automation
|
|||
/// <param name="message">
|
||||
/// The message used in the exception.
|
||||
/// </param>
|
||||
public CommandNotFoundException(string message) : base(message) {; }
|
||||
public CommandNotFoundException(string message) : base(message) { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a CommandNotFoundException.
|
||||
|
@ -69,7 +69,7 @@ namespace System.Management.Automation
|
|||
/// <param name="innerException">
|
||||
/// An exception that led to this exception.
|
||||
/// </param>
|
||||
public CommandNotFoundException(string message, Exception innerException) : base(message, innerException) {; }
|
||||
public CommandNotFoundException(string message, Exception innerException) : base(message, innerException) { }
|
||||
|
||||
#region Serialization
|
||||
/// <summary>
|
||||
|
@ -339,7 +339,7 @@ namespace System.Management.Automation
|
|||
/// <summary>
|
||||
/// Constructs an PSVersionNotCompatibleException.
|
||||
/// </summary>
|
||||
public ScriptRequiresException() : base() {; }
|
||||
public ScriptRequiresException() : base() { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs an PSVersionNotCompatibleException.
|
||||
|
@ -347,7 +347,7 @@ namespace System.Management.Automation
|
|||
/// <param name="message">
|
||||
/// The message used in the exception.
|
||||
/// </param>
|
||||
public ScriptRequiresException(string message) : base(message) {; }
|
||||
public ScriptRequiresException(string message) : base(message) { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs an PSVersionNotCompatibleException.
|
||||
|
@ -358,7 +358,7 @@ namespace System.Management.Automation
|
|||
/// <param name="innerException">
|
||||
/// The exception that led to this exception.
|
||||
/// </param>
|
||||
public ScriptRequiresException(string message, Exception innerException) : base(message, innerException) {; }
|
||||
public ScriptRequiresException(string message, Exception innerException) : base(message, innerException) { }
|
||||
|
||||
#region Serialization
|
||||
/// <summary>
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace System.Management.Automation.Internal
|
|||
/// <summary>
|
||||
/// The blob version is fixed.
|
||||
/// </summary>
|
||||
public const uint CUR_BLOB_VERSION = 0x00000002;
|
||||
public const uint CUR_BLOB_VERSION = 0x00000002;
|
||||
|
||||
/// <summary>
|
||||
/// RSA Key.
|
||||
|
@ -74,10 +74,10 @@ namespace System.Management.Automation.Internal
|
|||
|
||||
private static byte[] GetBytesLE(int val)
|
||||
{
|
||||
return new [] {
|
||||
(byte)(val & 0xff),
|
||||
(byte)((val >> 8) & 0xff),
|
||||
(byte)((val >> 16) & 0xff),
|
||||
return new [] {
|
||||
(byte)(val & 0xff),
|
||||
(byte)((val >> 8) & 0xff),
|
||||
(byte)((val >> 16) & 0xff),
|
||||
(byte)((val >> 24) & 0xff)
|
||||
};
|
||||
}
|
||||
|
@ -90,12 +90,12 @@ namespace System.Management.Automation.Internal
|
|||
return reverseData;
|
||||
}
|
||||
|
||||
internal static RSA FromCapiPublicKeyBlob(byte[] blob)
|
||||
internal static RSA FromCapiPublicKeyBlob(byte[] blob)
|
||||
{
|
||||
return FromCapiPublicKeyBlob(blob, 0);
|
||||
}
|
||||
|
||||
private static RSA FromCapiPublicKeyBlob(byte[] blob, int offset)
|
||||
private static RSA FromCapiPublicKeyBlob(byte[] blob, int offset)
|
||||
{
|
||||
if (blob == null)
|
||||
{
|
||||
|
@ -109,13 +109,13 @@ namespace System.Management.Automation.Internal
|
|||
|
||||
var rsap = GetParametersFromCapiPublicKeyBlob(blob, offset);
|
||||
|
||||
try
|
||||
try
|
||||
{
|
||||
RSA rsa = RSA.Create();
|
||||
rsa.ImportParameters(rsap);
|
||||
return rsa;
|
||||
}
|
||||
catch (Exception ex)
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new CryptographicException(SecuritySupportStrings.CannotImportPublicKey, ex);
|
||||
}
|
||||
|
@ -138,14 +138,14 @@ namespace System.Management.Automation.Internal
|
|||
throw new ArgumentException(SecuritySupportStrings.InvalidPublicKey);
|
||||
}
|
||||
|
||||
try
|
||||
try
|
||||
{
|
||||
if ((blob[offset] != PUBLICKEYBLOB) || // PUBLICKEYBLOB (0x06)
|
||||
(blob[offset + 1] != CUR_BLOB_VERSION) || // Version (0x02)
|
||||
(blob[offset + 2] != 0x00) || // Reserved (word)
|
||||
(blob[offset + 3] != 0x00) ||
|
||||
(ToUInt32LE(blob, offset + 8) != 0x31415352)) // DWORD magic = RSA1
|
||||
{
|
||||
{
|
||||
throw new CryptographicException(SecuritySupportStrings.InvalidPublicKey);
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ namespace System.Management.Automation.Internal
|
|||
rsap.Exponent[0] = blob[offset + 18];
|
||||
rsap.Exponent[1] = blob[offset + 17];
|
||||
rsap.Exponent[2] = blob[offset + 16];
|
||||
|
||||
|
||||
int pos = offset + 20;
|
||||
int byteLen = (bitLen >> 3);
|
||||
rsap.Modulus = new byte[byteLen];
|
||||
|
@ -166,14 +166,14 @@ namespace System.Management.Automation.Internal
|
|||
Array.Reverse(rsap.Modulus);
|
||||
|
||||
return rsap;
|
||||
}
|
||||
catch (Exception ex)
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new CryptographicException(SecuritySupportStrings.InvalidPublicKey, ex);
|
||||
}
|
||||
}
|
||||
|
||||
internal static byte[] ToCapiPublicKeyBlob(RSA rsa)
|
||||
internal static byte[] ToCapiPublicKeyBlob(RSA rsa)
|
||||
{
|
||||
if (rsa == null)
|
||||
{
|
||||
|
@ -381,7 +381,7 @@ namespace System.Management.Automation.Internal
|
|||
|
||||
// this flag indicates that this class has a key imported from the
|
||||
// remote end and so can be used for encryption
|
||||
private bool _canEncrypt;
|
||||
private bool _canEncrypt;
|
||||
|
||||
// bool indicating if session key was generated before
|
||||
private bool _sessionKeyGenerated = false;
|
||||
|
@ -439,7 +439,7 @@ namespace System.Management.Automation.Internal
|
|||
{
|
||||
// Aes object gens key automatically on construction, so this is somewhat redundant,
|
||||
// but at least the actionable key will not be in-memory until it's requested fwiw.
|
||||
_aes.GenerateKey();
|
||||
_aes.GenerateKey();
|
||||
_sessionKeyGenerated = true;
|
||||
_canEncrypt = true; // we can encrypt and decrypt once session key is available
|
||||
}
|
||||
|
@ -541,7 +541,7 @@ namespace System.Management.Automation.Internal
|
|||
}
|
||||
|
||||
return targetStream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -21,7 +21,6 @@ namespace System.Management.Automation
|
|||
return GetDamerauLevenshteinDistance(string1, string2) <= MinimumDistance;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Compute the case-insensitive distance between two strings.
|
||||
/// Based off https://www.csharpstar.com/csharp-string-distance-algorithm/.
|
||||
|
@ -38,8 +37,8 @@ namespace System.Management.Automation
|
|||
|
||||
int[,] matrix = new int[bounds.Height, bounds.Width];
|
||||
|
||||
for (int height = 0; height < bounds.Height; height++) { matrix[height, 0] = height; };
|
||||
for (int width = 0; width < bounds.Width; width++) { matrix[0, width] = width; };
|
||||
for (int height = 0; height < bounds.Height; height++) { matrix[height, 0] = height; }
|
||||
for (int width = 0; width < bounds.Width; width++) { matrix[0, width] = width; }
|
||||
|
||||
for (int height = 1; height < bounds.Height; height++)
|
||||
{
|
||||
|
|
|
@ -346,7 +346,7 @@ namespace System.Management.Automation
|
|||
/// <remarks>
|
||||
/// DO NOT USE!!!
|
||||
/// </remarks>
|
||||
public ParameterBindingException() : base() {; }
|
||||
public ParameterBindingException() : base() { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructors a ParameterBindingException.
|
||||
|
|
Loading…
Reference in a new issue