diff --git a/eng/CodeAnalysis.src.globalconfig b/eng/CodeAnalysis.src.globalconfig index 24427d2df83ba..ef23d84e18ff2 100644 --- a/eng/CodeAnalysis.src.globalconfig +++ b/eng/CodeAnalysis.src.globalconfig @@ -1458,7 +1458,7 @@ dotnet_diagnostic.IDE0052.severity = suggestion dotnet_diagnostic.IDE0053.severity = silent # IDE0054: Use compound assignment -dotnet_diagnostic.IDE0054.severity = suggestion +dotnet_diagnostic.IDE0054.severity = warning # IDE0055: Fix formatting dotnet_diagnostic.IDE0055.severity = suggestion diff --git a/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ThunkPool.cs b/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ThunkPool.cs index 76234dde14e4d..62c26ccd305ef 100644 --- a/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ThunkPool.cs +++ b/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ThunkPool.cs @@ -217,7 +217,7 @@ public unsafe IntPtr AllocateThunk() int thunkIndex = (int)(((nuint)(nint)nextAvailableThunkPtr) - ((nuint)(nint)nextAvailableThunkPtr & ~Constants.PageSizeMask)); Debug.Assert((thunkIndex % Constants.ThunkDataSize) == 0); - thunkIndex = thunkIndex / Constants.ThunkDataSize; + thunkIndex /= Constants.ThunkDataSize; IntPtr thunkAddress = InternalCalls.RhpGetThunkStubsBlockAddress(nextAvailableThunkPtr) + thunkIndex * Constants.ThunkCodeSize; diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Array.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Array.NativeAot.cs index 69b2f50c74f53..08725d5744774 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Array.NativeAot.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Array.NativeAot.cs @@ -897,7 +897,7 @@ internal static unsafe Array NewMultiDimArray(EETypePtr eeType, int* pLengths, i throw new OverflowException(); if (length > MaxLength) maxArrayDimensionLengthOverflow = true; - totalLength = totalLength * (ulong)length; + totalLength *= (ulong)length; if (totalLength > int.MaxValue) throw new OutOfMemoryException(); // "Array dimensions exceeded supported range." } diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/Assemblies/NativeFormat/NativeFormatRuntimeAssembly.GetTypeCore.CaseInsensitive.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/Assemblies/NativeFormat/NativeFormatRuntimeAssembly.GetTypeCore.CaseInsensitive.cs index d9f9c5f7148e2..48a2198d49bfe 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/Assemblies/NativeFormat/NativeFormatRuntimeAssembly.GetTypeCore.CaseInsensitive.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/Assemblies/NativeFormat/NativeFormatRuntimeAssembly.GetTypeCore.CaseInsensitive.cs @@ -90,7 +90,7 @@ private LowLevelDictionary CreateCaseInsensitiveTypeDictionary( { string ns = namespaceHandle.ToNamespaceName(reader); if (ns.Length != 0) - ns = ns + "."; + ns += "."; ns = ns.ToLowerInvariant(); NamespaceDefinition namespaceDefinition = namespaceHandle.GetNamespaceDefinition(reader); diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/CompilerServices/ClassConstructorRunner.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/CompilerServices/ClassConstructorRunner.cs index a3847253fa3f0..6db9cb646f91a 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/CompilerServices/ClassConstructorRunner.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/CompilerServices/ClassConstructorRunner.cs @@ -540,7 +540,7 @@ public static unsafe string ToHexStringUnsignedLong(ulong u, bool zeroPrepad, in for (; i >= 0; i--) { chars[i] = GetHexChar((uint)(u % 16)); - u = u / 16; + u /= 16; if ((i == 0) || (!zeroPrepad && (u == 0))) break; diff --git a/src/coreclr/nativeaot/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/PayForPlayExperience/MissingMetadataExceptionCreator.cs b/src/coreclr/nativeaot/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/PayForPlayExperience/MissingMetadataExceptionCreator.cs index 8b25905240d7b..818ba99f82a95 100644 --- a/src/coreclr/nativeaot/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/PayForPlayExperience/MissingMetadataExceptionCreator.cs +++ b/src/coreclr/nativeaot/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/PayForPlayExperience/MissingMetadataExceptionCreator.cs @@ -249,7 +249,7 @@ internal static string ToDisplayStringIfAvailable(this Type type, List gene { genericParameterOffsets.Add(s.Length); if (genericArgCount > 0) - s = s + ","; + s += ","; } s += "]"; } @@ -283,7 +283,7 @@ private static string CreateConstructedGenericTypeStringIfAvailable(Type generic // Similarly, if we found too few, add them at the end. while (genericTypeArguments.Length > genericParameterOffsets.Count) { - genericTypeDefinitionString = genericTypeDefinitionString + ","; + genericTypeDefinitionString += ","; genericParameterOffsets.Add(genericTypeDefinitionString.Length); } diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/EETypeCreator.cs b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/EETypeCreator.cs index f5bdf03faa20a..c16a125c3474e 100644 --- a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/EETypeCreator.cs +++ b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/EETypeCreator.cs @@ -941,7 +941,7 @@ private static unsafe int CreateGCDesc(LowLevelList bitfield, int size, bo } else { - seriesSize = seriesSize - size; + seriesSize -= size; *ptr-- = (void*)seriesOffset; *ptr-- = (void*)seriesSize; } diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.LdTokenResultLookup.cs b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.LdTokenResultLookup.cs index 1c1da35553b88..fd332cf1b751d 100644 --- a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.LdTokenResultLookup.cs +++ b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.LdTokenResultLookup.cs @@ -209,7 +209,7 @@ public unsafe RuntimeFieldHandle GetRuntimeFieldHandleForComponents(RuntimeTypeH fieldData->FieldName = fieldName; // Special flag (lowest bit set) in the handle value to indicate it was dynamically allocated - runtimeFieldHandleValue = runtimeFieldHandleValue + 1; + runtimeFieldHandleValue++; runtimeFieldHandle = *(RuntimeFieldHandle*)&runtimeFieldHandleValue; _runtimeFieldHandles.Add(key, runtimeFieldHandle); @@ -232,7 +232,7 @@ private unsafe bool TryGetDynamicRuntimeFieldHandleComponents(RuntimeFieldHandle // Special flag in the handle value to indicate it was dynamically allocated Debug.Assert((runtimeFieldHandleValue.ToInt64() & 0x1) == 0x1); - runtimeFieldHandleValue = runtimeFieldHandleValue - 1; + runtimeFieldHandleValue--; DynamicFieldHandleInfo* fieldData = (DynamicFieldHandleInfo*)runtimeFieldHandleValue.ToPointer(); declaringTypeHandle = *(RuntimeTypeHandle*)&(fieldData->DeclaringType); @@ -317,7 +317,7 @@ public unsafe RuntimeMethodHandle GetRuntimeMethodHandleForComponents(RuntimeTyp } // Special flag in the handle value to indicate it was dynamically allocated, and doesn't point into the InvokeMap blob - runtimeMethodHandleValue = runtimeMethodHandleValue + 1; + runtimeMethodHandleValue++; runtimeMethodHandle = * (RuntimeMethodHandle*)&runtimeMethodHandleValue; _runtimeMethodHandles.Add(key, runtimeMethodHandle); @@ -344,7 +344,7 @@ private unsafe bool TryGetDynamicRuntimeMethodHandleComponents(RuntimeMethodHand Debug.Assert((runtimeMethodHandleValue.ToInt64() & 0x1) == 0x1); // Special flag in the handle value to indicate it was dynamically allocated, and doesn't point into the InvokeMap blob - runtimeMethodHandleValue = runtimeMethodHandleValue - 1; + runtimeMethodHandleValue--; DynamicMethodHandleInfo* methodData = (DynamicMethodHandleInfo*)runtimeMethodHandleValue.ToPointer(); declaringTypeHandle = *(RuntimeTypeHandle*)&(methodData->DeclaringType); diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.Metadata.cs b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.Metadata.cs index a0c3379a3efb0..7c619907610f7 100644 --- a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.Metadata.cs +++ b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.Metadata.cs @@ -417,7 +417,7 @@ public static unsafe IntPtr TryGetStaticClassConstructionContext(RuntimeTypeHand // what we have now is the base address of the non-gc statics of the type // what we need is the cctor context, which is just before that - ptr = ptr - sizeof(System.Runtime.CompilerServices.StaticClassConstructionContext); + ptr -= sizeof(System.Runtime.CompilerServices.StaticClassConstructionContext); return (IntPtr)ptr; } diff --git a/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs b/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs index dd34d85aaa569..a225665dcee12 100644 --- a/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs +++ b/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs @@ -121,7 +121,7 @@ internal static uint ComputeValueTypeFieldPaddingFieldValue(uint padding, uint a while ((alignment & 1) == 0) { alignmentLog2++; - alignment = alignment >> 1; + alignment >>= 1; } Debug.Assert(alignment == 1); diff --git a/src/coreclr/tools/Common/TypeSystem/Common/ExplicitLayoutValidator.cs b/src/coreclr/tools/Common/TypeSystem/Common/ExplicitLayoutValidator.cs index c537f6ea4571e..838dd7038d33b 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/ExplicitLayoutValidator.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/ExplicitLayoutValidator.cs @@ -233,7 +233,7 @@ private void SetFieldLayout(List fieldLayoutInterval, int o previousInterval.EndSentinel = newInterval.EndSentinel; fieldLayoutInterval[newIntervalLocation - 1] = previousInterval; - newIntervalLocation = newIntervalLocation - 1; + newIntervalLocation--; } else { diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeHashingAlgorithms.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeHashingAlgorithms.cs index 6b3d37851cee6..5904397c4a015 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeHashingAlgorithms.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeHashingAlgorithms.cs @@ -125,7 +125,7 @@ private static string IntToString(int arg) while (arg != 0) { sb.Append((char)('0' + (arg % 10))); - arg = arg / 10; + arg /= 10; } // Reverse the string diff --git a/src/installer/managed/Microsoft.NET.HostModel/Bundle/Manifest.cs b/src/installer/managed/Microsoft.NET.HostModel/Bundle/Manifest.cs index 5d58732cb7594..cfc68b0cf9b6e 100644 --- a/src/installer/managed/Microsoft.NET.HostModel/Bundle/Manifest.cs +++ b/src/installer/managed/Microsoft.NET.HostModel/Bundle/Manifest.cs @@ -139,7 +139,7 @@ private string GenerateDeterministicId() public long Write(BinaryWriter writer) { - BundleID = BundleID ?? GenerateDeterministicId(); + BundleID ??= GenerateDeterministicId(); long startOffset = writer.BaseStream.Position; diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs index a72275a75900f..298b250b5ecba 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs @@ -111,7 +111,7 @@ private static SslProtocols CalculateEffectiveProtocols(SslAuthenticationOptions if (protocols != SslProtocols.None && CipherSuitesPolicyPal.WantsTls13(protocols)) { - protocols = protocols & (~SslProtocols.Tls13); + protocols &= ~SslProtocols.Tls13; } } else if (CipherSuitesPolicyPal.WantsTls13(protocols) && diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs index ce84a734d480b..24abe5323e5bd 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaLookupSids.cs @@ -41,7 +41,7 @@ public static unsafe void InitializeReferencedDomainsList(this SafeLsaMemoryHand if (domainList.Domains != IntPtr.Zero) { Interop.LSA_TRUST_INFORMATION* pTrustInformation = (Interop.LSA_TRUST_INFORMATION*)domainList.Domains; - pTrustInformation = pTrustInformation + domainList.Entries; + pTrustInformation += domainList.Entries; long bufferSize = (byte*)pTrustInformation - pRdl; System.Diagnostics.Debug.Assert(bufferSize > 0, "bufferSize > 0"); diff --git a/src/libraries/Common/src/System/IO/RowConfigReader.cs b/src/libraries/Common/src/System/IO/RowConfigReader.cs index 571aa9afd9e8a..b9b78f30a433f 100644 --- a/src/libraries/Common/src/System/IO/RowConfigReader.cs +++ b/src/libraries/Common/src/System/IO/RowConfigReader.cs @@ -141,7 +141,7 @@ private bool TryFindNextKeyOccurrence(string key, int startIndex, out int keyInd } } - startIndex = startIndex + key.Length; + startIndex += key.Length; } } diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/IntegerDecoder.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/IntegerDecoder.cs index 34ab1d294ec90..b717b3d4d83d3 100644 --- a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/IntegerDecoder.cs +++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/IntegerDecoder.cs @@ -73,7 +73,7 @@ public bool TryDecode(byte b, out int result) throw new HPackDecodingException(SR.net_http_hpack_bad_integer); } - _i = _i + ((b & 0x7f) << _m); + _i += ((b & 0x7f) << _m); // If the addition overflowed, the result will be negative. if (_i < 0) @@ -81,7 +81,7 @@ public bool TryDecode(byte b, out int result) throw new HPackDecodingException(SR.net_http_hpack_bad_integer); } - _m = _m + 7; + _m += 7; if ((b & 128) == 0) { diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/IntegerEncoder.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/IntegerEncoder.cs index b25b218522bab..22719673ffc2c 100644 --- a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/IntegerEncoder.cs +++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/IntegerEncoder.cs @@ -50,7 +50,7 @@ public static bool Encode(int value, int numBits, Span destination, out in return false; } - value = value - ((1 << numBits) - 1); + value -= ((1 << numBits) - 1); int i = 1; while (value >= 128) @@ -63,7 +63,7 @@ public static bool Encode(int value, int numBits, Span destination, out in return false; } - value = value / 128; + value /= 128; } destination[i++] = (byte)value; diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Operators.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Operators.cs index d11df5adba186..f730892b1b70f 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Operators.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Operators.cs @@ -245,11 +245,11 @@ private bool GetStandardAndLiftedBinopSignatures(List rgbofs, BinO switch (GetConvKind(info.ptRaw1, bos.pt1)) { default: - grflt = grflt | LiftFlags.Convert1; + grflt |= LiftFlags.Convert1; break; case ConvKind.Implicit: case ConvKind.Identity: - grflt = grflt | LiftFlags.Lift1; + grflt |= LiftFlags.Lift1; break; } break; @@ -272,11 +272,11 @@ private bool GetStandardAndLiftedBinopSignatures(List rgbofs, BinO switch (GetConvKind(info.ptRaw1, bos.pt1)) { default: - grflt = grflt | LiftFlags.Convert1; + grflt |= LiftFlags.Convert1; break; case ConvKind.Implicit: case ConvKind.Identity: - grflt = grflt | LiftFlags.Lift1; + grflt |= LiftFlags.Lift1; break; } break; @@ -330,11 +330,11 @@ private bool GetStandardAndLiftedBinopSignatures(List rgbofs, BinO switch (GetConvKind(info.ptRaw2, bos.pt2)) { default: - grflt = grflt | LiftFlags.Convert2; + grflt |= LiftFlags.Convert2; break; case ConvKind.Implicit: case ConvKind.Identity: - grflt = grflt | LiftFlags.Lift2; + grflt |= LiftFlags.Lift2; break; } break; @@ -357,11 +357,11 @@ private bool GetStandardAndLiftedBinopSignatures(List rgbofs, BinO switch (GetConvKind(info.ptRaw2, bos.pt2)) { default: - grflt = grflt | LiftFlags.Convert2; + grflt |= LiftFlags.Convert2; break; case ConvKind.Implicit: case ConvKind.Identity: - grflt = grflt | LiftFlags.Lift2; + grflt |= LiftFlags.Lift2; break; } break; @@ -750,7 +750,7 @@ private bool CanConvertArg1(BinOpArgInfo info, CType typeDst, out LiftFlags pgrf if (info.type2 is NullableType) { - pgrflt = pgrflt | LiftFlags.Lift2; + pgrflt |= LiftFlags.Lift2; ptypeSig2 = TypeManager.GetNullable(info.typeRaw2); } else @@ -785,7 +785,7 @@ private bool CanConvertArg2(BinOpArgInfo info, CType typeDst, out LiftFlags pgrf if (info.type1 is NullableType) { - pgrflt = pgrflt | LiftFlags.Lift1; + pgrflt |= LiftFlags.Lift1; ptypeSig1 = TypeManager.GetNullable(info.typeRaw1); } else @@ -809,7 +809,7 @@ private static void RecordBinOpSigFromArgs(List prgbofs, BinOpArgI if (info.type1 != info.typeRaw1) { Debug.Assert(info.type1 is NullableType); - grflt = grflt | LiftFlags.Lift1; + grflt |= LiftFlags.Lift1; typeSig1 = TypeManager.GetNullable(info.typeRaw1); } else @@ -820,7 +820,7 @@ private static void RecordBinOpSigFromArgs(List prgbofs, BinOpArgI if (info.type2 != info.typeRaw2) { Debug.Assert(info.type2 is NullableType); - grflt = grflt | LiftFlags.Lift2; + grflt |= LiftFlags.Lift2; typeSig2 = TypeManager.GetNullable(info.typeRaw2); } else @@ -1482,11 +1482,11 @@ private bool FindApplicableSignatures( switch (GetConvKind(ptRaw, uos.pt)) { default: - grflt = grflt | LiftFlags.Convert1; + grflt |= LiftFlags.Convert1; break; case ConvKind.Implicit: case ConvKind.Identity: - grflt = grflt | LiftFlags.Lift1; + grflt |= LiftFlags.Lift1; break; } diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/SymbolTable.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/SymbolTable.cs index c2056e5b0d2c3..b2f31a5eaf56d 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/SymbolTable.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/SymbolTable.cs @@ -213,7 +213,7 @@ private static void AddNamesInInheritanceHierarchy(string name, List inher else if (member is EventInfo e) { // Store events until after all fields - (events = events ?? new List()).Add(e); + (events ??= new List()).Add(e); } } while (memberEn.MoveNext()); diff --git a/src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/src/Microsoft/Diagnostics/Tracing/StubEnvironment.cs b/src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/src/Microsoft/Diagnostics/Tracing/StubEnvironment.cs index 11bb615d361fd..7e1a49cff5c08 100644 --- a/src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/src/Microsoft/Diagnostics/Tracing/StubEnvironment.cs +++ b/src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/src/Microsoft/Diagnostics/Tracing/StubEnvironment.cs @@ -37,7 +37,7 @@ public static int PopCount(uint value) const uint c3 = 0x_0F0F0F0Fu; const uint c4 = 0x_01010101u; - value = value - ((value >> 1) & c1); + value -= (value >> 1) & c1; value = (value & c2) + ((value >> 2) & c2); value = (((value + (value >> 4)) & c3) * c4) >> 24; diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs index 1b22c43223519..f058108744c60 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs @@ -64,7 +64,7 @@ internal ServiceProvider(ICollection serviceDescriptors, Serv } catch (Exception e) { - exceptions = exceptions ?? new List(); + exceptions ??= new List(); exceptions.Add(e); } } diff --git a/src/libraries/Microsoft.Extensions.FileSystemGlobbing/src/Internal/PatternContexts/PatternContextLinear.cs b/src/libraries/Microsoft.Extensions.FileSystemGlobbing/src/Internal/PatternContexts/PatternContextLinear.cs index 070ed6cac80be..29a53d0e7d0f8 100644 --- a/src/libraries/Microsoft.Extensions.FileSystemGlobbing/src/Internal/PatternContexts/PatternContextLinear.cs +++ b/src/libraries/Microsoft.Extensions.FileSystemGlobbing/src/Internal/PatternContexts/PatternContextLinear.cs @@ -58,7 +58,7 @@ public override void PushDirectory(DirectoryInfoBase directory) } // directory matches segment, advance position in pattern - frame.SegmentIndex = frame.SegmentIndex + 1; + frame.SegmentIndex++; } PushDataFrame(frame); diff --git a/src/libraries/Microsoft.Extensions.Options/src/OptionsManager.cs b/src/libraries/Microsoft.Extensions.Options/src/OptionsManager.cs index f5a74423c2f53..f6e4294b54931 100644 --- a/src/libraries/Microsoft.Extensions.Options/src/OptionsManager.cs +++ b/src/libraries/Microsoft.Extensions.Options/src/OptionsManager.cs @@ -36,7 +36,7 @@ public OptionsManager(IOptionsFactory factory) /// public virtual TOptions Get(string? name) { - name = name ?? Options.DefaultName; + name ??= Options.DefaultName; if (!_cache.TryGetValue(name, out TOptions? options)) { diff --git a/src/libraries/Microsoft.Extensions.Options/src/OptionsMonitor.cs b/src/libraries/Microsoft.Extensions.Options/src/OptionsMonitor.cs index 3f1c02900f629..39301d8816e85 100644 --- a/src/libraries/Microsoft.Extensions.Options/src/OptionsMonitor.cs +++ b/src/libraries/Microsoft.Extensions.Options/src/OptionsMonitor.cs @@ -63,7 +63,7 @@ void RegisterSource(IOptionsChangeTokenSource source) private void InvokeChanged(string? name) { - name = name ?? Options.DefaultName; + name ??= Options.DefaultName; _cache.TryRemove(name); TOptions options = Get(name); if (_onChange != null) diff --git a/src/libraries/Microsoft.XmlSerializer.Generator/src/Sgen.cs b/src/libraries/Microsoft.XmlSerializer.Generator/src/Sgen.cs index dc33ea08edceb..da545994e8e76 100644 --- a/src/libraries/Microsoft.XmlSerializer.Generator/src/Sgen.cs +++ b/src/libraries/Microsoft.XmlSerializer.Generator/src/Sgen.cs @@ -319,7 +319,7 @@ private static void GenerateFile(List typeNames, string defaultNamespace var allMappings = mappings.ToArray(); bool gac = assembly.GlobalAssemblyCache; - outputDirectory = outputDirectory ?? (gac ? Environment.CurrentDirectory : Path.GetDirectoryName(assembly.Location)); + outputDirectory ??= (gac ? Environment.CurrentDirectory : Path.GetDirectoryName(assembly.Location)); if (!Directory.Exists(outputDirectory)) { diff --git a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentBag.cs b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentBag.cs index 38dd19d79ada5..966cdc5cff097 100644 --- a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentBag.cs +++ b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentBag.cs @@ -749,8 +749,8 @@ internal void LocalPush(T item, ref long emptyToNonEmptyListTransitionCount) // the bit-masking, because we only do this if tail == int.MaxValue, meaning that all // bits are set, so all of the bits we're keeping will also be set. Thus it's impossible // for the head to end up > than the tail, since you can't set any more bits than all of them. - _headIndex = _headIndex & _mask; - _tailIndex = tail = tail & _mask; + _headIndex &= _mask; + _tailIndex = tail &= _mask; Debug.Assert(_headIndex - _tailIndex <= 0); Interlocked.Exchange(ref _currentOp, (int)Operation.Add); // ensure subsequent reads aren't reordered before this diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Builder.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Builder.cs index 601acadd2181d..4ab4c163f74d8 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Builder.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Builder.cs @@ -770,7 +770,7 @@ public int IndexOf(T item, int startIndex, int count, IEqualityComparer? equa Requires.Range(startIndex >= 0 && startIndex < this.Count, nameof(startIndex)); Requires.Range(count >= 0 && startIndex + count <= this.Count, nameof(count)); - equalityComparer = equalityComparer ?? EqualityComparer.Default; + equalityComparer ??= EqualityComparer.Default; if (equalityComparer == EqualityComparer.Default) { return Array.IndexOf(_elements, item, startIndex, count); @@ -867,7 +867,7 @@ public int LastIndexOf(T item, int startIndex, int count, IEqualityComparer? Requires.Range(startIndex >= 0 && startIndex < this.Count, nameof(startIndex)); Requires.Range(count >= 0 && startIndex - count + 1 >= 0, nameof(count)); - equalityComparer = equalityComparer ?? EqualityComparer.Default; + equalityComparer ??= EqualityComparer.Default; if (equalityComparer == EqualityComparer.Default) { return Array.LastIndexOf(_elements, item, startIndex, count); diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.cs index d539592686ead..e1d6e003b1cb7 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.cs @@ -166,7 +166,7 @@ public int IndexOf(T item, int startIndex, int count, IEqualityComparer? equa Requires.Range(startIndex >= 0 && startIndex < self.Length, nameof(startIndex)); Requires.Range(count >= 0 && startIndex + count <= self.Length, nameof(count)); - equalityComparer = equalityComparer ?? EqualityComparer.Default; + equalityComparer ??= EqualityComparer.Default; if (equalityComparer == EqualityComparer.Default) { return Array.IndexOf(self.array!, item, startIndex, count); @@ -251,7 +251,7 @@ public int LastIndexOf(T item, int startIndex, int count, IEqualityComparer? Requires.Range(startIndex >= 0 && startIndex < self.Length, nameof(startIndex)); Requires.Range(count >= 0 && startIndex - count + 1 >= 0, nameof(count)); - equalityComparer = equalityComparer ?? EqualityComparer.Default; + equalityComparer ??= EqualityComparer.Default; if (equalityComparer == EqualityComparer.Default) { return Array.LastIndexOf(self.array!, item, startIndex, count); diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.Node.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.Node.cs index 061e5cd06fbdb..bc64c46c910cb 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.Node.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.Node.cs @@ -636,7 +636,7 @@ internal int BinarySearch(int index, int count, T item, IComparer? comparer) { Requires.Range(index >= 0, nameof(index)); Requires.Range(count >= 0, nameof(count)); - comparer = comparer ?? Comparer.Default; + comparer ??= Comparer.Default; if (this.IsEmpty || count <= 0) { @@ -748,7 +748,7 @@ internal int IndexOf(T item, int index, int count, IEqualityComparer? equalit Requires.Range(count <= this.Count, nameof(count)); Requires.Range(index + count <= this.Count, nameof(count)); - equalityComparer = equalityComparer ?? EqualityComparer.Default; + equalityComparer ??= EqualityComparer.Default; using (var enumerator = new Enumerator(this, startIndex: index, count: count)) { while (enumerator.MoveNext()) @@ -789,7 +789,7 @@ internal int LastIndexOf(T item, int index, int count, IEqualityComparer? equ Requires.Range(count >= 0 && count <= this.Count, nameof(count)); Requires.Argument(index - count + 1 >= 0); - equalityComparer = equalityComparer ?? EqualityComparer.Default; + equalityComparer ??= EqualityComparer.Default; using (var enumerator = new Enumerator(this, startIndex: index, count: count, reversed: true)) { while (enumerator.MoveNext()) diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ContractNameServices.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ContractNameServices.cs index e6c4d6187dc34..d19b5da90618b 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ContractNameServices.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ContractNameServices.cs @@ -32,7 +32,7 @@ private static Dictionary TypeIdentityCache { get { - return typeIdentityCache = typeIdentityCache ?? new Dictionary(); + return typeIdentityCache ??= new Dictionary(); } } diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ComposablePartCatalogCollection.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ComposablePartCatalogCollection.cs index 58007738a8ed4..810834261e25c 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ComposablePartCatalogCollection.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ComposablePartCatalogCollection.cs @@ -32,7 +32,7 @@ public ComposablePartCatalogCollection( Action? onChanged, Action? onChanging) { - catalogs = catalogs ?? Enumerable.Empty(); + catalogs ??= Enumerable.Empty(); _catalogs = new List(catalogs); _onChanged = onChanged; _onChanging = onChanging; diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ImportType.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ImportType.cs index 94927096b3f98..6614acd0a6326 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ImportType.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ImportType.cs @@ -28,7 +28,7 @@ private static Dictionary?> CastSingleValueCache { get { - return _castSingleValueCache = _castSingleValueCache ?? new Dictionary?>(); + return _castSingleValueCache ??= new Dictionary?>(); } } diff --git a/src/libraries/System.Composition.Runtime/src/System/Composition/Hosting/Core/CompositionContract.cs b/src/libraries/System.Composition.Runtime/src/System/Composition/Hosting/Core/CompositionContract.cs index ebb14362686ec..641dde6524a5e 100644 --- a/src/libraries/System.Composition.Runtime/src/System/Composition/Hosting/Core/CompositionContract.cs +++ b/src/libraries/System.Composition.Runtime/src/System/Composition/Hosting/Core/CompositionContract.cs @@ -90,9 +90,9 @@ public override int GetHashCode() { var hc = _contractType.GetHashCode(); if (_contractName != null) - hc = hc ^ _contractName.GetHashCode(); + hc ^= _contractName.GetHashCode(); if (_metadataConstraints != null) - hc = hc ^ ConstraintHashCode(_metadataConstraints); + hc ^= ConstraintHashCode(_metadataConstraints); return hc; } diff --git a/src/libraries/System.Composition.TypedParts/src/System/Composition/TypedParts/ContractHelpers.cs b/src/libraries/System.Composition.TypedParts/src/System/Composition/TypedParts/ContractHelpers.cs index 3794657f43869..338c6ee039b43 100644 --- a/src/libraries/System.Composition.TypedParts/src/System/Composition/TypedParts/ContractHelpers.cs +++ b/src/libraries/System.Composition.TypedParts/src/System/Composition/TypedParts/ContractHelpers.cs @@ -47,7 +47,7 @@ public static ImportInfo GetImportInfo(Type memberType, object[] attributes, obj var ima = attr as ImportManyAttribute; if (ima != null) { - importMetadata = importMetadata ?? new Dictionary(); + importMetadata ??= new Dictionary(); importMetadata.Add(ImportManyImportMetadataConstraintName, true); importedContract = new CompositionContract(memberType, ima.ContractName); explicitImportsApplied++; @@ -57,7 +57,7 @@ public static ImportInfo GetImportInfo(Type memberType, object[] attributes, obj var imca = attr as ImportMetadataConstraintAttribute; if (imca != null) { - importMetadata = importMetadata ?? new Dictionary(); + importMetadata ??= new Dictionary(); importMetadata.Add(imca.Name, imca.Value); } } @@ -72,7 +72,7 @@ public static ImportInfo GetImportInfo(Type memberType, object[] attributes, obj .GetRuntimeProperties() .Where(p => p.GetMethod.IsPublic && p.DeclaringType == attrType && p.CanRead)) { - importMetadata = importMetadata ?? new Dictionary(); + importMetadata ??= new Dictionary(); importMetadata.Add(prop.Name, prop.GetValue(attr, null)); } } diff --git a/src/libraries/System.Composition.TypedParts/src/System/Composition/TypedParts/Discovery/TypeInspector.cs b/src/libraries/System.Composition.TypedParts/src/System/Composition/TypedParts/Discovery/TypeInspector.cs index 4175cd37dfc8c..322220c0fd842 100644 --- a/src/libraries/System.Composition.TypedParts/src/System/Composition/TypedParts/Discovery/TypeInspector.cs +++ b/src/libraries/System.Composition.TypedParts/src/System/Composition/TypedParts/Discovery/TypeInspector.cs @@ -33,7 +33,7 @@ public bool InspectTypeForPart(TypeInfo type, out DiscoveredPart part) foreach (var export in DiscoverExports(type)) { - part = part ?? new DiscoveredPart(type, _attributeContext, _activationFeatures); + part ??= new DiscoveredPart(type, _attributeContext, _activationFeatures); part.AddDiscoveredExport(export); } diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/StringAttributeCollection.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/StringAttributeCollection.cs index b91713cc7ad18..68b28f95daa00 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/StringAttributeCollection.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/StringAttributeCollection.cs @@ -66,7 +66,7 @@ public override string ToString() sb.Append(','); } - if (sb.Length > 0) sb.Length = sb.Length - 1; + if (sb.Length > 0) sb.Length--; return sb.Length == 0 ? null : sb.ToString(); } diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/ByteStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/ByteStorage.cs index c8a777db67b6b..8d894f40a2d5d 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/ByteStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/ByteStorage.cs @@ -88,7 +88,7 @@ public override object Aggregate(int[] records, AggregateType kind) if ((prec < 1e-15) || (var < 0)) var = 0; else - var = var / (count * (count - 1)); + var /= (count * (count - 1)); if (kind == AggregateType.StDev) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DataRecordInternal.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DataRecordInternal.cs index 046366210dc55..4f2a9cee00d62 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DataRecordInternal.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DataRecordInternal.cs @@ -131,7 +131,7 @@ public override long GetBytes(int i, long dataIndex, byte[]? buffer, int bufferI { // help the user out in the case where there's less data than requested if ((ndataIndex + length) > cbytes) - cbytes = cbytes - ndataIndex; + cbytes -= ndataIndex; else cbytes = length; } @@ -205,7 +205,7 @@ public override long GetChars(int i, long dataIndex, char[]? buffer, int bufferI // help the user out in the case where there's less data than requested if ((ndataIndex + length) > cchars) { - cchars = cchars - ndataIndex; + cchars -= ndataIndex; } else { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DecimalStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DecimalStorage.cs index 5c145272abb93..6e38415ca1aaa 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DecimalStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DecimalStorage.cs @@ -91,7 +91,7 @@ public override object Aggregate(int[] records, AggregateType kind) if ((prec < 1e-15) || (var < 0)) var = 0; else - var = var / (count * (count - 1)); + var /= (count * (count - 1)); if (kind == AggregateType.StDev) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DoubleStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DoubleStorage.cs index 73f17e241e96f..71d54b9b68f9b 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DoubleStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DoubleStorage.cs @@ -88,7 +88,7 @@ public override object Aggregate(int[] records, AggregateType kind) if ((prec < 1e-15) || (var < 0)) var = 0; else - var = var / (count * (count - 1)); + var /= (count * (count - 1)); if (kind == AggregateType.StDev) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/Int16Storage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/Int16Storage.cs index ceac9585cb383..a8d050ecf70f9 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/Int16Storage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/Int16Storage.cs @@ -91,7 +91,7 @@ public override object Aggregate(int[] records, AggregateType kind) if ((prec < 1e-15) || (var < 0)) var = 0; else - var = var / (count * (count - 1)); + var /= (count * (count - 1)); if (kind == AggregateType.StDev) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/Int32Storage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/Int32Storage.cs index 11da865400b63..20239c6e2879f 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/Int32Storage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/Int32Storage.cs @@ -91,7 +91,7 @@ public override object Aggregate(int[] records, AggregateType kind) if ((prec < 1e-15) || (var < 0)) var = 0; else - var = var / (count * (count - 1)); + var /= (count * (count - 1)); if (kind == AggregateType.StDev) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/Int64Storage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/Int64Storage.cs index bb0f519ada080..831f579bf17ab 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/Int64Storage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/Int64Storage.cs @@ -91,7 +91,7 @@ public override object Aggregate(int[] records, AggregateType kind) if ((prec < 1e-15) || (var < 0)) var = 0; else - var = var / (count * (count - 1)); + var /= (count * (count - 1)); if (kind == AggregateType.StDev) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SByteStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SByteStorage.cs index dc58d20033c06..a2534dc7671c5 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SByteStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SByteStorage.cs @@ -88,7 +88,7 @@ public override object Aggregate(int[] records, AggregateType kind) if ((prec < 1e-15) || (var < 0)) var = 0; else - var = var / (count * (count - 1)); + var /= (count * (count - 1)); if (kind == AggregateType.StDev) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLByteStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLByteStorage.cs index 85b4ea53891fa..d5294635702d0 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLByteStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLByteStorage.cs @@ -90,7 +90,7 @@ public override object Aggregate(int[] records, AggregateType kind) if ((prec < 1e-15) || (var < 0)) var = 0; else - var = var / (count * (count - 1)); + var /= (count * (count - 1)); if (kind == AggregateType.StDev) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDecimalStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDecimalStorage.cs index fb2e0b30c8771..c52cec0cc0046 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDecimalStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDecimalStorage.cs @@ -90,7 +90,7 @@ public override object Aggregate(int[] records, AggregateType kind) if ((prec < 1e-15) || (var < 0)) var = 0; else - var = var / (count * (count - 1)); + var /= (count * (count - 1)); if (kind == AggregateType.StDev) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDoubleStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDoubleStorage.cs index a9e78552afe9f..3653467086d35 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDoubleStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDoubleStorage.cs @@ -90,7 +90,7 @@ public override object Aggregate(int[] records, AggregateType kind) if ((prec < 1e-15) || (var < 0)) var = 0; else - var = var / (count * (count - 1)); + var /= (count * (count - 1)); if (kind == AggregateType.StDev) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt16Storage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt16Storage.cs index e210830f4bc90..4b7f61643ff02 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt16Storage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt16Storage.cs @@ -90,7 +90,7 @@ public override object Aggregate(int[] records, AggregateType kind) if ((prec < 1e-15) || (var < 0)) var = 0; else - var = var / (count * (count - 1)); + var /= (count * (count - 1)); if (kind == AggregateType.StDev) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt32Storage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt32Storage.cs index d2a1b8118f702..1f0852fed5d8c 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt32Storage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt32Storage.cs @@ -90,7 +90,7 @@ public override object Aggregate(int[] records, AggregateType kind) if ((prec < 1e-15) || (var < 0)) var = 0; else - var = var / (count * (count - 1)); + var /= (count * (count - 1)); if (kind == AggregateType.StDev) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt64Storage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt64Storage.cs index 83d7e548f084c..fa23bd6e441e5 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt64Storage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt64Storage.cs @@ -90,7 +90,7 @@ public override object Aggregate(int[] records, AggregateType kind) if ((prec < 1e-15) || (var < 0)) var = 0; else - var = var / (count * (count - 1)); + var /= (count * (count - 1)); if (kind == AggregateType.StDev) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLMoneyStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLMoneyStorage.cs index f220e760f4ebb..c2bd8eb9086eb 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLMoneyStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLMoneyStorage.cs @@ -90,7 +90,7 @@ public override object Aggregate(int[] records, AggregateType kind) if ((prec < 1e-15) || (var < 0)) var = 0; else - var = var / (count * (count - 1)); + var /= (count * (count - 1)); if (kind == AggregateType.StDev) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLSingleStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLSingleStorage.cs index 1250ed55ec495..f3357fe0b53a0 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLSingleStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLSingleStorage.cs @@ -90,7 +90,7 @@ public override object Aggregate(int[] records, AggregateType kind) if ((prec < 1e-15) || (var < 0)) var = 0; else - var = var / (count * (count - 1)); + var /= (count * (count - 1)); if (kind == AggregateType.StDev) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLStringStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLStringStorage.cs index d9413cd0e357d..57767ef64a5e9 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLStringStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLStringStorage.cs @@ -38,7 +38,7 @@ public override object Aggregate(int[] recordNos, AggregateType kind) } if (min >= 0) { - for (i = i + 1; i < recordNos.Length; i++) + for (i++; i < recordNos.Length; i++) { if (IsNull(recordNos[i])) continue; @@ -63,7 +63,7 @@ public override object Aggregate(int[] recordNos, AggregateType kind) } if (max >= 0) { - for (i = i + 1; i < recordNos.Length; i++) + for (i++; i < recordNos.Length; i++) { if (Compare(max, recordNos[i]) < 0) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SingleStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SingleStorage.cs index d7f0f5884b67c..99240898fa4f3 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SingleStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SingleStorage.cs @@ -88,7 +88,7 @@ public override object Aggregate(int[] records, AggregateType kind) if ((prec < 1e-15) || (var < 0)) var = 0; else - var = var / (count * (count - 1)); + var /= (count * (count - 1)); if (kind == AggregateType.StDev) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/StringStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/StringStorage.cs index db06db53dcd33..f3e457b8569c3 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/StringStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/StringStorage.cs @@ -33,7 +33,7 @@ public override object Aggregate(int[] recordNos, AggregateType kind) } if (min >= 0) { - for (i = i + 1; i < recordNos.Length; i++) + for (i++; i < recordNos.Length; i++) { if (IsNull(recordNos[i])) continue; @@ -57,7 +57,7 @@ public override object Aggregate(int[] recordNos, AggregateType kind) } if (max >= 0) { - for (i = i + 1; i < recordNos.Length; i++) + for (i++; i < recordNos.Length; i++) { if (Compare(max, recordNos[i]) < 0) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/UInt16Storage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/UInt16Storage.cs index a8a75051ef01c..dfbf07c8da5da 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/UInt16Storage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/UInt16Storage.cs @@ -91,7 +91,7 @@ public override object Aggregate(int[] records, AggregateType kind) if ((prec < 1e-15) || (var < 0)) var = 0; else - var = var / (count * (count - 1)); + var /= (count * (count - 1)); if (kind == AggregateType.StDev) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/UInt32Storage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/UInt32Storage.cs index 53a815a262a86..d893058e84b33 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/UInt32Storage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/UInt32Storage.cs @@ -91,7 +91,7 @@ public override object Aggregate(int[] records, AggregateType kind) if ((prec < 1e-15) || (var < 0)) var = 0; else - var = var / (count * (count - 1)); + var /= (count * (count - 1)); if (kind == AggregateType.StDev) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/UInt64Storage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/UInt64Storage.cs index fa18cdee966a6..9feaa5e4ff724 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/UInt64Storage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/UInt64Storage.cs @@ -91,7 +91,7 @@ public override object Aggregate(int[] records, AggregateType kind) if ((prec < 1e-15) || (var < 0)) var = 0; else - var = var / (count * (count - 1)); + var /= (count * (count - 1)); if (kind == AggregateType.StDev) { diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs index e3af9a2cfcb89..83ad2822fd1c2 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs @@ -2225,7 +2225,7 @@ private uint DivByULong(uint iDivisor) ulQuotientCur = (uint)(dwlAccum / dwlDivisor); rguiData[iData - 1] = ulQuotientCur; //Remainder to be carried to the next lower significant byte. - dwlAccum = dwlAccum % dwlDivisor; + dwlAccum %= dwlDivisor; // While current part of quotient still 0, reduce length if (fAllZero && (ulQuotientCur == 0)) diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLMoney.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLMoney.cs index 64c0d168631c8..24f6a1432f0e1 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLMoney.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLMoney.cs @@ -150,7 +150,7 @@ public long ToInt64() long ret = _value / (s_lTickBase / 10); bool fPositive = (ret >= 0); long remainder = ret % 10; - ret = ret / 10; + ret /= 10; if (remainder >= 5) { diff --git a/src/libraries/System.Data.Common/src/System/Data/XMLSchema.cs b/src/libraries/System.Data.Common/src/System/Data/XMLSchema.cs index 164b3731bdccb..0304f2522d24b 100644 --- a/src/libraries/System.Data.Common/src/System/Data/XMLSchema.cs +++ b/src/libraries/System.Data.Common/src/System/Data/XMLSchema.cs @@ -1493,7 +1493,7 @@ internal DataTable InstantiateSimpleTable(XmlSchemaElement node) int i = 0; colName = typeName + "_Text"; while (table.Columns[colName] != null) - colName = colName + i++; + colName += i++; } else { @@ -2003,7 +2003,7 @@ internal void HandleSimpleTypeSimpleContentColumn(XmlSchemaSimpleType typeNode, colName = table.TableName + "_Text"; while (table.Columns[colName] != null) { - colName = colName + i++; + colName += i++; } } else @@ -2115,7 +2115,7 @@ internal void HandleSimpleContentColumn(string strType, DataTable table, bool is colName = table.TableName + "_Text"; while (table.Columns[colName] != null) { - colName = colName + i++; + colName += i++; } } else diff --git a/src/libraries/System.Data.Common/src/System/Data/xmlsaver.cs b/src/libraries/System.Data.Common/src/System/Data/xmlsaver.cs index 32f72f51f01b1..c8d9513cf0361 100644 --- a/src/libraries/System.Data.Common/src/System/Data/xmlsaver.cs +++ b/src/libraries/System.Data.Common/src/System/Data/xmlsaver.cs @@ -1093,7 +1093,7 @@ internal void SetPath(XmlWriter xw) _fileName = Path.GetFileNameWithoutExtension(fs.Name); _fileExt = Path.GetExtension(fs.Name); if (!string.IsNullOrEmpty(_filePath)) - _filePath = _filePath + "\\"; + _filePath += "\\"; } [RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)] diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnection.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnection.cs index 6e95445410917..69329e3e4a3a0 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnection.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnection.cs @@ -844,7 +844,7 @@ internal bool TestTypeSupport(ODBC32.SQL_TYPE sqltype) int flags; flags = GetInfoInt32Unhandled((ODBC32.SQL_INFO)sqlconvert); - flags = flags & (int)sqlcvt; + flags &= (int)sqlcvt; ProviderInfo.TestedSQLTypes |= (int)sqlcvt; ProviderInfo.SupportedSQLTypes |= flags; diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcMetaDataFactory.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcMetaDataFactory.cs index 78ffdf1dc1614..4f373a5ceac36 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcMetaDataFactory.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcMetaDataFactory.cs @@ -636,19 +636,19 @@ private DataTable GetDataSourceInformationCollection(string?[]? restrictions, Common.SupportedJoinOperators supportedJoinOperators = Common.SupportedJoinOperators.None; if ((int32Value & (int)ODBC32.SQL_OJ_CAPABILITIES.LEFT) != 0) { - supportedJoinOperators = supportedJoinOperators | Common.SupportedJoinOperators.LeftOuter; + supportedJoinOperators |= Common.SupportedJoinOperators.LeftOuter; } if ((int32Value & (int)ODBC32.SQL_OJ_CAPABILITIES.RIGHT) != 0) { - supportedJoinOperators = supportedJoinOperators | Common.SupportedJoinOperators.RightOuter; + supportedJoinOperators |= Common.SupportedJoinOperators.RightOuter; } if ((int32Value & (int)ODBC32.SQL_OJ_CAPABILITIES.FULL) != 0) { - supportedJoinOperators = supportedJoinOperators | Common.SupportedJoinOperators.FullOuter; + supportedJoinOperators |= Common.SupportedJoinOperators.FullOuter; } if ((int32Value & (int)ODBC32.SQL_OJ_CAPABILITIES.INNER) != 0) { - supportedJoinOperators = supportedJoinOperators | Common.SupportedJoinOperators.Inner; + supportedJoinOperators |= Common.SupportedJoinOperators.Inner; } dataSourceInformation[DbMetaDataColumnNames.SupportedJoinOperators] = supportedJoinOperators; diff --git a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogReader.cs b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogReader.cs index c7a0b6b8ed1ad..4645d3024b182 100644 --- a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogReader.cs +++ b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogReader.cs @@ -218,7 +218,7 @@ internal void SeekCommon(long offset) // fact that we've already read some events in our buffer that the user // hasn't seen yet. // - offset = offset - (_eventCount - _currentIndex); + offset -= (_eventCount - _currentIndex); SeekReset(); diff --git a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventMetadata.cs b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventMetadata.cs index 2b3f74a261b96..4e2d2128b6ff7 100644 --- a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventMetadata.cs +++ b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventMetadata.cs @@ -100,7 +100,7 @@ public IEnumerable Keywords // theKeywords = theKeywords - mask; } // Modify the mask to check next bit. - mask = mask >> 1; + mask >>= 1; } return list; diff --git a/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/SharedPerformanceCounter.cs b/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/SharedPerformanceCounter.cs index 7ef3659bbd3e4..99e1f3395c14f 100644 --- a/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/SharedPerformanceCounter.cs +++ b/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/SharedPerformanceCounter.cs @@ -193,7 +193,7 @@ private int CalculateMemoryNoBoundsCheck(int oldOffset, int totalSize, out int a // make sure the start address is 8 byte aligned int startAddressMod8 = (int)(_baseAddress + oldOffset) & 0x7; alignmentAdjustment = (8 - startAddressMod8) & 0x7; - currentTotalSize = currentTotalSize + alignmentAdjustment; + currentTotalSize += alignmentAdjustment; int newOffset = oldOffset + currentTotalSize; @@ -670,7 +670,7 @@ private unsafe CategoryData GetCategoryData() { fileMappingSize = GetFileMappingSizeFromConfig(); if (data.UseUniqueSharedMemory) - fileMappingSize = fileMappingSize >> 2; // if we have a custom filemapping, only make it 25% as large. + fileMappingSize >>= 2; // if we have a custom filemapping, only make it 25% as large. } // now read the counter names diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.NonUap.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.NonUap.cs index b97658c52fc8b..cd4269d5373af 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.NonUap.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.NonUap.cs @@ -72,7 +72,7 @@ private bool IsSelfOrDescendantOf(Process processOfInterest) private List GetChildProcesses(Process[]? processes = null) { bool internallyInitializedProcesses = processes == null; - processes = processes ?? GetProcesses(); + processes ??= GetProcesses(); List childProcesses = new List(); diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/RangeRetriever.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/RangeRetriever.cs index 0be16009b54b8..3e0fee4f1b097 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/RangeRetriever.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/RangeRetriever.cs @@ -192,7 +192,7 @@ private IEnumerator GetNextChunk() } else { - _lowRange = _lowRange + pvc.Count; + _lowRange += pvc.Count; GlobalDebug.WriteLineIf(GlobalDebug.Info, "RangeRetriever", diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/SDSUtils.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/SDSUtils.cs index d747da6bfe3d3..6f6f5bee242ba 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/SDSUtils.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/SDSUtils.cs @@ -669,7 +669,7 @@ internal static void AccountControlToDirectoryEntry( if (!isSAM && de.Properties["msDS-User-Account-Control-Computed"].Count > 0) { Debug.Assert(de.Properties["msDS-User-Account-Control-Computed"].Count == 1); - uacValue = uacValue | (int)de.Properties["msDS-User-Account-Control-Computed"][0]; + uacValue |= (int)de.Properties["msDS-User-Account-Control-Computed"][0]; } } else diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLinkCollection.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLinkCollection.cs index 46e914c5efc6e..c19cb532cc5e1 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLinkCollection.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLinkCollection.cs @@ -53,7 +53,7 @@ public void AddRange(ActiveDirectorySiteLink[] links) if (links == null) throw new ArgumentNullException(nameof(links)); - for (int i = 0; i < links.Length; i = i + 1) + for (int i = 0; i < links.Length; i++) this.Add(links[i]); } diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Locator.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Locator.cs index d055b21f0343b..2909c7d44b7b9 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Locator.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Locator.cs @@ -224,7 +224,7 @@ private static Hashtable DnsQueryWrapper(string domainName, string siteName, lon } // now add the domainName - recordName = recordName + domainName; + recordName += domainName; // set the BYPASS CACHE option is specified if (((long)dcFlags & (long)LocatorOptions.ForceRediscovery) != 0) diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/ClientUtils.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/ClientUtils.cs index ec595b11cc034..a4ce3387b3ec3 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/ClientUtils.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/ClientUtils.cs @@ -143,8 +143,8 @@ private static void Copy(WeakRefCollection sourceList, int sourceIndex, WeakRefC // We need to copy from the back forward to prevent overwrite if source and // destination lists are the same, so we need to flip the source/dest indices // to point at the end of the spans to be copied. - sourceIndex = sourceIndex + length; - destinationIndex = destinationIndex + length; + sourceIndex += length; + destinationIndex += length; for (; length > 0; length--) { destinationList.InnerList[--destinationIndex] = sourceList.InnerList[--sourceIndex]; diff --git a/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateManaged/InputBuffer.cs b/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateManaged/InputBuffer.cs index 0fde03f8492a8..a8c592533a73f 100644 --- a/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateManaged/InputBuffer.cs +++ b/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateManaged/InputBuffer.cs @@ -219,7 +219,7 @@ public void SkipBits(int n) public void SkipToByteBoundary() { _bitBuffer >>= (_bitsInBuffer % 8); - _bitsInBuffer = _bitsInBuffer - (_bitsInBuffer % 8); + _bitsInBuffer -= (_bitsInBuffer % 8); } } } diff --git a/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs b/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs index 230daee5f6744..08f63807b2289 100644 --- a/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs +++ b/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs @@ -1280,7 +1280,7 @@ internal int GetDcbFlag(int whichFlag) internal void SetDcbFlag(int whichFlag, int setting) { uint mask; - setting = setting << whichFlag; + setting <<= whichFlag; Debug.Assert(whichFlag >= Interop.Kernel32.DCBFlags.FBINARY && whichFlag <= Interop.Kernel32.DCBFlags.FDUMMY2, "SetDcbFlag needs to fit into enum!"); @@ -1705,7 +1705,7 @@ private void CallEvents(int nativeEvents) return; } - errors = errors & ErrorEvents; + errors &= ErrorEvents; // TODO: what about CE_BREAK? Is this the same as EV_BREAK? EV_BREAK happens as one of the pin events, // but CE_BREAK is returned from ClreaCommError. // TODO: what about other error conditions not covered by the enum? Should those produce some other error? diff --git a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightCompiler.cs b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightCompiler.cs index 2c9edb8c4a321..a560068a6255d 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightCompiler.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightCompiler.cs @@ -241,7 +241,7 @@ int IComparer.Compare(DebugInfo? d1, DebugInfo? d2) return null; } //return the last one that is smaller - i = i - 1; + i--; } return debugInfos[i]; diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Partitioning/PartitionedDataSource.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Partitioning/PartitionedDataSource.cs index 1d43e57759141..be2778b054ca7 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Partitioning/PartitionedDataSource.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Partitioning/PartitionedDataSource.cs @@ -703,7 +703,7 @@ internal override bool MoveNext([MaybeNullWhen(false), AllowNull] ref T currentE { if ((mutables._chunkCounter++ & chunksPerChunkSize) == chunksPerChunkSize) { - mutables._nextChunkMaxSize = mutables._nextChunkMaxSize * 2; + mutables._nextChunkMaxSize *= 2; if (mutables._nextChunkMaxSize > chunkBuffer.Length) { mutables._nextChunkMaxSize = chunkBuffer.Length; diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/SortQueryOperator.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/SortQueryOperator.cs index be679efe9d760..7fb10e115a487 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/SortQueryOperator.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/SortQueryOperator.cs @@ -62,7 +62,7 @@ internal SortQueryOperator(IEnumerable source, Func IOrderedEnumerable.CreateOrderedEnumerable( Func key2Selector, IComparer? key2Comparer, bool descending) { - key2Comparer = key2Comparer ?? Util.GetDefaultComparer(); + key2Comparer ??= Util.GetDefaultComparer(); if (descending) { diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs index 96e7aa1a6b47e..81de50225cbd8 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs @@ -5139,7 +5139,7 @@ public static ILookup ToLookup( ArgumentNullException.ThrowIfNull(keySelector); // comparer may be null, in which case we use the default comparer. - comparer = comparer ?? EqualityComparer.Default; + comparer ??= EqualityComparer.Default; ParallelQuery> groupings = source.GroupBy(keySelector, comparer); @@ -5226,7 +5226,7 @@ public static ILookup ToLookup( ArgumentNullException.ThrowIfNull(elementSelector); // comparer may be null, in which case we use the default comparer. - comparer = comparer ?? EqualityComparer.Default; + comparer ??= EqualityComparer.Default; ParallelQuery> groupings = source.GroupBy(keySelector, elementSelector, comparer); diff --git a/src/libraries/System.Management/src/System/Management/ManagementDateTime.cs b/src/libraries/System.Management/src/System/Management/ManagementDateTime.cs index 5b29f245f3986..41cc474d38df1 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementDateTime.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementDateTime.cs @@ -260,12 +260,12 @@ public static string ToDmtfDateTime(DateTime date) string dmtfDateTime = date.Year.ToString(frmInt32).PadLeft(4, '0'); - dmtfDateTime = (dmtfDateTime + date.Month.ToString(frmInt32).PadLeft(2, '0')); - dmtfDateTime = (dmtfDateTime + date.Day.ToString(frmInt32).PadLeft(2, '0')); - dmtfDateTime = (dmtfDateTime + date.Hour.ToString(frmInt32).PadLeft(2, '0')); - dmtfDateTime = (dmtfDateTime + date.Minute.ToString(frmInt32).PadLeft(2, '0')); - dmtfDateTime = (dmtfDateTime + date.Second.ToString(frmInt32).PadLeft(2, '0')); - dmtfDateTime = (dmtfDateTime + "."); + dmtfDateTime += date.Month.ToString(frmInt32).PadLeft(2, '0'); + dmtfDateTime += date.Day.ToString(frmInt32).PadLeft(2, '0'); + dmtfDateTime += date.Hour.ToString(frmInt32).PadLeft(2, '0'); + dmtfDateTime += date.Minute.ToString(frmInt32).PadLeft(2, '0'); + dmtfDateTime += date.Second.ToString(frmInt32).PadLeft(2, '0'); + dmtfDateTime += "."; // Construct a DateTime with the precision to Second as same as the passed DateTime and so get // the ticks difference so that the microseconds can be calculated @@ -278,9 +278,9 @@ public static string ToDmtfDateTime(DateTime date) { strMicrosec = strMicrosec.Substring(0, 6); } - dmtfDateTime = dmtfDateTime + strMicrosec.PadLeft(6, '0'); + dmtfDateTime += strMicrosec.PadLeft(6, '0'); // adding the UTC offset - dmtfDateTime = dmtfDateTime + UtcString; + dmtfDateTime += UtcString; return dmtfDateTime; } @@ -370,7 +370,7 @@ public static TimeSpan ToTimeSpan(string dmtfTimespan) // Get a timepan for the additional ticks obtained for the microsecond part of DMTF time interval // and then add it to the original timespan TimeSpan tsTemp = System.TimeSpan.FromTicks(ticks); - timespan = timespan + tsTemp; + timespan += tsTemp; return timespan; } @@ -417,10 +417,10 @@ public static string ToDmtfTimeInterval(TimeSpan timespan) throw new System.ArgumentOutOfRangeException(nameof(timespan)); } - dmtftimespan = (dmtftimespan + timespan.Hours.ToString(frmInt32).PadLeft(2, '0')); - dmtftimespan = (dmtftimespan + timespan.Minutes.ToString(frmInt32).PadLeft(2, '0')); - dmtftimespan = (dmtftimespan + timespan.Seconds.ToString(frmInt32).PadLeft(2, '0')); - dmtftimespan = (dmtftimespan + "."); + dmtftimespan += timespan.Hours.ToString(frmInt32).PadLeft(2, '0'); + dmtftimespan += timespan.Minutes.ToString(frmInt32).PadLeft(2, '0'); + dmtftimespan += timespan.Seconds.ToString(frmInt32).PadLeft(2, '0'); + dmtftimespan += "."; // Construct a DateTime with the precision to Second as same as the passed DateTime and so get // the ticks difference so that the microseconds can be calculated @@ -433,9 +433,9 @@ public static string ToDmtfTimeInterval(TimeSpan timespan) { strMicrosec = strMicrosec.Substring(0, 6); } - dmtftimespan = dmtftimespan + strMicrosec.PadLeft(6, '0'); + dmtftimespan += strMicrosec.PadLeft(6, '0'); - dmtftimespan = dmtftimespan + ":000"; + dmtftimespan += ":000"; return dmtftimespan; } diff --git a/src/libraries/System.Management/src/System/Management/ManagementPath.cs b/src/libraries/System.Management/src/System/Management/ManagementPath.cs index 7dd7af05b81a8..633b3064122cf 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementPath.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementPath.cs @@ -271,7 +271,7 @@ private static void SetWbemPath(IWbemPath wbemPath, string path) // this is because in the case of "root", the path parser cannot tell whether // this is a namespace name or a class name if (string.Equals(path, "root", StringComparison.OrdinalIgnoreCase)) - flags = flags | (uint)tag_WBEM_PATH_CREATE_FLAG.WBEMPATH_TREAT_SINGLE_IDENT_AS_NS; + flags |= (uint)tag_WBEM_PATH_CREATE_FLAG.WBEMPATH_TREAT_SINGLE_IDENT_AS_NS; int status = wbemPath.SetText_(flags, path); diff --git a/src/libraries/System.Management/src/System/Management/ManagementQuery.cs b/src/libraries/System.Management/src/System/Management/ManagementQuery.cs index e9e0fe736317c..64816f8c3a0cd 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementQuery.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementQuery.cs @@ -932,7 +932,7 @@ protected internal void BuildQuery() s = s + selectedProperties[i] + ((i == (count - 1)) ? " " : ","); } else - s = s + "* "; + s += "* "; //From clause s = s + "from " + className; @@ -2993,7 +2993,7 @@ protected internal void BuildQuery() if ((null != groupByPropertyList) && (0 < groupByPropertyList.Count)) { int count = groupByPropertyList.Count; - s = s + " by "; + s += " by "; for (int i = 0; i < count; i++) s = s + groupByPropertyList[i] + (i == (count - 1) ? "" : ","); diff --git a/src/libraries/System.Management/src/System/Management/PropertySet.cs b/src/libraries/System.Management/src/System/Management/PropertySet.cs index 8e748bfcf913a..390b718cc8b79 100644 --- a/src/libraries/System.Management/src/System/Management/PropertySet.cs +++ b/src/libraries/System.Management/src/System/Management/PropertySet.cs @@ -461,7 +461,7 @@ public void Add(string propertyName, object propertyValue, CimType propertyType) if ((null != propertyValue) && propertyValue.GetType().IsArray) { isArray = true; - wmiCimType = (wmiCimType | (int)tag_CIMTYPE_ENUMERATION.CIM_FLAG_ARRAY); + wmiCimType |= (int)tag_CIMTYPE_ENUMERATION.CIM_FLAG_ARRAY; } object wmiValue = PropertyData.MapValueToWmiValue(propertyValue, propertyType, isArray); @@ -500,7 +500,7 @@ public void Add(string propertyName, CimType propertyType, bool isArray) int wmiCimType = (int)propertyType; if (isArray) - wmiCimType = (wmiCimType | (int)tag_CIMTYPE_ENUMERATION.CIM_FLAG_ARRAY); + wmiCimType |= (int)tag_CIMTYPE_ENUMERATION.CIM_FLAG_ARRAY; object dummyObj = System.DBNull.Value; diff --git a/src/libraries/System.Management/src/System/Management/QualifierSet.cs b/src/libraries/System.Management/src/System/Management/QualifierSet.cs index 528f244a8c1a9..a25f73559c3a7 100644 --- a/src/libraries/System.Management/src/System/Management/QualifierSet.cs +++ b/src/libraries/System.Management/src/System/Management/QualifierSet.cs @@ -464,12 +464,12 @@ public virtual void Add(string qualifierName, object qualifierValue, bool isAmen //Build the flavors bitmask and call the internal Add that takes a bitmask int qualFlavor = 0; - if (isAmended) qualFlavor = (qualFlavor | (int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_AMENDED); - if (propagatesToInstance) qualFlavor = (qualFlavor | (int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE); - if (propagatesToSubclass) qualFlavor = (qualFlavor | (int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS); + if (isAmended) qualFlavor |= (int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_AMENDED; + if (propagatesToInstance) qualFlavor |= (int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE; + if (propagatesToSubclass) qualFlavor |= (int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS; // Note we use the NOT condition here since WBEM_FLAVOR_OVERRIDABLE == 0 - if (!isOverridable) qualFlavor = (qualFlavor | (int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_NOT_OVERRIDABLE); + if (!isOverridable) qualFlavor |= (int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_NOT_OVERRIDABLE; //Try to add the qualifier to the WMI object int status = GetTypeQualifierSet().Put_(qualifierName, ref qualifierValue, qualFlavor); diff --git a/src/libraries/System.Management/src/System/Management/WMIGenerator.cs b/src/libraries/System.Management/src/System/Management/WMIGenerator.cs index 1c43875350a9c..f20286a94f090 100644 --- a/src/libraries/System.Management/src/System/Management/WMIGenerator.cs +++ b/src/libraries/System.Management/src/System/Management/WMIGenerator.cs @@ -563,7 +563,7 @@ private void InitializeClassObject() { if (bStart == true) { - OriginalNamespace = OriginalNamespace + arrString[i]; + OriginalNamespace += arrString[i]; } else if (arrString[i] == '\\') @@ -816,7 +816,7 @@ private string ResolveCollision(string inString, bool bCheckthisFirst) } catch (OverflowException) { - strToAdd = strToAdd + "_"; + strToAdd += "_"; k = 0; } strTemp = inString + strToAdd + k.ToString((IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(int))); @@ -972,7 +972,7 @@ private void GeneratePublicProperty(string propName, string propType, CodeExpres if (isStatic) { - cmp.Attributes = cmp.Attributes | MemberAttributes.Static; + cmp.Attributes |= MemberAttributes.Static; } caa = new CodeAttributeArgument(); @@ -1951,7 +1951,7 @@ private bool GeneratePropertyHelperEnums(PropertyData prop, string strPropertyNa // Now shift 1 more bit so that we can put it for the // next element in the enum - bitValue = bitValue << 1; + bitValue <<= 1; } if (bZeroFieldInEnum == false) @@ -1984,11 +1984,11 @@ private bool GeneratePropertyHelperEnums(PropertyData prop, string strPropertyNa cmf.Name = "NULL_ENUM_VALUE"; if (BitValues.Count > 30) { - maxBitValue = maxBitValue + 1; + maxBitValue++; } else { - maxBitValue = maxBitValue << 1; + maxBitValue <<= 1; } cmf.InitExpression = new CodePrimitiveExpression((int)(maxBitValue)); EnumObj.Members.Add(cmf); @@ -2048,7 +2048,7 @@ private void GenerateConstructPath() string strPath = OriginalNamespace + ":" + OriginalClassName; if (bSingletonClass == true) { - strPath = strPath + "=@"; + strPath += "=@"; cmm.Statements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(strPath))); } else @@ -3701,7 +3701,7 @@ private void GeneratePrivateMember(string memberName, string MemberType, CodeExp cf.Attributes = MemberAttributes.Private | MemberAttributes.Final; if (isStatic == true) { - cf.Attributes = cf.Attributes | MemberAttributes.Static; + cf.Attributes |= MemberAttributes.Static; } cf.Type = new CodeTypeReference(MemberType); if (initExpression != null && isStatic == true) @@ -5012,7 +5012,7 @@ private static int ConvertBitMapValueToInt32(string bitMap) int Len = bitMap.Length; for (int i = 2; i < Len; i++) { - strTemp = strTemp + arrString[i]; + strTemp += arrString[i]; } ret = System.Convert.ToInt32(strTemp, (IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(int))); } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/AuthenticationHeaderValue.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/AuthenticationHeaderValue.cs index 3ab1b98097020..35b070e3fe1ea 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/AuthenticationHeaderValue.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/AuthenticationHeaderValue.cs @@ -87,7 +87,7 @@ public override int GetHashCode() if (!string.IsNullOrEmpty(_parameter)) { - result = result ^ _parameter.GetHashCode(); + result ^= _parameter.GetHashCode(); } return result; @@ -148,7 +148,7 @@ internal static int GetAuthenticationLength(string? input, int startIndex, out o int current = startIndex + schemeLength; int whitespaceLength = HttpRuleParser.GetWhitespaceLength(input, current); - current = current + whitespaceLength; + current += whitespaceLength; if ((current == input.Length) || (input[current] == ',')) { @@ -206,7 +206,7 @@ private static bool TrySkipFirstBlob(string input, ref int current, ref int para // We have a quote but an invalid quoted-string. return false; } - current = current + quotedStringLength; + current += quotedStringLength; parameterEndIndex = current - 1; // -1 because 'current' points to the char after the final '"' } else @@ -223,7 +223,7 @@ private static bool TrySkipFirstBlob(string input, ref int current, ref int para } else { - current = current + whitespaceLength; + current += whitespaceLength; } } } @@ -256,8 +256,8 @@ private static bool TryGetParametersEndIndex(string input, ref int parseEndIndex return false; } - current = current + tokenLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += tokenLength; + current += HttpRuleParser.GetWhitespaceLength(input, current); // If we reached the end of the string or the token is followed by anything but '=', then the parsed // token is another scheme name. The string representing parameters ends before the token (e.g. @@ -268,7 +268,7 @@ private static bool TryGetParametersEndIndex(string input, ref int parseEndIndex } current++; // skip '=' delimiter - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); int valueLength = NameValueHeaderValue.GetValueLength(input, current); // After '=' we expect a valid (either token or quoted string) @@ -279,9 +279,9 @@ private static bool TryGetParametersEndIndex(string input, ref int parseEndIndex // Update parameter end index, since we just parsed a valid = pair that is part of the // parameters string. - current = current + valueLength; + current += valueLength; parameterEndIndex = current - 1; // -1 because 'current' already points to the char after - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); parseEndIndex = current; // this essentially points to parameterEndIndex + whitespace + next char } while ((current < input.Length) && (input[current] == ',')); diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/BaseHeaderParser.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/BaseHeaderParser.cs index 1c8df35e50be8..0c9d6f72ae2b5 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/BaseHeaderParser.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/BaseHeaderParser.cs @@ -66,7 +66,7 @@ public sealed override bool TryParseValue(string? value, object? storeValue, ref return false; } - current = current + length; + current += length; current = HeaderUtilities.GetNextNonEmptyOrWhitespaceIndex(value, current, SupportsMultipleValues, out separatorFound); diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/CacheControlHeaderValue.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/CacheControlHeaderValue.cs index a40b6b9d089e0..fdba34a3fd4a4 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/CacheControlHeaderValue.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/CacheControlHeaderValue.cs @@ -338,7 +338,7 @@ public override int GetHashCode() { foreach (var noCacheHeader in _noCacheHeaders) { - result = result ^ StringComparer.OrdinalIgnoreCase.GetHashCode(noCacheHeader); + result ^= StringComparer.OrdinalIgnoreCase.GetHashCode(noCacheHeader); } } @@ -346,7 +346,7 @@ public override int GetHashCode() { foreach (var privateHeader in _privateHeaders) { - result = result ^ StringComparer.OrdinalIgnoreCase.GetHashCode(privateHeader); + result ^= StringComparer.OrdinalIgnoreCase.GetHashCode(privateHeader); } } @@ -354,7 +354,7 @@ public override int GetHashCode() { foreach (var extension in _extensions) { - result = result ^ extension.GetHashCode(); + result ^= extension.GetHashCode(); } } @@ -568,7 +568,7 @@ private static bool TrySetOptionalTokenList(NameValueHeaderValue nameValue, ref destination ??= new TokenObjectCollection(); destination.Add(valueString.Substring(current, tokenLength)); - current = current + tokenLength; + current += tokenLength; } // After parsing a valid token list, we expect to have at least one value diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ContentDispositionHeaderValue.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ContentDispositionHeaderValue.cs index 6b282f0193aef..94d50128c5d33 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ContentDispositionHeaderValue.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ContentDispositionHeaderValue.cs @@ -225,7 +225,7 @@ internal static int GetDispositionTypeLength(string? input, int startIndex, out } int current = startIndex + dispositionTypeLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); ContentDispositionHeaderValue contentDispositionHeader = new ContentDispositionHeaderValue(); contentDispositionHeader._dispositionType = dispositionType!; diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ContentRangeHeaderValue.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ContentRangeHeaderValue.cs index 7321ea27dcabc..f74d5015b5fcd 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ContentRangeHeaderValue.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ContentRangeHeaderValue.cs @@ -143,7 +143,7 @@ public override int GetHashCode() if (HasLength) { - result = result ^ _length.GetHashCode(); + result ^= _length.GetHashCode(); } return result; @@ -227,7 +227,7 @@ internal static int GetContentRangeLength(string? input, int startIndex, out obj return 0; } - current = current + separatorLength; + current += separatorLength; if (current == input.Length) { @@ -251,7 +251,7 @@ internal static int GetContentRangeLength(string? input, int startIndex, out obj } current++; // Skip '/' separator - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); if (current == input.Length) { @@ -293,10 +293,10 @@ private static bool TryGetLengthLength(string input, ref int current, out int le return false; } - current = current + lengthLength; + current += lengthLength; } - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); return true; } @@ -323,8 +323,8 @@ private static bool TryGetRangeLength(string input, ref int current, out int fro return false; } - current = current + fromLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += fromLength; + current += HttpRuleParser.GetWhitespaceLength(input, current); // After the first value, the '-' character must follow. if ((current == input.Length) || (input[current] != '-')) @@ -334,7 +334,7 @@ private static bool TryGetRangeLength(string input, ref int current, out int fro } current++; // skip the '-' character - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); if (current == input.Length) { @@ -350,10 +350,10 @@ private static bool TryGetRangeLength(string input, ref int current, out int fro return false; } - current = current + toLength; + current += toLength; } - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); return true; } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/EntityTagHeaderValue.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/EntityTagHeaderValue.cs index f3c1f07e1021f..2a7c7e39e6173 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/EntityTagHeaderValue.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/EntityTagHeaderValue.cs @@ -143,7 +143,7 @@ internal static int GetEntityTagLength(string? input, int startIndex, out Entity } isWeak = true; current++; // we have a weak-entity tag. - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); } int tagStartIndex = current; @@ -165,9 +165,9 @@ internal static int GetEntityTagLength(string? input, int startIndex, out Entity parsedValue = new EntityTagHeaderValue(input.Substring(tagStartIndex, tagLength), isWeak); } - current = current + tagLength; + current += tagLength; } - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); return current - startIndex; } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/HeaderUtilities.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/HeaderUtilities.cs index 7975f3fc42b36..14b1075ec1f77 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/HeaderUtilities.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/HeaderUtilities.cs @@ -267,14 +267,14 @@ internal static int GetNextNonEmptyOrWhitespaceIndex(string input, int startInde // empty values, continue until the current character is neither a separator nor a whitespace. separatorFound = true; current++; // skip delimiter. - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); if (skipEmptyValues) { while ((current < input.Length) && (input[current] == ',')) { current++; // skip delimiter. - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); } } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/MediaTypeHeaderValue.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/MediaTypeHeaderValue.cs index 47855527860dc..3cceffb67a43e 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/MediaTypeHeaderValue.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/MediaTypeHeaderValue.cs @@ -168,7 +168,7 @@ internal static int GetMediaTypeLength(string? input, int startIndex, } int current = startIndex + mediaTypeLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); MediaTypeHeaderValue mediaTypeHeader; // If we're not done and we have a parameter delimiter, then we have a list of parameters. @@ -213,7 +213,7 @@ private static int GetMediaTypeExpressionLength(string input, int startIndex, ou } int current = startIndex + typeLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); // Parse the separator between type and subtype if ((current >= input.Length) || (input[current] != '/')) @@ -221,7 +221,7 @@ private static int GetMediaTypeExpressionLength(string input, int startIndex, ou return 0; } current++; // skip delimiter. - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); // Parse the subtype, i.e. in media type string "/; param1=value1; param2=value2" int subtypeLength = HttpRuleParser.GetTokenLength(input, current); diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/NameValueHeaderValue.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/NameValueHeaderValue.cs index 9084597b1f90c..5160733432ca8 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/NameValueHeaderValue.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/NameValueHeaderValue.cs @@ -193,7 +193,7 @@ internal static int GetHashCode(UnvalidatedObjectCollection in name/value string "=" int valueLength = GetValueLength(input, current); @@ -255,8 +255,8 @@ internal static int GetNameValueLength(string input, int startIndex, parsedValue = nameValueCreator(); parsedValue._name = name; parsedValue._value = input.Substring(current, valueLength); - current = current + valueLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); // skip whitespace + current += valueLength; + current += HttpRuleParser.GetWhitespaceLength(input, current); // skip whitespace return current - startIndex; } @@ -286,8 +286,8 @@ internal static int GetNameValueListLength(string? input, int startIndex, char d } nameValueCollection.Add(parameter!); - current = current + nameValueLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += nameValueLength; + current += HttpRuleParser.GetWhitespaceLength(input, current); if ((current == input.Length) || (input[current] != delimiter)) { @@ -297,7 +297,7 @@ internal static int GetNameValueListLength(string? input, int startIndex, char d // input[current] is 'delimiter'. Skip the delimiter and whitespace and try to parse again. current++; // skip delimiter. - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); } } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/NameValueWithParametersHeaderValue.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/NameValueWithParametersHeaderValue.cs index f02ffc3d8da7d..0f7bba3d3ce77 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/NameValueWithParametersHeaderValue.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/NameValueWithParametersHeaderValue.cs @@ -114,7 +114,7 @@ internal static int GetNameValueWithParametersLength(string? input, int startInd } int current = startIndex + nameValueLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); NameValueWithParametersHeaderValue? nameValueWithParameters = nameValue as NameValueWithParametersHeaderValue; Debug.Assert(nameValueWithParameters != null); diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ProductHeaderValue.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ProductHeaderValue.cs index 555b1eb1a73c0..a6013b8616fcd 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ProductHeaderValue.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ProductHeaderValue.cs @@ -76,7 +76,7 @@ public override int GetHashCode() if (!string.IsNullOrEmpty(_version)) { - result = result ^ StringComparer.OrdinalIgnoreCase.GetHashCode(_version); + result ^= StringComparer.OrdinalIgnoreCase.GetHashCode(_version); } return result; @@ -122,7 +122,7 @@ internal static int GetProductLength(string input, int startIndex, out ProductHe string name = input.Substring(startIndex, nameLength); int current = startIndex + nameLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); if ((current == input.Length) || (input[current] != '/')) { @@ -131,7 +131,7 @@ internal static int GetProductLength(string input, int startIndex, out ProductHe } current++; // Skip '/' delimiter. - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); // Parse the name string: in '/'. int versionLength = HttpRuleParser.GetTokenLength(input, current); @@ -143,8 +143,8 @@ internal static int GetProductLength(string input, int startIndex, out ProductHe string version = input.Substring(current, versionLength); - current = current + versionLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += versionLength; + current += HttpRuleParser.GetWhitespaceLength(input, current); parsedValue = new ProductHeaderValue(name, version); return current - startIndex; diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ProductInfoHeaderParser.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ProductInfoHeaderParser.cs index f224eeb10481d..47ff3bfdbdd7b 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ProductInfoHeaderParser.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ProductInfoHeaderParser.cs @@ -46,7 +46,7 @@ public override bool TryParseValue([NotNullWhen(true)] string? value, object? st } // GetProductInfoLength() already skipped trailing whitespace. No need to do it here again. - current = current + length; + current += length; // If we have more values, make sure we saw a whitespace before. Values like "product/1.0(comment)" are // invalid since there must be a whitespace between the product and the comment value. diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ProductInfoHeaderValue.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ProductInfoHeaderValue.cs index 2e52dbd7f1911..40a6b474e6450 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ProductInfoHeaderValue.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ProductInfoHeaderValue.cs @@ -144,8 +144,8 @@ internal static int GetProductInfoLength(string? input, int startIndex, out Prod comment = input.Substring(current, commentLength); - current = current + commentLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += commentLength; + current += HttpRuleParser.GetWhitespaceLength(input, current); parsedValue = new ProductInfoHeaderValue(comment); } @@ -159,7 +159,7 @@ internal static int GetProductInfoLength(string? input, int startIndex, out Prod return 0; } - current = current + productLength; + current += productLength; parsedValue = new ProductInfoHeaderValue(product!); } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/RangeConditionHeaderValue.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/RangeConditionHeaderValue.cs index a445cc597b7c5..e85de153f9234 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/RangeConditionHeaderValue.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/RangeConditionHeaderValue.cs @@ -139,7 +139,7 @@ internal static int GetRangeConditionLength(string? input, int startIndex, out o return 0; } - current = current + entityTagLength; + current += entityTagLength; // RangeConditionHeaderValue only allows 1 value. There must be no delimiter/other chars after an // entity tag. diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/RangeHeaderValue.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/RangeHeaderValue.cs index 0f81df89293fa..28f64786ec502 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/RangeHeaderValue.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/RangeHeaderValue.cs @@ -102,7 +102,7 @@ public override int GetHashCode() { foreach (RangeItemHeaderValue range in _ranges) { - result = result ^ range.GetHashCode(); + result ^= range.GetHashCode(); } } @@ -150,7 +150,7 @@ internal static int GetRangeLength(string? input, int startIndex, out object? pa RangeHeaderValue result = new RangeHeaderValue(); result._unit = input.Substring(startIndex, unitLength); int current = startIndex + unitLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); if ((current == input.Length) || (input[current] != '=')) { @@ -158,7 +158,7 @@ internal static int GetRangeLength(string? input, int startIndex, out object? pa } current++; // skip '=' separator - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); int rangesLength = RangeItemHeaderValue.GetRangeItemListLength(input, current, result.Ranges); @@ -167,7 +167,7 @@ internal static int GetRangeLength(string? input, int startIndex, out object? pa return 0; } - current = current + rangesLength; + current += rangesLength; Debug.Assert(current == input.Length, "GetRangeItemListLength() should consume the whole string or fail."); parsedValue = result; diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/RangeItemHeaderValue.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/RangeItemHeaderValue.cs index 8c14da848b1d0..f257b7d860d7e 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/RangeItemHeaderValue.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/RangeItemHeaderValue.cs @@ -130,7 +130,7 @@ internal static int GetRangeItemListLength(string? input, int startIndex, rangeCollection.Add(range!); - current = current + rangeLength; + current += rangeLength; current = HeaderUtilities.GetNextNonEmptyOrWhitespaceIndex(input, current, true, out bool separatorFound); // If the string is not consumed, we must have a delimiter, otherwise the string is not a valid @@ -172,8 +172,8 @@ internal static int GetRangeItemLength(string? input, int startIndex, out RangeI return 0; } - current = current + fromLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += fromLength; + current += HttpRuleParser.GetWhitespaceLength(input, current); // After the first value, the '-' character must follow. if ((current == input.Length) || (input[current] != '-')) @@ -183,7 +183,7 @@ internal static int GetRangeItemLength(string? input, int startIndex, out RangeI } current++; // skip the '-' character - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); int toStartIndex = current; int toLength = 0; @@ -198,8 +198,8 @@ internal static int GetRangeItemLength(string? input, int startIndex, out RangeI return 0; } - current = current + toLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += toLength; + current += HttpRuleParser.GetWhitespaceLength(input, current); } if ((fromLength == 0) && (toLength == 0)) diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/RetryConditionHeaderValue.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/RetryConditionHeaderValue.cs index 84bb302c6f9ab..3e8bbe62e516e 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/RetryConditionHeaderValue.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/RetryConditionHeaderValue.cs @@ -138,8 +138,8 @@ internal static int GetRetryConditionLength(string? input, int startIndex, out o return 0; } - current = current + deltaLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += deltaLength; + current += HttpRuleParser.GetWhitespaceLength(input, current); // RetryConditionHeaderValue only allows 1 value. There must be no delimiter/other chars after 'delta' if (current != input.Length) diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/StringWithQualityHeaderValue.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/StringWithQualityHeaderValue.cs index 377a2113dfa88..6059f7b7642c4 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/StringWithQualityHeaderValue.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/StringWithQualityHeaderValue.cs @@ -93,7 +93,7 @@ public override int GetHashCode() if (_quality.HasValue) { - result = result ^ _quality.Value.GetHashCode(); + result ^= _quality.Value.GetHashCode(); } return result; @@ -141,7 +141,7 @@ internal static int GetStringWithQualityLength(string? input, int startIndex, ou string value = input.Substring(startIndex, valueLength); int current = startIndex + valueLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); if ((current == input.Length) || (input[current] != ';')) { @@ -150,7 +150,7 @@ internal static int GetStringWithQualityLength(string? input, int startIndex, ou } current++; // skip ';' separator - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); // If we found a ';' separator, it must be followed by a quality information if (!TryReadQuality(input, out double quality, ref current)) @@ -174,7 +174,7 @@ private static bool TryReadQuality(string input, out double quality, ref int ind } current++; // skip 'q' identifier - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); // If we found "q" it must be followed by "=" if ((current == input.Length) || (input[current] != '=')) @@ -183,7 +183,7 @@ private static bool TryReadQuality(string input, out double quality, ref int ind } current++; // skip '=' separator - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); if (current == input.Length) { @@ -208,8 +208,8 @@ private static bool TryReadQuality(string input, out double quality, ref int ind return false; } - current = current + qualityLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += qualityLength; + current += HttpRuleParser.GetWhitespaceLength(input, current); index = current; return true; diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/TransferCodingHeaderValue.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/TransferCodingHeaderValue.cs index 74e2aa30f5396..592560997e0b8 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/TransferCodingHeaderValue.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/TransferCodingHeaderValue.cs @@ -80,7 +80,7 @@ internal static int GetTransferCodingLength(string input, int startIndex, string value = input.Substring(startIndex, valueLength); int current = startIndex + valueLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); TransferCodingHeaderValue transferCodingHeader; // If we're not done and we have a parameter delimiter, then we have a list of parameters. diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ViaHeaderValue.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ViaHeaderValue.cs index a2afd99c3bc8d..98012dafa7edc 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ViaHeaderValue.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/ViaHeaderValue.cs @@ -123,12 +123,12 @@ public override int GetHashCode() if (!string.IsNullOrEmpty(_protocolName)) { - result = result ^ StringComparer.OrdinalIgnoreCase.GetHashCode(_protocolName); + result ^= StringComparer.OrdinalIgnoreCase.GetHashCode(_protocolName); } if (!string.IsNullOrEmpty(_comment)) { - result = result ^ _comment.GetHashCode(); + result ^= _comment.GetHashCode(); } return result; @@ -183,9 +183,9 @@ internal static int GetViaLength(string? input, int startIndex, out object? pars } string receivedBy = input.Substring(current, receivedByLength); - current = current + receivedByLength; + current += receivedByLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); string? comment = null; if ((current < input.Length) && (input[current] == '(')) @@ -199,8 +199,8 @@ internal static int GetViaLength(string? input, int startIndex, out object? pars comment = input.Substring(current, commentLength); - current = current + commentLength; - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += commentLength; + current += HttpRuleParser.GetWhitespaceLength(input, current); } parsedValue = new ViaHeaderValue(protocolVersion, receivedBy!, protocolName, comment); @@ -227,7 +227,7 @@ private static int GetProtocolEndIndex(string input, int startIndex, out string? current = startIndex + protocolVersionOrNameLength; int whitespaceLength = HttpRuleParser.GetWhitespaceLength(input, current); - current = current + whitespaceLength; + current += whitespaceLength; if (current == input.Length) { @@ -240,7 +240,7 @@ private static int GetProtocolEndIndex(string input, int startIndex, out string? protocolName = input.Substring(startIndex, protocolVersionOrNameLength); current++; // skip the '/' delimiter - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); protocolVersionOrNameLength = HttpRuleParser.GetTokenLength(input, current); @@ -251,9 +251,9 @@ private static int GetProtocolEndIndex(string input, int startIndex, out string? protocolVersion = input.Substring(current, protocolVersionOrNameLength); - current = current + protocolVersionOrNameLength; + current += protocolVersionOrNameLength; whitespaceLength = HttpRuleParser.GetWhitespaceLength(input, current); - current = current + whitespaceLength; + current += whitespaceLength; } else { diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/WarningHeaderValue.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/WarningHeaderValue.cs index d70b666d3c1cd..8c0757e08df35 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/WarningHeaderValue.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/WarningHeaderValue.cs @@ -126,7 +126,7 @@ public override int GetHashCode() if (_date.HasValue) { - result = result ^ _date.Value.GetHashCode(); + result ^= _date.Value.GetHashCode(); } return result; @@ -187,7 +187,7 @@ internal static int GetWarningLength(string? input, int startIndex, out object? string text = input.Substring(textStartIndex, textLength); - current = current + textLength; + current += textLength; // Read in ' [""]' DateTimeOffset? date; @@ -214,10 +214,10 @@ private static bool TryReadAgent(string input, ref int current, [NotNullWhen(tru } agent = input.Substring(current, agentLength); - current = current + agentLength; + current += agentLength; int whitespaceLength = HttpRuleParser.GetWhitespaceLength(input, current); - current = current + whitespaceLength; + current += whitespaceLength; // At least one whitespace required after . Also make sure we have characters left for if ((whitespaceLength == 0) || (current == input.Length)) @@ -246,10 +246,10 @@ private static bool TryReadCode(string input, ref int current, out int code) return false; } - current = current + codeLength; + current += codeLength; int whitespaceLength = HttpRuleParser.GetWhitespaceLength(input, current); - current = current + whitespaceLength; + current += whitespaceLength; // Make sure the number is followed by at least one whitespace and that we have characters left to parse. if ((whitespaceLength == 0) || (current == input.Length)) @@ -266,7 +266,7 @@ private static bool TryReadDate(string input, ref int current, out DateTimeOffse // Make sure we have at least one whitespace between and (if we have ) int whitespaceLength = HttpRuleParser.GetWhitespaceLength(input, current); - current = current + whitespaceLength; + current += whitespaceLength; // Read in ' [""]' if ((current < input.Length) && (input[current] == '"')) @@ -303,7 +303,7 @@ private static bool TryReadDate(string input, ref int current, out DateTimeOffse date = temp; current++; // skip closing '"' - current = current + HttpRuleParser.GetWhitespaceLength(input, current); + current += HttpRuleParser.GetWhitespaceLength(input, current); } return true; diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpRuleParser.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpRuleParser.cs index deadd8b5b25e7..f7c5564edf71f 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/HttpRuleParser.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/HttpRuleParser.cs @@ -315,7 +315,7 @@ private static HttpParseResult GetExpressionLength(string input, int startIndex, // We ignore invalid quoted-pairs. Invalid quoted-pairs may mean that it looked like a quoted pair, // but we actually have a quoted-string: e.g. "\\u00FC" ('\' followed by a char >127 - quoted-pair only // allows ASCII chars after '\'; qdtext allows both '\' and >127 chars). - current = current + quotedPairLength; + current += quotedPairLength; continue; } diff --git a/src/libraries/System.Net.HttpListener/src/System/Net/Windows/HttpResponseStream.Windows.cs b/src/libraries/System.Net.HttpListener/src/System/Net/Windows/HttpResponseStream.Windows.cs index dc54f6cd6bfae..37eabcd78cf49 100644 --- a/src/libraries/System.Net.HttpListener/src/System/Net/Windows/HttpResponseStream.Windows.cs +++ b/src/libraries/System.Net.HttpListener/src/System/Net/Windows/HttpResponseStream.Windows.cs @@ -78,7 +78,7 @@ private void WriteCore(byte[] buffer, int offset, int size) if (_httpContext.Response.BoundaryType == BoundaryType.Chunked) { string chunkHeader = size.ToString("x", CultureInfo.InvariantCulture); - dataToWrite = dataToWrite + (uint)(chunkHeader.Length + 4); + dataToWrite += (uint)(chunkHeader.Length + 4); bufferAsIntPtr = SafeLocalAllocHandle.LocalAlloc((int)dataToWrite); pBufferAsIntPtr = bufferAsIntPtr.DangerousGetHandle(); for (int i = 0; i < chunkHeader.Length; i++) diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/MailPriority.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/MailPriority.cs index 0744a29bb99b4..6ceea22e88a6a 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/MailPriority.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/MailPriority.cs @@ -147,7 +147,7 @@ internal string? Subject { // Store the decoded value, we'll re-encode before sending value = MimeBasePart.DecodeHeaderValue(value); - _subjectEncoding = _subjectEncoding ?? inputEncoding; + _subjectEncoding ??= inputEncoding; } // Failed to decode, just pass it through as ascii (legacy) catch (FormatException) { } diff --git a/src/libraries/System.Net.Requests/src/System/Net/FtpControlStream.cs b/src/libraries/System.Net.Requests/src/System/Net/FtpControlStream.cs index a093ef49c98e8..af30b09181309 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/FtpControlStream.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/FtpControlStream.cs @@ -1039,8 +1039,7 @@ private static int GetPortV4(string responseString) index--; int port = Convert.ToByte(parsedList[index--], NumberFormatInfo.InvariantInfo); - port = port | - (Convert.ToByte(parsedList[index--], NumberFormatInfo.InvariantInfo) << 8); + port |= (Convert.ToByte(parsedList[index--], NumberFormatInfo.InvariantInfo) << 8); return port; } diff --git a/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/ManagedWebSocket.cs b/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/ManagedWebSocket.cs index 88c011565d649..4130cff1cc65d 100644 --- a/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/ManagedWebSocket.cs +++ b/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/ManagedWebSocket.cs @@ -620,7 +620,7 @@ private static int WriteHeader(MessageOpcode opcode, byte[] sendBuffer, ReadOnly for (int i = 9; i >= 2; i--) { sendBuffer[i] = unchecked((byte)length); - length = length / 256; + length /= 256; } maskOffset = 2 + sizeof(ulong); // additional 8 bytes for 64-bit length } diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/DirectoryInfo.cs b/src/libraries/System.Private.CoreLib/src/System/IO/DirectoryInfo.cs index 2417f93f556b3..c47ef747ee988 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/DirectoryInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/DirectoryInfo.cs @@ -31,7 +31,7 @@ private void Init(string originalPath, string? fullPath = null, string? fileName OriginalPath = originalPath; - fullPath = fullPath ?? originalPath; + fullPath ??= originalPath; fullPath = isNormalized ? fullPath : Path.GetFullPath(fullPath); _name = fileName ?? (PathInternal.IsRoot(fullPath.AsSpan()) ? diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileInfo.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileInfo.cs index efa2a139b133b..3b9cc7b9f1417 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/FileInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileInfo.cs @@ -25,7 +25,7 @@ internal FileInfo(string originalPath, string? fullPath = null, string? fileName // Want to throw the original argument name OriginalPath = originalPath; - fullPath = fullPath ?? originalPath; + fullPath ??= originalPath; Debug.Assert(!isNormalized || !PathInternal.IsPartiallyQualified(fullPath.AsSpan()), "should be fully qualified if normalized"); FullPath = isNormalized ? fullPath ?? originalPath : Path.GetFullPath(fullPath); diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/ASCIIUtility.cs b/src/libraries/System.Private.CoreLib/src/System/Text/ASCIIUtility.cs index 8fd4df503b0f9..84001aa728f9f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/ASCIIUtility.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/ASCIIUtility.cs @@ -198,7 +198,7 @@ private static unsafe nuint GetIndexOfFirstNonAsciiByte_Default(byte* pBuffer, n { if (!BitConverter.IsLittleEndian) { - currentUInt32 = currentUInt32 << 16; + currentUInt32 <<= 16; } goto FoundNonAsciiData; } @@ -1680,7 +1680,7 @@ public static unsafe nuint WidenAsciiToUtf16(byte* pAsciiBuffer, char* pUtf16Buf { if (!BitConverter.IsLittleEndian) { - asciiData = asciiData << 16; + asciiData <<= 16; } goto FoundNonAsciiData; } diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ExtensionDataReader.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ExtensionDataReader.cs index bb9f446bfd3d7..0fe6ffba9f56d 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ExtensionDataReader.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ExtensionDataReader.cs @@ -484,7 +484,7 @@ private void GrowElementsIfNeeded() internal static string GetPrefix(string? ns) { - ns = ns ?? string.Empty; + ns ??= string.Empty; string? prefix = (string?)s_nsToPrefixTable[ns]; if (prefix == null) { diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonWriterDelegator.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonWriterDelegator.cs index d14a3847c3ffe..60433c1382d79 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonWriterDelegator.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonWriterDelegator.cs @@ -191,7 +191,7 @@ private void WriteDateTimeInDefaultFormat(DateTime value) long tickCount = value.Ticks; if (lowBound > tickCount || highBound < tickCount) // We could potentially under/over flow { - tickCount = tickCount - TimeZoneInfo.Local.GetUtcOffset(value).Ticks; + tickCount -= TimeZoneInfo.Local.GetUtcOffset(value).Ticks; if ((tickCount > DateTime.MaxValue.Ticks) || (tickCount < DateTime.MinValue.Ticks)) { throw XmlObjectSerializer.CreateSerializationException(SR.JsonDateTimeOutOfRange, new ArgumentOutOfRangeException(nameof(value))); diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs index 3951445813082..39ce7dfb2ab5b 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs @@ -1009,8 +1009,8 @@ internal XmlReaderDelegator CreateReaderOverChildNodes(IList? xmlA internal static XmlNode CreateWrapperXmlElement(XmlDocument document, IList? xmlAttributes, IList xmlChildNodes, string? prefix, string? localName, string? ns) { - localName = localName ?? "wrapper"; - ns = ns ?? string.Empty; + localName ??= "wrapper"; + ns ??= string.Empty; XmlElement wrapperElement = document.CreateElement(prefix, localName, ns); if (xmlAttributes != null) { diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/ArrayHelper.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/ArrayHelper.cs index 05bffd65b03b2..3baa246fd2a4e 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/ArrayHelper.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/ArrayHelper.cs @@ -38,10 +38,9 @@ public TArray[] ReadArray(XmlDictionaryReader reader, TArgument localName, TArgu totalRead += read; if (read < array.Length || reader.NodeType == XmlNodeType.EndElement) break; - if (arrays == null) - arrays = new TArray[32][]; + arrays ??= new TArray[32][]; arrays[arrayCount++] = array; - count = count * 2; + count *= 2; } if (totalRead != array.Length || arrayCount > 0) { diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBaseReader.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBaseReader.cs index 928e571a7366e..07908253c08c0 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBaseReader.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBaseReader.cs @@ -1485,7 +1485,7 @@ private int ReadBytes(Encoding encoding, int byteBlock, int charBlock, byte[] bu { if (_trailChars == null) _trailChars = new char[4]; - charCount = charCount - _trailCharCount; + charCount -= _trailCharCount; Array.Copy(chars, charCount, _trailChars, 0, _trailCharCount); } } diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBinaryWriter.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBinaryWriter.cs index 7b060146400a6..7ed8b8ebfc670 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBinaryWriter.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBinaryWriter.cs @@ -815,12 +815,12 @@ private static long ToBinary(DateTime dt) switch (dt.Kind) { case DateTimeKind.Local: - temp = temp | -9223372036854775808L; // 0x8000000000000000 - temp = temp | dt.ToUniversalTime().Ticks; + temp |= -9223372036854775808L; // 0x8000000000000000 + temp |= dt.ToUniversalTime().Ticks; break; case DateTimeKind.Utc: - temp = temp | 0x4000000000000000L; - temp = temp | dt.Ticks; + temp |= 0x4000000000000000L; + temp |= dt.Ticks; break; case DateTimeKind.Unspecified: temp = dt.Ticks; diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryReader.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryReader.cs index e2daea3d7425a..2eb1a86b865b6 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryReader.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryReader.cs @@ -534,7 +534,7 @@ private byte[] ReadContentAsBytes(bool base64, int maxByteArrayContentLength) totalRead += read; if (read < buffer.Length) break; - count = count * 2; + count *= 2; } buffer = new byte[totalRead]; int offset = 0; diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryWriter.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryWriter.cs index 49babc9f9f167..091df90f056ef 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryWriter.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryWriter.cs @@ -217,7 +217,7 @@ public virtual void WriteValue(IStreamProvider value) break; if (blockSize < 65536 && bytesRead == blockSize) { - blockSize = blockSize * 16; + blockSize *= 16; block = new byte[blockSize]; } } diff --git a/src/libraries/System.Private.Uri/src/System/UriExt.cs b/src/libraries/System.Private.Uri/src/System/UriExt.cs index ff5f5776c541c..fba947f22e68e 100644 --- a/src/libraries/System.Private.Uri/src/System/UriExt.cs +++ b/src/libraries/System.Private.Uri/src/System/UriExt.cs @@ -459,22 +459,22 @@ internal unsafe bool InternalIsWellFormedOriginalString() { if ((nonCanonical & (Flags.E_UserNotCanonical | Flags.UserIriCanonical)) == (Flags.E_UserNotCanonical | Flags.UserIriCanonical)) { - nonCanonical = nonCanonical & ~(Flags.E_UserNotCanonical | Flags.UserIriCanonical); + nonCanonical &= ~(Flags.E_UserNotCanonical | Flags.UserIriCanonical); } if ((nonCanonical & (Flags.E_PathNotCanonical | Flags.PathIriCanonical)) == (Flags.E_PathNotCanonical | Flags.PathIriCanonical)) { - nonCanonical = nonCanonical & ~(Flags.E_PathNotCanonical | Flags.PathIriCanonical); + nonCanonical &= ~(Flags.E_PathNotCanonical | Flags.PathIriCanonical); } if ((nonCanonical & (Flags.E_QueryNotCanonical | Flags.QueryIriCanonical)) == (Flags.E_QueryNotCanonical | Flags.QueryIriCanonical)) { - nonCanonical = nonCanonical & ~(Flags.E_QueryNotCanonical | Flags.QueryIriCanonical); + nonCanonical &= ~(Flags.E_QueryNotCanonical | Flags.QueryIriCanonical); } if ((nonCanonical & (Flags.E_FragmentNotCanonical | Flags.FragmentIriCanonical)) == (Flags.E_FragmentNotCanonical | Flags.FragmentIriCanonical)) { - nonCanonical = nonCanonical & ~(Flags.E_FragmentNotCanonical | Flags.FragmentIriCanonical); + nonCanonical &= ~(Flags.E_FragmentNotCanonical | Flags.FragmentIriCanonical); } } diff --git a/src/libraries/System.Private.Xml/src/System/Xml/BinaryXml/SqlUtils.cs b/src/libraries/System.Private.Xml/src/System/Xml/BinaryXml/SqlUtils.cs index a88f9cfde36f4..d22aefc772f72 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/BinaryXml/SqlUtils.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/BinaryXml/SqlUtils.cs @@ -455,7 +455,7 @@ private static void BreakDownXsdDate(long val, out int yr, out int mnth, out int { if (val < 0) goto Error; - val = val / 4; // trim indicator bits + val /= 4; // trim indicator bits int totalMin = (int)(val % (29 * 60)) - 60 * 14; long totalDays = val / (29 * 60); @@ -480,7 +480,7 @@ private static void BreakDownXsdTime(long val, out int hr, out int min, out int { if (val < 0) goto Error; - val = val / 4; // trim indicator bits + val /= 4; // trim indicator bits ms = (int)(val % 1000); val /= 1000; sec = (int)(val % 60); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/BinaryXml/XmlBinaryReader.cs b/src/libraries/System.Private.Xml/src/System/Xml/BinaryXml/XmlBinaryReader.cs index 2e0e70a96eae2..fddf94c8ee557 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/BinaryXml/XmlBinaryReader.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/BinaryXml/XmlBinaryReader.cs @@ -387,7 +387,7 @@ public XmlSqlBinaryReader(Stream stream, byte[] data, int len, string baseUri, b _ignorePIs = settings.IgnoreProcessingInstructions; _ignoreComments = settings.IgnoreComments; - s_tokenTypeMap = s_tokenTypeMap ?? GenerateTokenTypeMap(); + s_tokenTypeMap ??= GenerateTokenTypeMap(); } public override XmlReaderSettings Settings @@ -2095,17 +2095,17 @@ private int ParseMB32_(byte b) Debug.Assert(0 != (b & 0x80)); b = ReadByte(); t = (uint)b & (uint)0x7F; - u = u + (t << 7); + u += (t << 7); if (b > 127) { b = ReadByte(); t = (uint)b & (uint)0x7F; - u = u + (t << 14); + u += (t << 14); if (b > 127) { b = ReadByte(); t = (uint)b & (uint)0x7F; - u = u + (t << 21); + u += (t << 21); if (b > 127) { b = ReadByte(); @@ -2115,7 +2115,7 @@ private int ParseMB32_(byte b) t = (uint)b & (uint)0x07; if (b > 7) throw ThrowXmlException(SR.XmlBinary_ValueTooBig); - u = u + (t << 28); + u += (t << 28); } } } @@ -2134,17 +2134,17 @@ private int ParseMB32(int pos) { b = data[pos++]; t = (uint)b & (uint)0x7F; - u = u + (t << 7); + u += (t << 7); if (b > 127) { b = data[pos++]; t = (uint)b & (uint)0x7F; - u = u + (t << 14); + u += (t << 14); if (b > 127) { b = data[pos++]; t = (uint)b & (uint)0x7F; - u = u + (t << 21); + u += (t << 21); if (b > 127) { b = data[pos++]; @@ -2152,7 +2152,7 @@ private int ParseMB32(int pos) t = (uint)b & (uint)0x07; if (b > 7) throw ThrowXmlException(SR.XmlBinary_ValueTooBig); - u = u + (t << 28); + u += (t << 28); } } } diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImpl.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImpl.cs index 9819b04db6c30..224eab23a651d 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImpl.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImpl.cs @@ -3466,7 +3466,7 @@ private int ReadData() int copyCharsCount = _ps.charsUsed - _ps.charPos; if (copyCharsCount < charsLen - 1) { - _ps.lineStartPos = _ps.lineStartPos - _ps.charPos; + _ps.lineStartPos -= _ps.charPos; if (copyCharsCount > 0) { BlockCopyChars(_ps.chars, _ps.charPos, _ps.chars, 0, copyCharsCount); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImplAsync.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImplAsync.cs index 1f4672577e2c4..b828f2ad976e9 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImplAsync.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImplAsync.cs @@ -1128,7 +1128,7 @@ private async Task ReadDataAsync() int copyCharsCount = _ps.charsUsed - _ps.charPos; if (copyCharsCount < charsLen - 1) { - _ps.lineStartPos = _ps.lineStartPos - _ps.charPos; + _ps.lineStartPos -= _ps.charPos; if (copyCharsCount > 0) { BlockCopyChars(_ps.chars, _ps.charPos, _ps.chars, 0, copyCharsCount); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Dom/DocumentSchemaValidator.cs b/src/libraries/System.Private.Xml/src/System/Xml/Dom/DocumentSchemaValidator.cs index 5b5e5089f888b..d1ffd7ae95001 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Dom/DocumentSchemaValidator.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Dom/DocumentSchemaValidator.cs @@ -525,7 +525,7 @@ private void SetDefaultAttributeSchemaInfo(XmlSchemaAttribute schemaAttribute) if (parentNode == null) { //Did not find any type info all the way to the root, currentNode is Document || DocumentFragment - nodeIndex = nodeIndex - 1; //Subtract the one for document and set the node to null + nodeIndex--; //Subtract the one for document and set the node to null _nodeSequenceToValidate![nodeIndex] = null; return GetTypeFromAncestors(elementToValidate, null, nodeIndex); } diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/ContentValidator.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/ContentValidator.cs index a4ec00be589ab..c7309296d1fbd 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/ContentValidator.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/ContentValidator.cs @@ -1929,7 +1929,7 @@ public override void InitValidation(ValidationState context) { //If the first bitset itself matched, then no need to remove anything runningPositions!.RemoveRange(0, k); //Delete entries from 0 to k-1 } - matchCount = matchCount - k; + matchCount -= k; k = 0; // Since we re-sized the array while (k < matchCount) { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/FacetChecker.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/FacetChecker.cs index a29d4928dc8b0..57500d13e2e17 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/FacetChecker.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/FacetChecker.cs @@ -986,7 +986,7 @@ internal static decimal Power(int x, int y) } for (int i = 0; i < y; i++) { - returnValue = returnValue * decimalValue; + returnValue *= decimalValue; } return returnValue; } @@ -1110,7 +1110,7 @@ internal static bool MatchEnumeration(decimal value, ArrayList enumeration, XmlV } while (decimal.Truncate(value) != value) { //Till it has a fraction - value = value * 10; + value *= 10; powerCnt++; } diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlReflectionImporter.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlReflectionImporter.cs index f3fb4eb9fb230..9d6998aba7e72 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlReflectionImporter.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlReflectionImporter.cs @@ -2253,7 +2253,7 @@ private static ElementAccessor CreateElementAccessor(TypeMapping mapping, string [RequiresUnreferencedCode("Calls TypeScope.GetTypeDesc(Type) which has RequiresUnreferencedCode")] internal static XmlTypeMapping GetTopLevelMapping(Type type, string? defaultNamespace) { - defaultNamespace = defaultNamespace ?? string.Empty; + defaultNamespace ??= string.Empty; XmlAttributes a = new XmlAttributes(type); TypeDesc typeDesc = new TypeScope().GetTypeDesc(type); ElementAccessor element = new ElementAccessor(); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSchemaImporter.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSchemaImporter.cs index fbc15d44dc375..7c7c3b6648c08 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSchemaImporter.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSchemaImporter.cs @@ -1389,7 +1389,7 @@ private bool IsCyclicReferencedType(XmlSchemaElement element, List ident [RequiresUnreferencedCode("calls ImportSubstitutionGroupMember")] private void ImportElementMember(XmlSchemaElement element, string identifier, CodeIdentifiers members, CodeIdentifiers membersScope, INameScope elementsScope, string? ns, bool repeats, ref bool needExplicitOrder, bool allowDuplicates, bool allowUnboundedElements) { - repeats = repeats | element.IsMultipleOccurrence; + repeats |= element.IsMultipleOccurrence; XmlSchemaElement? headElement = GetTopLevelElement(element); if (headElement != null && ImportSubstitutionGroupMember(headElement, identifier, members, membersScope, ns, repeats, ref needExplicitOrder, allowDuplicates)) { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriter.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriter.cs index 11449885a9a6e..bcdfd587ac7f7 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriter.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriter.cs @@ -1222,7 +1222,7 @@ private void WriteArray(string name, string? ns, object o, Type type) } if (arrayDims.Length > 0) - typeName = typeName + arrayDims.ToString(); + typeName += arrayDims.ToString(); if (_soap12 && name != null && name.Length > 0) WriteStartElement(name, ns, null, false); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XPathConvert.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XPathConvert.cs index db78c6ce2501d..abce1eebfb2bf 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XPathConvert.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XPathConvert.cs @@ -428,7 +428,7 @@ private void Normalize() w2 = 32 - w1; _u2 = (_u2 << w1) | (_u1 >> w2); _u1 = (_u1 << w1) | (_u0 >> w2); - _u0 = (_u0 << w1); + _u0 <<= w1; _exp -= w1; } } diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/BitArithmetic.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/BitArithmetic.cs index 32eb1b402454d..7ad3c4aba6e61 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/BitArithmetic.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/BitArithmetic.cs @@ -22,7 +22,7 @@ internal static int CountBits(uint v) #else unchecked { - v = v - ((v >> 1) & 0x55555555u); + v -= ((v >> 1) & 0x55555555u); v = (v & 0x33333333u) + ((v >> 2) & 0x33333333u); return (int)((v + (v >> 4) & 0xF0F0F0Fu) * 0x1010101u) >> 24; } @@ -38,7 +38,7 @@ internal static int CountBits(ulong v) const ulong Mask00110011 = 0x3333333333333333UL; const ulong Mask00001111 = 0x0F0F0F0F0F0F0F0FUL; const ulong Mask00000001 = 0x0101010101010101UL; - v = v - ((v >> 1) & Mask01010101); + v -= ((v >> 1) & Mask01010101); v = (v & Mask00110011) + ((v >> 2) & Mask00110011); return (int)(unchecked(((v + (v >> 4)) & Mask00001111) * Mask00000001) >> 56); #endif diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEReader.EmbeddedPortablePdb.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEReader.EmbeddedPortablePdb.cs index a099e858919c2..08ba31fdda3c0 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEReader.EmbeddedPortablePdb.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEReader.EmbeddedPortablePdb.cs @@ -158,7 +158,7 @@ partial void TryOpenEmbeddedPortablePdb(DebugDirectoryEntry embeddedPdbEntry, re } catch (Exception e) when (e is BadImageFormatException || e is IOException) { - errorToReport = errorToReport ?? e; + errorToReport ??= e; openedEmbeddedPdb = false; } finally diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEReader.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEReader.cs index be70102491819..eda470b5bd713 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEReader.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEReader.cs @@ -768,7 +768,7 @@ private bool TryOpenCodeViewPortablePdb(DebugDirectoryEntry codeViewEntry, strin } catch (Exception e) when (e is BadImageFormatException || e is IOException) { - errorToReport = errorToReport ?? e; + errorToReport ??= e; return false; } @@ -832,7 +832,7 @@ private static bool TryOpenPortablePdbFile(string path, BlobContentId id, Func left, ReadOnlySpan right, u { carry += right[i] * q; uint digit = unchecked((uint)carry); - carry = carry >> 32; + carry >>= 32; ref uint leftElement = ref left[i]; if (leftElement < digit) ++carry; @@ -249,8 +249,8 @@ private static bool DivideGuessTooBig(ulong q, ulong valHi, uint valLo, ulong chkHi = divHi * q; ulong chkLo = divLo * q; - chkHi = chkHi + (chkLo >> 32); - chkLo = chkLo & 0xFFFFFFFF; + chkHi += (chkLo >> 32); + chkLo &= 0xFFFFFFFF; if (chkHi < valHi) return false; diff --git a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigIntegerCalculator.PowMod.cs b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigIntegerCalculator.PowMod.cs index 0407feff54fe3..c292558176a16 100644 --- a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigIntegerCalculator.PowMod.cs +++ b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigIntegerCalculator.PowMod.cs @@ -59,7 +59,7 @@ private static Span PowCore(Span value, int valueLength, Span bitsLength = MultiplySelf(ref result, bitsLength, value.Slice(0, valueLength), ref temp); if (power != 1) valueLength = SquareSelf(ref value, valueLength, ref temp); - power = power >> 1; + power >>= 1; } return result; @@ -120,7 +120,7 @@ public static int PowBound(uint power, int valueLength) if (power != 1) valueLength += valueLength; } - power = power >> 1; + power >>= 1; } return resultLength; @@ -173,7 +173,7 @@ private static uint PowCore(ulong value, ReadOnlySpan power, uint modulus, if ((p & 1) == 1) result = (result * value) % modulus; value = (value * value) % modulus; - p = p >> 1; + p >>= 1; } } @@ -191,7 +191,7 @@ private static uint PowCore(ulong value, uint power, uint modulus, ulong result) result = (result * value) % modulus; if (power != 1) value = (value * value) % modulus; - power = power >> 1; + power >>= 1; } return (uint)(result % modulus); @@ -431,7 +431,7 @@ private static Span PowCore(Span value, int valueLength, } valueLength = SquareSelf(ref value, valueLength, ref temp); valueLength = Reduce(value.Slice(0, valueLength), modulus); - p = p >> 1; + p >>= 1; } } @@ -461,7 +461,7 @@ private static Span PowCore(Span value, int valueLength, valueLength = SquareSelf(ref value, valueLength, ref temp); valueLength = Reduce(value.Slice(0, valueLength), modulus); } - power = power >> 1; + power >>= 1; } return result.Slice(0, resultLength); @@ -490,7 +490,7 @@ private static Span PowCore(Span value, int valueLength, } valueLength = SquareSelf(ref value, valueLength, ref temp); valueLength = reducer.Reduce(value.Slice(0, valueLength)); - p = p >> 1; + p >>= 1; } } @@ -520,7 +520,7 @@ private static Span PowCore(Span value, int valueLength, valueLength = SquareSelf(ref value, valueLength, ref temp); valueLength = reducer.Reduce(value.Slice(0, valueLength)); } - power = power >> 1; + power >>= 1; } return result; diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryObjectReader.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryObjectReader.cs index 94efc7f679fc7..ba514525295f1 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryObjectReader.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryObjectReader.cs @@ -483,7 +483,7 @@ private void ParseArray(ParseRecord pr) int sum = 1; for (int i = 0; i < pr._rank; i++) { - sum = sum * pr._lengthA[i]; + sum *= pr._lengthA[i]; } pr._indexMap = new int[pr._rank]; pr._rectangularMap = new int[pr._rank]; diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryParser.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryParser.cs index 058c5ac141266..81d475f8387ba 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryParser.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryParser.cs @@ -835,7 +835,7 @@ private void ReadArray(BinaryHeaderEnum binaryHeaderEnum) case BinaryArrayTypeEnum.RectangularOffset: int arrayLength = 1; for (int i = 0; i < record._rank; i++) - arrayLength = arrayLength * record._lengthA[i]; + arrayLength *= record._lengthA[i]; op._numItems = arrayLength; pr._arrayTypeEnum = InternalArrayTypeE.Rectangular; break; diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/EnvelopedCms.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/EnvelopedCms.cs index 0fab983af14d2..b52bfb473e562 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/EnvelopedCms.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/EnvelopedCms.cs @@ -246,7 +246,7 @@ public void Decrypt(RecipientInfo recipientInfo, AsymmetricAlgorithm? privateKey private void DecryptContent(RecipientInfoCollection recipientInfos, X509Certificate2Collection? extraStore) { CheckStateForDecryption(); - extraStore = extraStore ?? new X509Certificate2Collection(); + extraStore ??= new X509Certificate2Collection(); X509Certificate2Collection certs = new X509Certificate2Collection(); PkcsPal.Instance.AddCertsFromStoreForDecryption(certs); diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedXml.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedXml.cs index 41614db010a83..89b05ff113cfc 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedXml.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedXml.cs @@ -976,7 +976,7 @@ private static bool CryptographicEquals(byte[] a, byte[] b) // This cannot overflow more than once (and back to 0) because bytes are 1 byte // in length, and result is 4 bytes. The OR propagates all set bytes, so the differences // can't add up and overflow a second time. - result = result | (a[i] - b[i]); + result |= (a[i] - b[i]); } return (0 == result); diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/ChainPal.Windows.GetChainStatusInformation.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/ChainPal.Windows.GetChainStatusInformation.cs index e22f6c8adb49a..a74354c0189ea 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/ChainPal.Windows.GetChainStatusInformation.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/ChainPal.Windows.GetChainStatusInformation.cs @@ -13,7 +13,7 @@ private static X509ChainStatus[] GetChainStatusInformation(CertTrustErrorStatus return Array.Empty(); int count = 0; - for (uint bits = (uint)dwStatus; bits != 0; bits = bits >> 1) + for (uint bits = (uint)dwStatus; bits != 0; bits >>= 1) { if ((bits & 0x1) != 0) count++; @@ -36,7 +36,7 @@ private static X509ChainStatus[] GetChainStatusInformation(CertTrustErrorStatus } int shiftCount = 0; - for (uint bits = (uint)dwStatus; bits != 0; bits = bits >> 1) + for (uint bits = (uint)dwStatus; bits != 0; bits >>= 1) { if ((bits & 0x1) != 0) { diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/StorePal.iOS.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/StorePal.iOS.cs index 3e8c5acfd25ae..02c3af95fa66f 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/StorePal.iOS.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/StorePal.iOS.cs @@ -23,7 +23,7 @@ internal static partial ILoaderPal FromBlob(ReadOnlySpan rawData, SafePass rawData, (derData, contentType) => { - certificateList = certificateList ?? new List(); + certificateList ??= new List(); certificateList.Add(AppleCertificatePal.FromDerBlob(derData, contentType, password, keyStorageFlags)); return true; }); diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs index fd6620844bb46..2050b173aefa6 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs @@ -762,7 +762,7 @@ private SyndicationFeed ReadFeedFrom(XmlReader reader, SyndicationFeed result, b } else if (reader.IsStartElement(Atom10Constants.EntryTag, Atom10Constants.Atom10Namespace) && !isSourceFeed) { - feedItems = feedItems ?? new NullNotAllowedCollection(); + feedItems ??= new NullNotAllowedCollection(); IEnumerable items = ReadItems(reader, result, out areAllItemsRead); foreach (SyndicationItem item in items) { @@ -1129,14 +1129,14 @@ private void WriteFeedTo(XmlWriter writer, SyndicationFeed feed, bool isSourceFe TextSyndicationContent title = feed.Title; if (isElementRequired) { - title = title ?? new TextSyndicationContent(string.Empty); + title ??= new TextSyndicationContent(string.Empty); } WriteContentTo(writer, Atom10Constants.TitleTag, title); WriteContentTo(writer, Atom10Constants.SubtitleTag, feed.Description); string id = feed.Id; if (isElementRequired) { - id = id ?? s_idGenerator.Next(); + id ??= s_idGenerator.Next(); } WriteElement(writer, Atom10Constants.IdTag, id); WriteContentTo(writer, Atom10Constants.RightsTag, feed.Copyright); diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs index 9fe755dfbc301..980318ecc9776 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs @@ -736,7 +736,7 @@ private void ReadXml(XmlReader reader, SyndicationFeed result) } else if (reader.IsStartElement(Rss20Constants.ItemTag, Rss20Constants.Rss20Namespace)) { - feedItems = feedItems ?? new NullNotAllowedCollection(); + feedItems ??= new NullNotAllowedCollection(); IEnumerable items = ReadItems(reader, result, out areAllItemsRead); foreach (SyndicationItem item in items) { diff --git a/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceBase.cs b/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceBase.cs index 905af30eaa1f5..fbbd18ecf895c 100644 --- a/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceBase.cs +++ b/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceBase.cs @@ -909,7 +909,7 @@ public unsafe void ServiceMainCallback(int argCount, IntPtr argPointer) _commandPropsFrozen = true; if ((_status.controlsAccepted & AcceptOptions.ACCEPT_STOP) != 0) { - _status.controlsAccepted = _status.controlsAccepted | AcceptOptions.ACCEPT_SHUTDOWN; + _status.controlsAccepted |= AcceptOptions.ACCEPT_SHUTDOWN; } _status.currentState = ServiceControlStatus.STATE_START_PENDING; diff --git a/src/libraries/System.Speech/src/Internal/Synthesis/AudioFormatConverter.cs b/src/libraries/System.Speech/src/Internal/Synthesis/AudioFormatConverter.cs index 39c4db1d31e57..556ccb9eda1d0 100644 --- a/src/libraries/System.Speech/src/Internal/Synthesis/AudioFormatConverter.cs +++ b/src/libraries/System.Speech/src/Internal/Synthesis/AudioFormatConverter.cs @@ -221,7 +221,7 @@ private static byte[] CalcLinear2ULawTable() if (sample > uCLIP) sample = uCLIP; // clip the magnitude // Convert from 16 bit linear to ULaw. - sample = sample + uBIAS; + sample += uBIAS; exponent = s_exp_lut_linear2ulaw[(sample >> 7) & 0xFF]; mantissa = (sample >> (exponent + 3)) & 0x0F; diff --git a/src/libraries/System.Speech/src/Internal/Synthesis/SSmlParser.cs b/src/libraries/System.Speech/src/Internal/Synthesis/SSmlParser.cs index 11d62a89d2b1b..de41d0223ea56 100644 --- a/src/libraries/System.Speech/src/Internal/Synthesis/SSmlParser.cs +++ b/src/libraries/System.Speech/src/Internal/Synthesis/SSmlParser.cs @@ -1701,7 +1701,7 @@ private static bool TryParseNumber(string sNumber, ref ProsodyNumber number) float percent = (float)value / 100f; if (sNumber[0] != '+' && sNumber[0] != '-') { - number.Number = number.Number * percent; + number.Number *= percent; } else { diff --git a/src/libraries/System.Speech/src/Recognition/SrgsGrammar/SrgsElementFactory.cs b/src/libraries/System.Speech/src/Recognition/SrgsGrammar/SrgsElementFactory.cs index 06af30b081867..a731a35b8cb7b 100644 --- a/src/libraries/System.Speech/src/Recognition/SrgsGrammar/SrgsElementFactory.cs +++ b/src/libraries/System.Speech/src/Recognition/SrgsGrammar/SrgsElementFactory.cs @@ -151,7 +151,7 @@ void IElementFactory.AddScript(IGrammar grammar, string sRule, string code) SrgsRule rule = srgsGrammar.Rules[sRule]; if (rule != null) { - rule.Script = rule.Script + code; + rule.Script += code; } else { diff --git a/src/libraries/System.Speech/src/Recognition/SrgsGrammar/SrgsGrammar.cs b/src/libraries/System.Speech/src/Recognition/SrgsGrammar/SrgsGrammar.cs index 7837767ebc84f..0183a01dfe3c4 100644 --- a/src/libraries/System.Speech/src/Recognition/SrgsGrammar/SrgsGrammar.cs +++ b/src/libraries/System.Speech/src/Recognition/SrgsGrammar/SrgsGrammar.cs @@ -232,7 +232,7 @@ void IElement.PostParse(IElement parent) SrgsRule rule = Rules[script._name]; if (rule != null) { - rule.Script = rule.Script + script._value; + rule.Script += script._value; } else { diff --git a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EUCJPEncoding.cs b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EUCJPEncoding.cs index 7c4b7485d0c08..0135bfdb6d7da 100644 --- a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EUCJPEncoding.cs +++ b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EUCJPEncoding.cs @@ -63,11 +63,11 @@ protected override bool CleanUpBytes(ref int bytes) if (bytes >= 0xfa40 && bytes <= 0xfa5b) { if (bytes <= 0xfa49) - bytes = bytes - 0x0b51; + bytes -= 0x0b51; else if (bytes >= 0xfa4a && bytes <= 0xfa53) - bytes = bytes - 0x072f6; + bytes -= 0x072f6; else if (bytes >= 0xfa54 && bytes <= 0xfa57) - bytes = bytes - 0x0b5b; + bytes -= 0x0b5b; else if (bytes == 0xfa58) bytes = 0x878a; else if (bytes == 0xfa59) @@ -81,11 +81,11 @@ protected override bool CleanUpBytes(ref int bytes) { byte tc = unchecked((byte)bytes); if (tc < 0x5c) - bytes = bytes - 0x0d5f; + bytes -= 0x0d5f; else if (tc >= 0x80 && tc <= 0x9B) - bytes = bytes - 0x0d1d; + bytes -= 0x0d1d; else - bytes = bytes - 0x0d1c; + bytes -= 0x0d1c; } } diff --git a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/ISO2022Encoding.cs b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/ISO2022Encoding.cs index 602212497b433..65537fd283b2a 100644 --- a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/ISO2022Encoding.cs +++ b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/ISO2022Encoding.cs @@ -114,11 +114,11 @@ protected override bool CleanUpBytes(ref int bytes) if (bytes >= 0xfa40 && bytes <= 0xfa5b) { if (bytes <= 0xfa49) - bytes = bytes - 0x0b51; + bytes -= 0x0b51; else if (bytes >= 0xfa4a && bytes <= 0xfa53) - bytes = bytes - 0x072f6; + bytes -= 0x072f6; else if (bytes >= 0xfa54 && bytes <= 0xfa57) - bytes = bytes - 0x0b5b; + bytes -= 0x0b5b; else if (bytes == 0xfa58) bytes = 0x878a; else if (bytes == 0xfa59) @@ -132,11 +132,11 @@ protected override bool CleanUpBytes(ref int bytes) { byte tc = unchecked((byte)bytes); if (tc < 0x5c) - bytes = bytes - 0x0d5f; + bytes -= 0x0d5f; else if (tc >= 0x80 && tc <= 0x9B) - bytes = bytes - 0x0d1d; + bytes -= 0x0d1d; else - bytes = bytes - 0x0d1c; + bytes -= 0x0d1c; } } diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/BitStack.cs b/src/libraries/System.Text.Json/src/System/Text/Json/BitStack.cs index 9ba42d2620619..12255d985358c 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/BitStack.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/BitStack.cs @@ -47,7 +47,7 @@ public void PushFalse() { if (_currentDepth < AllocationFreeMaxDepth) { - _allocationFreeContainer = _allocationFreeContainer << 1; + _allocationFreeContainer <<= 1; } else { diff --git a/src/libraries/System.Threading/src/System/Threading/Barrier.cs b/src/libraries/System.Threading/src/System/Threading/Barrier.cs index 61114b240d0c8..8baebc3eb5815 100644 --- a/src/libraries/System.Threading/src/System/Threading/Barrier.cs +++ b/src/libraries/System.Threading/src/System/Threading/Barrier.cs @@ -814,7 +814,7 @@ private static void InvokePostPhaseAction(object? obj) private void SetResetEvents(bool observedSense) { // Increment the phase count using Volatile class because m_currentPhase is 64 bit long type, that could cause torn write on 32 bit machines - CurrentPhaseNumber = CurrentPhaseNumber + 1; + CurrentPhaseNumber++; if (observedSense) { _oddEvent.Reset(); diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/FieldBuilder.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/FieldBuilder.Mono.cs index 0ceb6a433e8b4..33f29efbfa32e 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/FieldBuilder.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/FieldBuilder.Mono.cs @@ -148,7 +148,7 @@ internal override int GetFieldOffset() internal void SetRVAData(byte[] data) { - attrs = attrs | FieldAttributes.HasFieldRVA; + attrs |= FieldAttributes.HasFieldRVA; rva_data = (byte[])data.Clone(); } diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/MonoArrayMethod.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/MonoArrayMethod.cs index 8421804e0b6b0..93f961ed2774b 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/MonoArrayMethod.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/MonoArrayMethod.cs @@ -167,8 +167,8 @@ public override string ToString() for (int i = 0; i < p.Length; ++i) { if (i > 0) - parms = parms + ", "; - parms = parms + p[i].ParameterType.Name; + parms += ", "; + parms += p[i].ParameterType.Name; } if (ReturnType != null) return ReturnType.Name + " " + Name + "(" + parms + ")"; diff --git a/src/mono/System.Private.CoreLib/src/System/String.Mono.cs b/src/mono/System.Private.CoreLib/src/System/String.Mono.cs index 780fd4fe66e24..c700d31af5059 100644 --- a/src/mono/System.Private.CoreLib/src/System/String.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/String.Mono.cs @@ -47,8 +47,8 @@ private static unsafe void memset(byte* dest, int val, int len) } if (val != 0) { - val = val | (val << 8); - val = val | (val << 16); + val |= (val << 8); + val |= (val << 16); } // align to 4 int rest = (int)dest & 3; diff --git a/src/mono/wasm/host/Options.cs b/src/mono/wasm/host/Options.cs index 3fa1de9912575..d2f64bf287f9f 100644 --- a/src/mono/wasm/host/Options.cs +++ b/src/mono/wasm/host/Options.cs @@ -1796,7 +1796,7 @@ private void AddCommand(Command value) base.Add(value); - help = help ?? value as HelpCommand; + help ??= value as HelpCommand; } public CommandSet Add(string header) @@ -1955,7 +1955,7 @@ public IEnumerable GetCompletions(string prefix = null) private static void ExtractToken(ref string input, out string rest) { rest = ""; - input = input ?? ""; + input ??= ""; int top = input.Length; for (int i = 0; i < top; i++)