Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void ProcessOutParameter(CimMethodResult methodResult, MethodParameter m
{
Dbg.Assert(methodResult != null, "Caller should verify methodResult != null");
Dbg.Assert(methodParameter != null, "Caller should verify methodParameter != null");
Dbg.Assert(0 != (methodParameter.Bindings & (MethodParameterBindings.Out | MethodParameterBindings.Error)), "Caller should verify that this is an out parameter");
Dbg.Assert((methodParameter.Bindings & (MethodParameterBindings.Out | MethodParameterBindings.Error)) != 0, "Caller should verify that this is an out parameter");
Dbg.Assert(cmdletOutput != null, "Caller should verify cmdletOutput != null");

Dbg.Assert(this.MethodSubject != null, "MethodSubject property should be initialized before starting main job processing");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ internal IEnumerable<MethodParameter> GetMethodOutputParameters()
}

var outParameters = allParameters_plus_returnValue
.Where(p => (0 != (p.Bindings & (MethodParameterBindings.Out | MethodParameterBindings.Error))));
.Where(p => ((p.Bindings & (MethodParameterBindings.Out | MethodParameterBindings.Error)) != 0));

return outParameters;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2536,7 +2536,7 @@ protected override void ProcessRecord()
try
{
resolvedPSPaths = SessionState.Path.GetResolvedPSPathFromPSPath(path, currentContext);
if (true == SuppressWildcardExpansion && 0 == resolvedPSPaths.Count)
if (SuppressWildcardExpansion == true && resolvedPSPaths.Count == 0)
{
ItemNotFoundException pathNotFound =
new ItemNotFoundException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private static int ProcessComparison(Process x, Process y)
SafeGetProcessName(x),
SafeGetProcessName(y),
StringComparison.OrdinalIgnoreCase);
if (0 != diff)
if (diff != 0)
return diff;
return SafeGetProcessId(x) - SafeGetProcessId(y);
}
Expand Down Expand Up @@ -943,7 +943,7 @@ public void Dispose()
// Handle Exited event and display process information.
private void myProcess_Exited(object sender, System.EventArgs e)
{
if (0 == System.Threading.Interlocked.Decrement(ref _numberOfProcessesToWaitFor))
if (System.Threading.Interlocked.Decrement(ref _numberOfProcessesToWaitFor) == 0)
{
if (_waitHandle != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ protected override void ProcessRecord()
{
// lookup the time zone name and make sure we have one (and only one) match
TimeZoneInfo[] timeZones = TimeZoneHelper.LookupSystemTimeZoneInfoByName(Name);
if (0 == timeZones.Length)
if (timeZones.Length == 0)
{
string message = string.Format(CultureInfo.InvariantCulture,
TimeZoneResources.TimeZoneNameNotFound, Name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private void Process(OrderByPropertyEntry differenceEntry)
// 2005/07/19 Switched order of referenceEntry and differenceEntry
// so that we cast differenceEntry to the type of referenceEntry.
if (referenceEntry != null && differenceEntry != null &&
0 == _comparer.Compare(referenceEntry, differenceEntry))
_comparer.Compare(referenceEntry, differenceEntry) == 0)
{
EmitMatch(referenceEntry);
return;
Expand Down Expand Up @@ -284,7 +284,7 @@ private OrderByPropertyEntry MatchAndRemove(
{
OrderByPropertyEntry listEntry = list[i];
Diagnostics.Assert(listEntry != null, "null listEntry " + i);
if (0 == _comparer.Compare(match, listEntry))
if (_comparer.Compare(match, listEntry) == 0)
{
list.RemoveAt(i);
return listEntry;
Expand Down Expand Up @@ -325,7 +325,7 @@ private void Emit(OrderByPropertyEntry entry, string sideIndicator)
else
{
mshobj = new PSObject();
if (Property == null || 0 == Property.Length)
if (Property == null || Property.Length == 0)
{
PSNoteProperty inputNote = new PSNoteProperty(
InputObjectPropertyName, entry.inputObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected override void ProcessRecord()
true); // case-sensitive
}

isUnique = (0 != _comparer.Compare(InputObject, _lastObject));
isUnique = (_comparer.Compare(InputObject, _lastObject) != 0);
}

if (isUnique)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ internal virtual void PrepareSession()
// supplying a credential overrides the UseDefaultCredentials setting
WebSession.UseDefaultCredentials = false;
}
else if ((Credential != null || null != Token) && Authentication != WebAuthenticationType.None)
else if ((Credential != null || Token != null) && Authentication != WebAuthenticationType.None)
{
ProcessAuthentication();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1703,7 +1703,7 @@ private void DoDeleteKey(IntPtr pProvInfo)
ThrowErrorRemoting(stat);
}

if (0 != (cngKeyFlag & (uint)Security.NativeMethods.NCryptDeletKeyFlag.NCRYPT_SILENT_FLAG))
if ((cngKeyFlag & (uint)Security.NativeMethods.NCryptDeletKeyFlag.NCRYPT_SILENT_FLAG) != 0)
{
unsafe
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ internal bool IsObjectApplicable(Collection<string> typeNames)
// we were unable to find a best match so far..try
// to get rid of Deserialization prefix and see if a
// match can be found.
if (false == result)
if (result == false)
{
Collection<string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
if (typesWithoutPrefix != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ internal sealed override bool Read()
try
{
// Process the input pipeline object
if (false == ProcessInputPipelineObject(inputObject))
if (ProcessInputPipelineObject(inputObject) == false)
{
// The input object was not bound to any parameters of the cmdlet.
// Write a non-terminating error and continue with the next input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ private bool BlockMethodInLanguageMode(object inputObject)
internal static ErrorRecord GenerateNameParameterError(string paraName, string resourceString, string errorId, object target, params object[] args)
{
string message;
if (args == null || 0 == args.Length)
if (args == null || args.Length == 0)
{
// Don't format in case the string contains literal curly braces
message = resourceString;
Expand Down
40 changes: 20 additions & 20 deletions src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ private Hashtable LoadModuleManifestData(
}
catch (RuntimeException pe)
{
if (0 != (manifestProcessingFlags & ManifestProcessingFlags.WriteErrors))
if ((manifestProcessingFlags & ManifestProcessingFlags.WriteErrors) != 0)
{
string message = StringUtil.Format(Modules.InvalidModuleManifest, scriptInfo.Path, pe.Message);
MissingMemberException mm = new MissingMemberException(message);
Expand Down Expand Up @@ -483,8 +483,8 @@ internal Hashtable LoadModuleManifestData(
{
string message;

var importingModule = 0 != (manifestProcessingFlags & ManifestProcessingFlags.LoadElements);
var writingErrors = 0 != (manifestProcessingFlags & ManifestProcessingFlags.WriteErrors);
var importingModule = (manifestProcessingFlags & ManifestProcessingFlags.LoadElements) != 0;
var writingErrors = (manifestProcessingFlags & ManifestProcessingFlags.WriteErrors) != 0;

// Load the data file(s) to get the module info...
try
Expand Down Expand Up @@ -556,7 +556,7 @@ internal Hashtable LoadModuleManifestData(
if (validMembers != null && !ValidateManifestHash(data, validMembers, moduleManifestPath, manifestProcessingFlags))
{
containedErrors = true;
if (0 != (manifestProcessingFlags & ManifestProcessingFlags.NullOnFirstError))
if ((manifestProcessingFlags & ManifestProcessingFlags.NullOnFirstError) != 0)
return null;
}

Expand Down Expand Up @@ -602,7 +602,7 @@ private bool ValidateManifestHash(
result = false;
string message = null;

if (0 != (manifestProcessingFlags & ManifestProcessingFlags.WriteErrors))
if ((manifestProcessingFlags & ManifestProcessingFlags.WriteErrors) != 0)
{
// Check for PowerShell Version before checking other keys
// If a PowerShellVersion exists and does not match the requirements, then the error is InsufficientPowerShellVersion
Expand Down Expand Up @@ -1527,7 +1527,7 @@ internal PSModuleInfo LoadModuleManifest(
!Context.ModuleBeingProcessed.Equals(Context.PreviousModuleProcessed,
StringComparison.OrdinalIgnoreCase)))
{
if (0 != (manifestProcessingFlags & ManifestProcessingFlags.WriteWarnings))
if ((manifestProcessingFlags & ManifestProcessingFlags.WriteWarnings) != 0)
{
WriteWarning(Modules.ModuleToProcessFieldDeprecated);
}
Expand Down Expand Up @@ -1779,7 +1779,7 @@ internal PSModuleInfo LoadModuleManifest(
containedErrors = true;
// Ignore errors related to HostVersion as per the ManifestProcessingFlags
// doing this at this place because we have to set "containedErrors"
if ((0 == (manifestProcessingFlags & ManifestProcessingFlags.IgnoreHostNameAndHostVersion)) &&
if (((manifestProcessingFlags & ManifestProcessingFlags.IgnoreHostNameAndHostVersion) == 0) &&
bailOnFirstError)
return null;
}
Expand All @@ -1791,7 +1791,7 @@ internal PSModuleInfo LoadModuleManifest(
containedErrors = true;
// Ignore errors related to HostVersion as per the ManifestProcessingFlags
// doing this at this place because we have to set "containedErrors"
if (0 == (manifestProcessingFlags & ManifestProcessingFlags.IgnoreHostNameAndHostVersion))
if ((manifestProcessingFlags & ManifestProcessingFlags.IgnoreHostNameAndHostVersion) == 0)
{
if (writingErrors)
{
Expand All @@ -1817,7 +1817,7 @@ internal PSModuleInfo LoadModuleManifest(
containedErrors = true;
// Ignore errors related to HostVersion as per the ManifestProcessingFlags
// doing this at this place because we have to set "containedErrors"
if ((0 == (manifestProcessingFlags & ManifestProcessingFlags.IgnoreHostNameAndHostVersion)) &&
if (((manifestProcessingFlags & ManifestProcessingFlags.IgnoreHostNameAndHostVersion) == 0) &&
bailOnFirstError)
return null;
}
Expand All @@ -1829,7 +1829,7 @@ internal PSModuleInfo LoadModuleManifest(
containedErrors = true;
// Ignore errors related to HostVersion as per the ManifestProcessingFlags
// doing this at this place because we have to set "containedErrors"
if (0 == (manifestProcessingFlags & ManifestProcessingFlags.IgnoreHostNameAndHostVersion))
if ((manifestProcessingFlags & ManifestProcessingFlags.IgnoreHostNameAndHostVersion) == 0)
{
if (writingErrors)
{
Expand Down Expand Up @@ -3030,8 +3030,8 @@ internal PSModuleInfo LoadModuleManifest(
ss: ss,
options: options,
manifestProcessingFlags: manifestProcessingFlags,
loadTypesFiles: (exportedTypeFiles == null || 0 == exportedTypeFiles.Count), // If types files already loaded, don't load snapin files
loadFormatFiles: (exportedFormatFiles == null || 0 == exportedFormatFiles.Count), // if format files already loaded, don't load snapin files
loadTypesFiles: (exportedTypeFiles == null || exportedTypeFiles.Count == 0), // If types files already loaded, don't load snapin files
loadFormatFiles: (exportedFormatFiles == null || exportedFormatFiles.Count == 0), // if format files already loaded, don't load snapin files
privateData: privateData,
found: out found,
shortModuleName: null,
Expand Down Expand Up @@ -3646,7 +3646,7 @@ private static void WriteInvalidManifestMemberError(
Exception e,
ManifestProcessingFlags manifestProcessingFlags)
{
if (0 != (manifestProcessingFlags & ManifestProcessingFlags.WriteErrors))
if ((manifestProcessingFlags & ManifestProcessingFlags.WriteErrors) != 0)
{
ErrorRecord er = GenerateInvalidModuleMemberErrorRecord(manifestElement, moduleManifestPath, e);
cmdlet.WriteError(er);
Expand Down Expand Up @@ -3750,7 +3750,7 @@ internal static PSModuleInfo LoadRequiredModule(ExecutionContext context,
ManifestProcessingFlags manifestProcessingFlags,
out ErrorRecord error)
{
Dbg.Assert(0 != (manifestProcessingFlags & ManifestProcessingFlags.LoadElements), "LoadRequiredModule / RequiredModules checks should only be done when actually loading a module");
Dbg.Assert((manifestProcessingFlags & ManifestProcessingFlags.LoadElements) != 0, "LoadRequiredModule / RequiredModules checks should only be done when actually loading a module");

error = null;

Expand Down Expand Up @@ -3817,7 +3817,7 @@ internal static PSModuleInfo LoadRequiredModule(ExecutionContext context,
string message;
if (moduleManifestPath != null)
{
if (0 != (manifestProcessingFlags & ManifestProcessingFlags.WriteErrors))
if ((manifestProcessingFlags & ManifestProcessingFlags.WriteErrors) != 0)
{
switch (loadFailureReason)
{
Expand Down Expand Up @@ -4521,7 +4521,7 @@ internal bool GetScalarFromData<T>(
catch (PSInvalidCastException e)
{
result = default(T);
if (0 != (manifestProcessingFlags & ManifestProcessingFlags.WriteErrors))
if ((manifestProcessingFlags & ManifestProcessingFlags.WriteErrors) != 0)
{
string message = StringUtil.Format(Modules.ModuleManifestInvalidValue, key, e.Message, moduleManifestPath);
ArgumentException newAe = new ArgumentException(message);
Expand Down Expand Up @@ -5349,7 +5349,7 @@ internal PSModuleInfo LoadUsingExtensions(PSModuleInfo parentModule,
else
extensions = ModuleIntrinsics.PSModuleExtensions;

var importingModule = 0 != (manifestProcessingFlags & ManifestProcessingFlags.LoadElements);
var importingModule = (manifestProcessingFlags & ManifestProcessingFlags.LoadElements) != 0;

// "ni.dll" has a higher priority then ".dll" to be loaded.
for (int i = 0; i < extensions.Length; i++)
Expand Down Expand Up @@ -5556,8 +5556,8 @@ internal PSModuleInfo LoadModule(PSModuleInfo parentModule, string fileName, str
return null;
}

var importingModule = 0 != (manifestProcessingFlags & ManifestProcessingFlags.LoadElements);
var writingErrors = 0 != (manifestProcessingFlags & ManifestProcessingFlags.WriteErrors);
var importingModule = (manifestProcessingFlags & ManifestProcessingFlags.LoadElements) != 0;
var writingErrors = (manifestProcessingFlags & ManifestProcessingFlags.WriteErrors) != 0;

// In case the file is a Ngen Assembly.
string ext;
Expand Down Expand Up @@ -6558,7 +6558,7 @@ internal PSModuleInfo LoadBinaryModule(PSModuleInfo parentModule, bool trySnapIn
bool importSuccessful = false;
string modulePath = string.Empty;
Version assemblyVersion = new Version(0, 0, 0, 0);
var importingModule = 0 != (manifestProcessingFlags & ManifestProcessingFlags.LoadElements);
var importingModule = (manifestProcessingFlags & ManifestProcessingFlags.LoadElements) != 0;

// See if we're loading a straight assembly...
if (assemblyToLoad != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ protected override void ProcessRecord()
&& !IsValidGacAssembly(nestedModule.Name))
{
Collection<PSModuleInfo> modules = GetModuleIfAvailable(nestedModule);
if (0 == modules.Count)
if (modules.Count == 0)
{
string errorMsg = StringUtil.Format(Modules.InvalidNestedModuleinModuleManifest, nestedModule.Name, filePath);
var errorRecord = new ErrorRecord(new DirectoryNotFoundException(errorMsg), "Modules_InvalidNestedModuleinModuleManifest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ internal void WriteProgress(ProgressRecord progressRecord, bool overrideInquire)
// WriteProgress. The following logic ensures that
// there is a unique id for each Cmdlet instance.

if (0 == _sourceId)
if (_sourceId == 0)
{
_sourceId = Interlocked.Increment(ref s_lastUsedSourceId);
}
Expand Down
4 changes: 2 additions & 2 deletions src/System.Management.Automation/engine/MshMemberInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,12 @@ protected void SetMemberName(string name)

internal bool MatchesOptions(MshMemberMatchOptions options)
{
if (this.IsHidden && (0 == (options & MshMemberMatchOptions.IncludeHidden)))
if (this.IsHidden && ((options & MshMemberMatchOptions.IncludeHidden) == 0))
{
return false;
}

if (!this.ShouldSerialize && (0 != (options & MshMemberMatchOptions.OnlySerializable)))
if (!this.ShouldSerialize && ((options & MshMemberMatchOptions.OnlySerializable) != 0))
{
return false;
}
Expand Down
Loading