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 @@ -66,7 +66,7 @@ internal abstract partial class RuntimeTypeInfo
#endregion

#region Check that any named parameters are not null
if (namedParams != null && Array.IndexOf(namedParams, null) != -1)
if (namedParams != null && Array.IndexOf(namedParams, null) >= 0)
// "Named parameter value must not be null."
throw new ArgumentException(SR.Arg_NamedParamNull, nameof(namedParams));
#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static bool IsConstructedOverType(this TypeDesc type, TypeDesc[] typesToF
{
int directDiscoveryIndex = Array.IndexOf(typesToFind, type);

if (directDiscoveryIndex != -1)
if (directDiscoveryIndex >= 0)
return true;

if (type.HasInstantiation)
Expand Down Expand Up @@ -72,7 +72,7 @@ public static TypeDesc ReplaceTypesInConstructionOfType(this TypeDesc type, Type
{
int directReplacementIndex = Array.IndexOf(typesToReplace, type);

if (directReplacementIndex != -1)
if (directReplacementIndex >= 0)
return replacementTypes[directReplacementIndex];

if (type.HasInstantiation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ private static DefaultInterfaceMethodResolution ResolveInterfaceMethodToDefaultI
impl = interfaceMethodDefinition;
}
}
else if (Array.IndexOf(runtimeInterface.RuntimeInterfaces, interfaceMethodOwningType) != -1)
else if (Array.IndexOf(runtimeInterface.RuntimeInterfaces, interfaceMethodOwningType) >= 0)
{
// This interface might provide a default implementation
MethodImplRecord[] possibleImpls = runtimeInterface.FindMethodsImplWithMatchingDeclName(interfaceMethod.Name);
Expand All @@ -890,13 +890,13 @@ private static DefaultInterfaceMethodResolution ResolveInterfaceMethodToDefaultI
{
// This interface provides a default implementation.
// Is it also most specific?
if (mostSpecificInterface == null || Array.IndexOf(runtimeInterface.RuntimeInterfaces, mostSpecificInterface) != -1)
if (mostSpecificInterface == null || Array.IndexOf(runtimeInterface.RuntimeInterfaces, mostSpecificInterface) >= 0)
{
mostSpecificInterface = runtimeInterface;
impl = implRecord.Body;
diamondCase = false;
}
else if (Array.IndexOf(mostSpecificInterface.RuntimeInterfaces, runtimeInterface) == -1)
else if (Array.IndexOf(mostSpecificInterface.RuntimeInterfaces, runtimeInterface) < 0)
{
diamondCase = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public override IReadOnlyList<MethodDesc> Slots

public override bool IsSlotUsed(MethodDesc slot)
{
Debug.Assert(Array.IndexOf(_slots, slot) != -1);
Debug.Assert(Array.IndexOf(_slots, slot) >= 0);
return true;
}

Expand Down Expand Up @@ -176,7 +176,7 @@ public override IReadOnlyList<MethodDesc> Slots

public override bool IsSlotUsed(MethodDesc slot)
{
Debug.Assert(Array.IndexOf(_slots, slot) != -1);
Debug.Assert(Array.IndexOf(_slots, slot) >= 0);
#if DEBUG
_isLocked = true;
#endif
Expand All @@ -198,7 +198,7 @@ public void AddEntry(MethodDesc virtualMethod)
Debug.Assert(!virtualMethod.HasInstantiation);
Debug.Assert(virtualMethod.IsVirtual);
Debug.Assert(virtualMethod.OwningType == _type);
Debug.Assert(Array.IndexOf(_slots, virtualMethod) != -1);
Debug.Assert(Array.IndexOf(_slots, virtualMethod) >= 0);
#if DEBUG
Debug.Assert(!_isLocked);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal static string GetUnixVersion()
return string.Empty;
}

Debug.Assert(Array.IndexOf<byte>(version, 0) != -1);
Debug.Assert(Array.IndexOf<byte>(version, 0) >= 0);
unsafe
{
fixed (byte* ptr = version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public bool Contains(T item)
// via EqualityComparer<T>.Default.Equals, we
// only make one virtual call to EqualityComparer.LastIndexOf.

return _size != 0 && Array.LastIndexOf(_array, item, _size - 1) != -1;
return _size != 0 && Array.LastIndexOf(_array, item, _size - 1) >= 0;
}

// Copies the stack into an array.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContex
int invariantIndex = Array.IndexOf(installedCultures, CultureInfo.InvariantCulture);

CultureInfo[] array;
if (invariantIndex != -1)
if (invariantIndex >= 0)
{
Debug.Assert(invariantIndex >= 0 && invariantIndex < installedCultures.Length);
installedCultures[invariantIndex] = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ public void Add(string item)

public void Clear() => Items = Array.Empty<string>();

public bool Contains(string item) => Array.IndexOf(Items, item) != -1;
public bool Contains(string item) => Array.IndexOf(Items, item) >= 0;

public void CopyTo(string[] array, int arrayIndex) => Items.CopyTo(array, arrayIndex);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ private static bool IsAsciiLetterOrDigit(char character) =>
/// <param name="ch">input character</param>
/// <returns></returns>
private static bool IsLinearWhiteSpaceChar(char ch) =>
ch <= ' ' && Array.IndexOf(s_linearWhiteSpaceChars, ch) != -1;
ch <= ' ' && Array.IndexOf(s_linearWhiteSpaceChars, ch) >= 0;

#endregion Private Methods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ private void ParseCorePropertyPart(PackagePart part)
PackageXmlEnum xmlStringIndex = PackageXmlStringTable.GetEnumOf(localName);
string? valueType = PackageXmlStringTable.GetValueType(xmlStringIndex);

if (Array.IndexOf(s_validProperties, xmlStringIndex) == -1) // An unexpected element is an error.
if (Array.IndexOf(s_validProperties, xmlStringIndex) < 0) // An unexpected element is an error.
{
throw new XmlException(
SR.Format(SR.InvalidPropertyNameInCorePropertiesPart, reader.LocalName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public bool ReadHeader([NotNullWhen(true)] out string? name, [NotNullWhen(true)]
int colonIndex = Array.IndexOf(_buffer, ':', startIndex, length);

// Skip malformed header lines that are missing the colon character.
if (colonIndex == -1)
if (colonIndex < 0)
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void Clear()
public bool Contains(T item) =>
_size <= 0 ? false :
_items is T o ? o.Equals(item) :
_items is T[] items && Array.IndexOf(items, item, 0, _size) != -1;
_items is T[] items && Array.IndexOf(items, item, 0, _size) >= 0;

public void CopyTo(T[] array, int arrayIndex)
{
Expand Down Expand Up @@ -127,7 +127,7 @@ public bool Remove(T item)
else if (_items is T[] items)
{
int index = Array.IndexOf(items, item, 0, _size);
if (index != -1)
if (index >= 0)
{
_size--;
if (index < _size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private static unsafe void ParseHostEntry(Interop.Sys.HostEntry hostEntry, bool
for (int i = 0; i < hostEntry.IPAddressCount; i++)
{
Interop.Sys.IPAddress nativeAddr = addressHandle[i];
if (Array.IndexOf(nativeAddresses, nativeAddr, 0, nativeAddressCount) == -1 &&
if (Array.IndexOf(nativeAddresses, nativeAddr, 0, nativeAddressCount) < 0 &&
(!nativeAddr.IsIPv6 || SocketProtocolSupportPal.OSSupportsIPv6)) // Do not include IPv6 addresses if IPV6 support is force-disabled
{
nativeAddresses[nativeAddressCount++] = nativeAddr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private static bool NetworkChanged(IPAddress[] oldAddresses, IPAddress[] newAddr

for (int i = 0; i < newAddresses.Length; i++)
{
if (Array.IndexOf(oldAddresses, newAddresses[i]) == -1)
if (Array.IndexOf(oldAddresses, newAddresses[i]) < 0)
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ private string[] GetRequestCertificateAuthorities()
for (int ii = 0; ii < elementsCount; ++ii)
{
string issuer = chain.ChainElements[ii].Certificate!.Issuer;
found = Array.IndexOf(issuers, issuer) != -1;
found = Array.IndexOf(issuers, issuer) >= 0;
if (found)
{
if (NetEventSource.Log.IsEnabled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private static bool IsLocal(Uri host)
{
EnsureNetworkChangeRegistration();
IPAddress[] localAddresses = s_localAddresses ??= Dns.GetHostEntry(Dns.GetHostName()).AddressList;
return Array.IndexOf(localAddresses, hostAddress) != -1;
return Array.IndexOf(localAddresses, hostAddress) >= 0;
}

// No dot? Local.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ _ when vt.HasFlag(VarEnum.VT_ARRAY) && sizeof(T) == nint.Size => rawValue,

private readonly void ThrowIfNotVarType(params VarEnum[] requiredType)
{
if (Array.IndexOf(requiredType, VarType) == -1)
if (Array.IndexOf(requiredType, VarType) < 0)
{
throw new InvalidOperationException(SR.Format(SR.ComVariant_TypeIsNotSupportedType, VarType, string.Join(", ", requiredType)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ private static SyntaxNode SortDllImportAttributeArguments(AttributeSyntax attrib
// Named arguments in specified order, followed by any named arguments with no preferred order
string name = arg.NameEquals.Name.Identifier.Text;
int index = System.Array.IndexOf(s_preferredAttributeArgumentOrder, name);
return index == -1 ? int.MaxValue : index;
return index < 0 ? int.MaxValue : index;
})));
return generator.ReplaceNode(attribute, attribute.ArgumentList, updatedArgList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ public EdgeMap(int numNodes)
set => _edgeMap[to * NodeCount + from] = value;
}

public bool AnyEdges => Array.IndexOf(_edgeMap, true) != -1;
public bool AnyEdges => Array.IndexOf(_edgeMap, true) >= 0;

public int NodeCount { get; }

public bool AnyIncomingEdge(int to)
{
return Array.IndexOf(_edgeMap, true, to * NodeCount, NodeCount) != -1;
return Array.IndexOf(_edgeMap, true, to * NodeCount, NodeCount) >= 0;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private static int LastIndexOf(Delegate[] haystack, Delegate[] needle)
else if (other.delegates == null)
{
int idx = Array.LastIndexOf(delegates, other);
if (idx == -1)
if (idx < 0)
return this;

if (delegates.Length <= 1)
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/host/WebServerStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static int GetNextRandomExcept(Range range, params int[] except)
do
{
current = Random.Shared.Next(range.Start.Value, range.End.Value);
} while (Array.IndexOf(except, current) > -1);
} while (Array.IndexOf(except, current) >= 0);

return current;
}
Expand Down
Loading