diff --git a/src/coreclr/tools/Common/Compiler/ReferenceSource/LinkAttributesParser.cs b/src/coreclr/tools/Common/Compiler/ReferenceSource/LinkAttributesParser.cs index 0acfdda2dccbe5..e4476e05a315e0 100644 --- a/src/coreclr/tools/Common/Compiler/ReferenceSource/LinkAttributesParser.cs +++ b/src/coreclr/tools/Common/Compiler/ReferenceSource/LinkAttributesParser.cs @@ -173,7 +173,7 @@ static string FormatCustomAttribute(CustomAttribute ca) continue; bool match = true; - for (int ii = 0; match && ii != args.Length; ++ii) + for (int ii = 0; match && ii < args.Length; ++ii) { // // No candidates betterness, only exact matches are supported diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/NiceIO.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/NiceIO.cs index 5028f992d1b33e..791d6b4d408539 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/NiceIO.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/Extensions/NiceIO.cs @@ -328,7 +328,7 @@ public bool Equals (NPath? p) if (p._elements.Length != _elements.Length) return false; - for (var i = 0; i != _elements.Length; i++) + for (var i = 0; i < _elements.Length; i++) if (!string.Equals (p._elements[i], _elements[i], PathStringComparison)) return false; diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/BinderHelper.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/BinderHelper.cs index 2b4220b389236b..9feac5c18c13ea 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/BinderHelper.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/BinderHelper.cs @@ -157,7 +157,7 @@ public static void ValidateBindArgument(DynamicMetaObject[] arguments, string pa { if (arguments != null) // null is treated as empty, so not invalid { - for (int i = 0; i != arguments.Length; ++i) + for (int i = 0; i < arguments.Length; ++i) { ValidateBindArgument(arguments[i], $"{paramName}[{i}]"); } diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/ActivatorUtilities.cs b/src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/ActivatorUtilities.cs index 45b1cdc56ca5f1..6511528989f879 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/ActivatorUtilities.cs +++ b/src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/ActivatorUtilities.cs @@ -445,7 +445,7 @@ public int Match(object[] givenParameters, IServiceProviderIsService serviceProv public object CreateInstance(IServiceProvider provider) { - for (int index = 0; index != _parameters.Length; index++) + for (int index = 0; index < _parameters.Length; index++) { if (_parameterValues[index] == null) { diff --git a/src/libraries/System.Collections/src/System/Collections/Generic/SortedList.cs b/src/libraries/System.Collections/src/System/Collections/Generic/SortedList.cs index 3204094bf71ecd..2ca0f0e740132c 100644 --- a/src/libraries/System.Collections/src/System/Collections/Generic/SortedList.cs +++ b/src/libraries/System.Collections/src/System/Collections/Generic/SortedList.cs @@ -160,7 +160,7 @@ public SortedList(IDictionary dictionary, IComparer? compare { comparer = Comparer; // obtain default if this is null. Array.Sort(keys, values, comparer); - for (int i = 1; i != keys.Length; ++i) + for (int i = 1; i < keys.Length; ++i) { if (comparer.Compare(keys[i - 1], keys[i]) == 0) { diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/AsynchronousChannelMergeEnumerator.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/AsynchronousChannelMergeEnumerator.cs index 161fb73749130c..4db5b14c1537b9 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/AsynchronousChannelMergeEnumerator.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/AsynchronousChannelMergeEnumerator.cs @@ -122,7 +122,7 @@ private bool MoveNextSlowPath() int firstChannelIndex = _channelIndex; int currChannelIndex; - while ((currChannelIndex = _channelIndex) != _channels.Length) + while ((currChannelIndex = _channelIndex) < _channels.Length) { AsynchronousChannel current = _channels[currChannelIndex]; diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/SynchronousChannelMergeEnumerator.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/SynchronousChannelMergeEnumerator.cs index ba10ef68646219..f288412e97a0e4 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/SynchronousChannelMergeEnumerator.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/SynchronousChannelMergeEnumerator.cs @@ -84,7 +84,7 @@ public override bool MoveNext() } // If the index has reached the end, we bail. - while (_channelIndex != _channels.Length) + while (_channelIndex < _channels.Length) { SynchronousChannel current = _channels[_channelIndex]; Debug.Assert(current != null); diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/AltSvcHeaderParser.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/AltSvcHeaderParser.cs index 5c63f095229dbd..050de323ea52b8 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/AltSvcHeaderParser.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/AltSvcHeaderParser.cs @@ -73,10 +73,10 @@ protected override int GetParsedValueLength(string value, int startIndex, object int? maxAge = null; bool persist = false; - while (idx != value.Length) + while (idx < value.Length) { // Skip OWS before semicolon. - while (idx != value.Length && IsOptionalWhiteSpace(value[idx])) ++idx; + while (idx < value.Length && IsOptionalWhiteSpace(value[idx])) ++idx; if (idx == value.Length) { @@ -102,7 +102,7 @@ protected override int GetParsedValueLength(string value, int startIndex, object ++idx; // Skip OWS after semicolon / before value. - while (idx != value.Length && IsOptionalWhiteSpace(value[idx])) ++idx; + while (idx < value.Length && IsOptionalWhiteSpace(value[idx])) ++idx; // Get the parameter key length. int tokenLength = HttpRuleParser.GetTokenLength(value, idx); diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Number.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Number.cs index b0816d00683616..0349d7aada43fb 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Number.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Number.cs @@ -44,7 +44,7 @@ private static bool TryParseNumber(ReadOnlySpan source, ref Number.NumberB case Utf8Constants.Plus: srcIndex++; - if (srcIndex == source.Length) + if (srcIndex >= source.Length) { bytesConsumed = 0; return false; @@ -61,7 +61,7 @@ private static bool TryParseNumber(ReadOnlySpan source, ref Number.NumberB int maxDigitCount = digits.Length - 1; // Throw away any leading zeroes - while (srcIndex != source.Length) + while (srcIndex < source.Length) { c = source[srcIndex]; if (c != '0') @@ -79,7 +79,7 @@ private static bool TryParseNumber(ReadOnlySpan source, ref Number.NumberB int startIndexNonLeadingDigitsBeforeDecimal = srcIndex; int hasNonZeroTail = 0; - while (srcIndex != source.Length) + while (srcIndex < source.Length) { c = source[srcIndex]; int value = (byte)(c - (byte)('0')); @@ -134,7 +134,7 @@ private static bool TryParseNumber(ReadOnlySpan source, ref Number.NumberB srcIndex++; int startIndexDigitsAfterDecimal = srcIndex; - while (srcIndex != source.Length) + while (srcIndex < source.Length) { c = source[srcIndex]; int value = (byte)(c - (byte)('0')); @@ -268,7 +268,7 @@ private static bool TryParseNumber(ReadOnlySpan source, ref Number.NumberB // continue eating digits from there srcIndex += 10; - while (srcIndex != source.Length) + while (srcIndex < source.Length) { c = source[srcIndex]; int value = (byte)(c - (byte)('0')); diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.TimeSpan.BigG.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.TimeSpan.BigG.cs index 94d307d77b204c..5046731ff05326 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.TimeSpan.BigG.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.TimeSpan.BigG.cs @@ -9,7 +9,7 @@ private static bool TryParseTimeSpanBigG(ReadOnlySpan source, out TimeSpan { int srcIndex = 0; byte c = default; - while (srcIndex != source.Length) + while (srcIndex < source.Length) { c = source[srcIndex]; if (!(c == ' ' || c == '\t')) diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.TimeSpan.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.TimeSpan.cs index 7dd0382de572f3..a6ac0d4db985ec 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.TimeSpan.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.TimeSpan.cs @@ -75,7 +75,7 @@ private static bool TryParseTimeSpanFraction(ReadOnlySpan source, out uint uint fraction = digit; int digitCount = 1; - while (srcIndex != source.Length) + while (srcIndex < source.Length) { digit = source[srcIndex] - 48u; // '0' if (digit > 9) diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.TimeSpanSplitter.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.TimeSpanSplitter.cs index ce119a8ec337e1..60521e6cdf0d7a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.TimeSpanSplitter.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.TimeSpanSplitter.cs @@ -38,7 +38,7 @@ public bool TrySplitTimeSpan(ReadOnlySpan source, bool periodUsedToSeparat byte c = default; // Unlike many other data types, TimeSpan allow leading whitespace. - while (srcIndex != source.Length) + while (srcIndex < source.Length) { c = source[srcIndex]; if (!(c == ' ' || c == '\t')) diff --git a/src/tools/illink/test/Mono.Linker.Tests/Extensions/NiceIO.cs b/src/tools/illink/test/Mono.Linker.Tests/Extensions/NiceIO.cs index ffc24695eb8035..dc4f9dcd8d7ad6 100644 --- a/src/tools/illink/test/Mono.Linker.Tests/Extensions/NiceIO.cs +++ b/src/tools/illink/test/Mono.Linker.Tests/Extensions/NiceIO.cs @@ -326,7 +326,7 @@ public bool Equals (NPath p) if (p._elements.Length != _elements.Length) return false; - for (var i = 0; i != _elements.Length; i++) + for (var i = 0; i < _elements.Length; i++) if (!string.Equals (p._elements[i], _elements[i], PathStringComparison)) return false; @@ -870,4 +870,4 @@ public enum DeleteMode Normal, Soft } -} \ No newline at end of file +}