From fe30442714a1baed7bf1e0db2ede774fb65980d1 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Sun, 21 Sep 2025 18:39:44 +0100 Subject: [PATCH 1/4] `Array.IndexOf != -1` --- .../Runtime/TypeInfos/RuntimeTypeInfo.InvokeMember.cs | 2 +- .../TypeSystem/Common/ConstructedTypeRewritingHelpers.cs | 4 ++-- .../TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs | 4 ++-- .../Compiler/DependencyAnalysis/VTableSliceNode.cs | 6 +++--- .../Interop/Unix/System.Native/Interop.GetUnixVersion.cs | 2 +- .../src/System/ComponentModel/CultureInfoConverter.cs | 2 +- .../src/System/IO/FileSystemWatcher.cs | 2 +- .../src/System/IO/Packaging/ContentType.cs | 2 +- .../src/System/Net/Http/Headers/ObjectCollection.cs | 4 ++-- .../src/System/Net/Security/SslStream.Protocol.cs | 2 +- .../System.Net.WebProxy/src/System/Net/WebProxy.NonWasm.cs | 2 +- .../Marshalling/MarshallerHelpers.cs | 4 ++-- src/mono/wasm/host/WebServerStartup.cs | 2 +- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.InvokeMember.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.InvokeMember.cs index 7a8621c1bd1e52..64886f4ae639e2 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.InvokeMember.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.InvokeMember.cs @@ -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 diff --git a/src/coreclr/tools/Common/TypeSystem/Common/ConstructedTypeRewritingHelpers.cs b/src/coreclr/tools/Common/TypeSystem/Common/ConstructedTypeRewritingHelpers.cs index 3019606023a15c..bfa0c97888e70f 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/ConstructedTypeRewritingHelpers.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/ConstructedTypeRewritingHelpers.cs @@ -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) @@ -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) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs b/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs index 3f0773c6b22a54..657f0b8492eab1 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs @@ -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); @@ -890,7 +890,7 @@ 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; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VTableSliceNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VTableSliceNode.cs index 2ec4de0835ed59..e412116fc3970f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VTableSliceNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VTableSliceNode.cs @@ -123,7 +123,7 @@ public override IReadOnlyList Slots public override bool IsSlotUsed(MethodDesc slot) { - Debug.Assert(Array.IndexOf(_slots, slot) != -1); + Debug.Assert(Array.IndexOf(_slots, slot) >= 0); return true; } @@ -176,7 +176,7 @@ public override IReadOnlyList 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 @@ -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 diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixVersion.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixVersion.cs index a08115bf857980..5e60df46572c2a 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixVersion.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixVersion.cs @@ -37,7 +37,7 @@ internal static string GetUnixVersion() return string.Empty; } - Debug.Assert(Array.IndexOf(version, 0) != -1); + Debug.Assert(Array.IndexOf(version, 0) >= 0); unsafe { fixed (byte* ptr = version) diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/CultureInfoConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/CultureInfoConverter.cs index 014a3e980dded7..b78d2bdb7781a0 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/CultureInfoConverter.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/CultureInfoConverter.cs @@ -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; diff --git a/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs b/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs index f285b0572ccd4d..de090ed95980cf 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs +++ b/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs @@ -733,7 +733,7 @@ public void Add(string item) public void Clear() => Items = Array.Empty(); - 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); diff --git a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ContentType.cs b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ContentType.cs index 9e59813328e35a..f3dbe73349687e 100644 --- a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ContentType.cs +++ b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ContentType.cs @@ -497,7 +497,7 @@ private static bool IsAsciiLetterOrDigit(char character) => /// input character /// private static bool IsLinearWhiteSpaceChar(char ch) => - ch <= ' ' && Array.IndexOf(s_linearWhiteSpaceChars, ch) != -1; + ch <= ' ' && Array.IndexOf(s_linearWhiteSpaceChars, ch) >= 0; #endregion Private Methods diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ObjectCollection.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ObjectCollection.cs index 31376a4de20f58..f8a5452edb5da6 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ObjectCollection.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ObjectCollection.cs @@ -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) { @@ -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) diff --git a/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Protocol.cs b/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Protocol.cs index 806e488243d7d3..50711bd4eaba8c 100644 --- a/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Protocol.cs +++ b/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Protocol.cs @@ -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()) diff --git a/src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.NonWasm.cs b/src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.NonWasm.cs index b865732117622d..7d35d4310317f9 100644 --- a/src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.NonWasm.cs +++ b/src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.NonWasm.cs @@ -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. diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs index 45b1ad734483dd..b6bf201d03b235 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/MarshallerHelpers.cs @@ -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; } } diff --git a/src/mono/wasm/host/WebServerStartup.cs b/src/mono/wasm/host/WebServerStartup.cs index c7f735f5ee8e06..8714ef5234dc54 100644 --- a/src/mono/wasm/host/WebServerStartup.cs +++ b/src/mono/wasm/host/WebServerStartup.cs @@ -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; } From 31692c45c6eb542a2680fd2218a2bff0218aaf13 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Sun, 21 Sep 2025 18:48:29 +0100 Subject: [PATCH 2/4] `Array.IndexOf == -1` --- .../Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs | 2 +- .../src/System/IO/Packaging/PartBasedPackageProperties.cs | 2 +- .../src/System/Net/Http/WinHttpResponseHeaderReader.cs | 2 +- .../src/System/Net/NameResolutionPal.Unix.cs | 2 +- .../Net/NetworkInformation/NetworkAddressChange.Android.cs | 2 +- .../System/Runtime/InteropServices/Marshalling/ComVariant.cs | 2 +- .../Analyzers/ConvertToLibraryImportFixer.cs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs b/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs index 657f0b8492eab1..49fb0827d7165c 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs @@ -896,7 +896,7 @@ private static DefaultInterfaceMethodResolution ResolveInterfaceMethodToDefaultI impl = implRecord.Body; diamondCase = false; } - else if (Array.IndexOf(mostSpecificInterface.RuntimeInterfaces, runtimeInterface) == -1) + else if (Array.IndexOf(mostSpecificInterface.RuntimeInterfaces, runtimeInterface) < 0) { diamondCase = true; } diff --git a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PartBasedPackageProperties.cs b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PartBasedPackageProperties.cs index e1fbb6f9b1b20f..5d26dd271a83c1 100644 --- a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PartBasedPackageProperties.cs +++ b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PartBasedPackageProperties.cs @@ -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), diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpResponseHeaderReader.cs b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpResponseHeaderReader.cs index dd732514b1bdd0..a8be6635565dca 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpResponseHeaderReader.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpResponseHeaderReader.cs @@ -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; } diff --git a/src/libraries/System.Net.NameResolution/src/System/Net/NameResolutionPal.Unix.cs b/src/libraries/System.Net.NameResolution/src/System/Net/NameResolutionPal.Unix.cs index 01f90f2c1e2de2..d142c065e8ee98 100644 --- a/src/libraries/System.Net.NameResolution/src/System/Net/NameResolutionPal.Unix.cs +++ b/src/libraries/System.Net.NameResolution/src/System/Net/NameResolutionPal.Unix.cs @@ -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; diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Android.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Android.cs index c9d7f9d67f6096..e6cb7995803147 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Android.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Android.cs @@ -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; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/ComVariant.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/ComVariant.cs index ee44d4960718ce..f42435e24194d2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/ComVariant.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/ComVariant.cs @@ -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))); } diff --git a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/ConvertToLibraryImportFixer.cs b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/ConvertToLibraryImportFixer.cs index b83eb5803abffd..ef8c15d621c148 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/ConvertToLibraryImportFixer.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/ConvertToLibraryImportFixer.cs @@ -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); } From e7e875ffc62c5498c8080c1148532b7073a40d04 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Sun, 21 Sep 2025 18:50:09 +0100 Subject: [PATCH 3/4] `Array.LastIndexOf != -1` --- .../System.Collections/src/System/Collections/Generic/Stack.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Collections/src/System/Collections/Generic/Stack.cs b/src/libraries/System.Collections/src/System/Collections/Generic/Stack.cs index 310c779a1dd0b9..c97689f6294f32 100644 --- a/src/libraries/System.Collections/src/System/Collections/Generic/Stack.cs +++ b/src/libraries/System.Collections/src/System/Collections/Generic/Stack.cs @@ -90,7 +90,7 @@ public bool Contains(T item) // via EqualityComparer.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. From da9097f6debf265ba8a0a8e8ac94a964efcc5077 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Sun, 21 Sep 2025 18:50:51 +0100 Subject: [PATCH 4/4] `Array.LastIndexOf == -1` --- .../System.Private.CoreLib/src/System/MulticastDelegate.Mono.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/System.Private.CoreLib/src/System/MulticastDelegate.Mono.cs b/src/mono/System.Private.CoreLib/src/System/MulticastDelegate.Mono.cs index 73aacd9ca0e0c6..47fb79aa3cdfa7 100644 --- a/src/mono/System.Private.CoreLib/src/System/MulticastDelegate.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/MulticastDelegate.Mono.cs @@ -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)