From fdd0f455cfc2108565f4c5c2f636f75fd3d31a40 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 31 Jan 2026 00:51:14 +0000 Subject: [PATCH 1/5] Initial plan From ffe9453f9364df7a99a704fa98d68ed6abc33e83 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 31 Jan 2026 01:15:13 +0000 Subject: [PATCH 2/5] Fix flag check simplifications in Uri.cs and XmlSchemaValidator.cs Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com> --- src/libraries/System.Private.Uri/src/System/Uri.cs | 3 +-- .../src/System/Xml/Schema/XmlSchemaValidator.cs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Private.Uri/src/System/Uri.cs b/src/libraries/System.Private.Uri/src/System/Uri.cs index 8548552949b797..a77362a27f8811 100644 --- a/src/libraries/System.Private.Uri/src/System/Uri.cs +++ b/src/libraries/System.Private.Uri/src/System/Uri.cs @@ -3302,8 +3302,7 @@ private void ParseRemaining() // (This is very unfortunate that the original design has included that feature) bool nonCanonical = false; if ((cF & Flags.DosPath) != 0 || (((cF & Flags.AuthorityFound) != 0) && - (((syntaxFlags & (UriSyntaxFlags.CompressPath | UriSyntaxFlags.ConvertPathSlashes)) != 0) || - (syntaxFlags & UriSyntaxFlags.UnEscapeDotsAndSlashes) != 0))) + ((syntaxFlags & (UriSyntaxFlags.CompressPath | UriSyntaxFlags.ConvertPathSlashes | UriSyntaxFlags.UnEscapeDotsAndSlashes)) != 0))) { if (((result & Check.DotSlashEscaped) != 0) && (syntaxFlags & UriSyntaxFlags.UnEscapeDotsAndSlashes) != 0) { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaValidator.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaValidator.cs index 81ccdd1ac1d75f..af5392d6583b80 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaValidator.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaValidator.cs @@ -170,7 +170,7 @@ public XmlSchemaValidator(XmlNameTable nameTable, XmlSchemaSet schemas, IXmlName _validationFlags = validationFlags; - if (((validationFlags & XmlSchemaValidationFlags.ProcessInlineSchema) != 0) || ((validationFlags & XmlSchemaValidationFlags.ProcessSchemaLocation) != 0)) + if ((validationFlags & (XmlSchemaValidationFlags.ProcessInlineSchema | XmlSchemaValidationFlags.ProcessSchemaLocation)) != 0) { //Process schema hints in xml document, hence user's set might change _schemaSet = new XmlSchemaSet(nameTable); _schemaSet.ValidationEventHandler += schemas.GetEventHandler(); From d6f51063a7e25816880fc16599465b11c6882a54 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 31 Jan 2026 01:17:36 +0000 Subject: [PATCH 3/5] Simplify flag checks throughout libraries Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com> --- .../src/System/Net/Security/TlsFrameHelper.cs | 2 +- src/libraries/System.Private.Uri/src/System/Uri.cs | 2 +- .../src/System/Reflection/Emit/ModuleBuilderImpl.cs | 2 +- .../ManualTypeMarshallingHelper.cs | 8 ++++---- .../Marshalling/StatefulMarshallingStrategy.cs | 6 +++--- .../Marshalling/StatelessMarshallingStrategy.cs | 6 +++--- .../System.Speech/src/Internal/SrgsCompiler/BackEnd.cs | 2 +- .../System.Speech/src/Recognition/RecognizerBase.cs | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/libraries/System.Net.Security/src/System/Net/Security/TlsFrameHelper.cs b/src/libraries/System.Net.Security/src/System/Net/Security/TlsFrameHelper.cs index dff33e22f58f55..6f7caa0d1cf5e2 100644 --- a/src/libraries/System.Net.Security/src/System/Net/Security/TlsFrameHelper.cs +++ b/src/libraries/System.Net.Security/src/System/Net/Security/TlsFrameHelper.cs @@ -526,7 +526,7 @@ private static bool TryParseHelloExtensions(ReadOnlySpan extensions, ref T info.SupportedVersions |= versions; } else if (extensionType == ExtensionType.ApplicationProtocols && (options == ProcessingOptions.All || - (options.HasFlag(ProcessingOptions.ApplicationProtocol) || options.HasFlag(ProcessingOptions.RawApplicationProtocol)))) + options.HasFlag(ProcessingOptions.ApplicationProtocol | ProcessingOptions.RawApplicationProtocol))) { if (!TryGetApplicationProtocolsFromExtension(extensionData, out ApplicationProtocolInfo alpn)) { diff --git a/src/libraries/System.Private.Uri/src/System/Uri.cs b/src/libraries/System.Private.Uri/src/System/Uri.cs index a77362a27f8811..51432a7cc925a1 100644 --- a/src/libraries/System.Private.Uri/src/System/Uri.cs +++ b/src/libraries/System.Private.Uri/src/System/Uri.cs @@ -3692,7 +3692,7 @@ private static int ParseSchemeCheckImplicitFile(string uriString, ref ParsingErr private int CheckAuthorityHelper(ReadOnlySpan str, int startOffset, out ParsingError err, ref Flags flags, UriSyntaxFlags syntaxFlags, ref string? newHost) { Debug.Assert((_flags & Flags.Debug_LeftConstructor) == 0 || (!_syntax.IsSimple && Monitor.IsEntered(_info))); - Debug.Assert((_flags & Flags.HasUserInfo) == 0 && (_flags & Flags.HostTypeMask) == 0); + Debug.Assert((_flags & (Flags.HasUserInfo | Flags.HostTypeMask)) == 0); Debug.Assert((uint)startOffset <= (uint)str.Length); err = ParsingError.None; diff --git a/src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ModuleBuilderImpl.cs b/src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ModuleBuilderImpl.cs index e87fa61926efb9..72a94d2a2f81e2 100644 --- a/src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ModuleBuilderImpl.cs +++ b/src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ModuleBuilderImpl.cs @@ -801,7 +801,7 @@ private BlobBuilder GetMethodArrayMethodSignature(ArrayMethod method) => Metadat this, method.ParameterTypes, method.ReturnType, GetSignatureConvention(method.CallingConvention), isInstance: IsInstance(method.CallingConvention)); private static bool IsInstance(CallingConventions callingConvention) => - callingConvention.HasFlag(CallingConventions.HasThis) || callingConvention.HasFlag(CallingConventions.ExplicitThis) ? true : false; + callingConvention.HasFlag(CallingConventions.HasThis | CallingConventions.ExplicitThis); internal static SignatureCallingConvention GetSignatureConvention(CallingConventions callingConventions) { diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs index 44f0c3a7e4d70b..ddd08d4633851b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/ManualTypeMarshallingHelper.cs @@ -458,7 +458,7 @@ or MarshalMode.ElementRef ITypeSymbol? nativeType = null; if (ModeUsesManagedToUnmanagedShape(mode)) { - if (!ModeOptionallyMatchesShape(mode) && !shape.HasFlag(MarshallerShape.CallerAllocatedBuffer) && !shape.HasFlag(MarshallerShape.ToUnmanaged)) + if (!ModeOptionallyMatchesShape(mode) && (shape & (MarshallerShape.CallerAllocatedBuffer | MarshallerShape.ToUnmanaged)) == 0) return null; if (isLinearCollectionMarshaller && methods.ManagedValuesSource is not null) @@ -481,7 +481,7 @@ or MarshalMode.ElementRef if (ModeUsesUnmanagedToManagedShape(mode)) { // Unmanaged to managed requires ToManaged either with or without guaranteed unmarshal - if (!ModeOptionallyMatchesShape(mode) && !shape.HasFlag(MarshallerShape.GuaranteedUnmarshal) && !shape.HasFlag(MarshallerShape.ToManaged)) + if (!ModeOptionallyMatchesShape(mode) && (shape & (MarshallerShape.GuaranteedUnmarshal | MarshallerShape.ToManaged)) == 0) return null; if (isLinearCollectionMarshaller) @@ -559,7 +559,7 @@ or MarshalMode.ElementRef if (ModeUsesManagedToUnmanagedShape(mode)) { // Managed to unmanaged requires ToUnmanaged either with or without the caller-allocated buffer - if (mode != MarshalMode.Default && !shape.HasFlag(MarshallerShape.CallerAllocatedBuffer) && !shape.HasFlag(MarshallerShape.ToUnmanaged)) + if (mode != MarshalMode.Default && (shape & (MarshallerShape.CallerAllocatedBuffer | MarshallerShape.ToUnmanaged)) == 0) return null; if (methods.ToUnmanaged is not null) @@ -577,7 +577,7 @@ or MarshalMode.ElementRef if (ModeUsesUnmanagedToManagedShape(mode)) { // Unmanaged to managed requires ToManaged either with or without guaranteed unmarshal - if (mode != MarshalMode.Default && !shape.HasFlag(MarshallerShape.GuaranteedUnmarshal) && !shape.HasFlag(MarshallerShape.ToManaged)) + if (mode != MarshalMode.Default && (shape & (MarshallerShape.GuaranteedUnmarshal | MarshallerShape.ToManaged)) == 0) return null; if (methods.FromUnmanaged is not null && nativeType is null) diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StatefulMarshallingStrategy.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StatefulMarshallingStrategy.cs index 6cc20f83a48e06..ed757491033bf6 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StatefulMarshallingStrategy.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StatefulMarshallingStrategy.cs @@ -81,7 +81,7 @@ public IEnumerable GenerateMarshalStatements(StubIdentifierCont public IEnumerable GeneratePinnedMarshalStatements(StubIdentifierContext context) { - if (!shape.HasFlag(MarshallerShape.ToUnmanaged) && !shape.HasFlag(MarshallerShape.CallerAllocatedBuffer)) + if ((shape & (MarshallerShape.ToUnmanaged | MarshallerShape.CallerAllocatedBuffer)) == 0) yield break; (_, string nativeIdentifier) = context.GetIdentifiers(info); @@ -111,7 +111,7 @@ public IEnumerable GenerateUnmarshalStatements(StubIdentifierCo public IEnumerable GenerateUnmarshalCaptureStatements(StubIdentifierContext context) { - if (!shape.HasFlag(MarshallerShape.ToManaged) && !shape.HasFlag(MarshallerShape.GuaranteedUnmarshal)) + if ((shape & (MarshallerShape.ToManaged | MarshallerShape.GuaranteedUnmarshal)) == 0) yield break; (_, string nativeIdentifier) = context.GetIdentifiers(info); @@ -375,7 +375,7 @@ public IEnumerable GenerateMarshalStatements(StubIdentifierCont yield break; } - if (!shape.HasFlag(MarshallerShape.ToUnmanaged) && !shape.HasFlag(MarshallerShape.CallerAllocatedBuffer)) + if ((shape & (MarshallerShape.ToUnmanaged | MarshallerShape.CallerAllocatedBuffer)) == 0) yield break; yield return elementsMarshalling.GenerateMarshalStatement(context); diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StatelessMarshallingStrategy.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StatelessMarshallingStrategy.cs index da13f490614238..335bd07e8d4267 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StatelessMarshallingStrategy.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/StatelessMarshallingStrategy.cs @@ -50,7 +50,7 @@ public IEnumerable GenerateGuaranteedUnmarshalStatements(StubId public IEnumerable GenerateMarshalStatements(StubIdentifierContext context) { - if (!shape.HasFlag(MarshallerShape.ToUnmanaged) && !shape.HasFlag(MarshallerShape.CallerAllocatedBuffer)) + if ((shape & (MarshallerShape.ToUnmanaged | MarshallerShape.CallerAllocatedBuffer)) == 0) yield break; (string managedIdentifier, string nativeIdentifier) = context.GetIdentifiers(info); @@ -384,7 +384,7 @@ public IEnumerable GenerateGuaranteedUnmarshalStatements(StubId public IEnumerable GenerateMarshalStatements(StubIdentifierContext context) { - if (!shape.HasFlag(MarshallerShape.ToUnmanaged) && !shape.HasFlag(MarshallerShape.CallerAllocatedBuffer)) + if ((shape & (MarshallerShape.ToUnmanaged | MarshallerShape.CallerAllocatedBuffer)) == 0) yield break; if (shape.HasFlag(MarshallerShape.ToUnmanaged) @@ -672,7 +672,7 @@ public IEnumerable GenerateMarshalStatements(StubIdentifierCont yield return statement; } - if (!shape.HasFlag(MarshallerShape.ToUnmanaged) && !shape.HasFlag(MarshallerShape.CallerAllocatedBuffer)) + if ((shape & (MarshallerShape.ToUnmanaged | MarshallerShape.CallerAllocatedBuffer)) == 0) yield break; yield return elementsMarshalling.GenerateMarshalStatement(context); diff --git a/src/libraries/System.Speech/src/Internal/SrgsCompiler/BackEnd.cs b/src/libraries/System.Speech/src/Internal/SrgsCompiler/BackEnd.cs index 0308d09958ba4f..b3d5480c2d5adb 100644 --- a/src/libraries/System.Speech/src/Internal/SrgsCompiler/BackEnd.cs +++ b/src/libraries/System.Speech/src/Internal/SrgsCompiler/BackEnd.cs @@ -265,7 +265,7 @@ internal Rule CreateRule(string name, SPCFGRULEATTRIBUTES attributes) // - To maintain maximal backwards compatibility, if a rule is marked as Import, we will unmark TopLevel/Active/Root. // - This changes the behavior when application tries to activate this rule. However, given that it is already // broken/fragile, we believe it is better to change the behavior. - if ((attributes & SPCFGRULEATTRIBUTES.SPRAF_Import) != 0 && ((attributes & SPCFGRULEATTRIBUTES.SPRAF_TopLevel) != 0 || (attributes & SPCFGRULEATTRIBUTES.SPRAF_Active) != 0 || (attributes & SPCFGRULEATTRIBUTES.SPRAF_Root) != 0)) + if ((attributes & SPCFGRULEATTRIBUTES.SPRAF_Import) != 0 && (attributes & (SPCFGRULEATTRIBUTES.SPRAF_TopLevel | SPCFGRULEATTRIBUTES.SPRAF_Active | SPCFGRULEATTRIBUTES.SPRAF_Root)) != 0) { attributes &= ~(SPCFGRULEATTRIBUTES.SPRAF_TopLevel | SPCFGRULEATTRIBUTES.SPRAF_Active | SPCFGRULEATTRIBUTES.SPRAF_Root); } diff --git a/src/libraries/System.Speech/src/Recognition/RecognizerBase.cs b/src/libraries/System.Speech/src/Recognition/RecognizerBase.cs index 2c98f3b83a2951..72bfe958165b55 100644 --- a/src/libraries/System.Speech/src/Recognition/RecognizerBase.cs +++ b/src/libraries/System.Speech/src/Recognition/RecognizerBase.cs @@ -2638,7 +2638,7 @@ private static SpeechEmulationCompareFlags ConvertCompareOptions(CompareOptions { CompareOptions handledOptions = CompareOptions.IgnoreCase | CompareOptions.OrdinalIgnoreCase | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.Ordinal; SpeechEmulationCompareFlags flags = 0; - if ((compareOptions & CompareOptions.IgnoreCase) != 0 || (compareOptions & CompareOptions.OrdinalIgnoreCase) != 0) + if ((compareOptions & (CompareOptions.IgnoreCase | CompareOptions.OrdinalIgnoreCase)) != 0) { flags |= SpeechEmulationCompareFlags.SECFIgnoreCase; } From 247eb0dbcf68a2a73a290fd417fcf0c66e3ac64e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 31 Jan 2026 01:39:12 +0000 Subject: [PATCH 4/5] Simplify flag checks in multiple files per issue #93954 patterns Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com> --- .../Common/tests/System/Net/Security/FakeNtlmServer.cs | 2 +- .../System/Net/NegotiateAuthenticationPal.ManagedNtlm.cs | 2 +- .../tests/TypeBuilder/TypeBuilderDefineNestedType.cs | 2 +- .../RevocationTests/DynamicRevocationTests.cs | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libraries/Common/tests/System/Net/Security/FakeNtlmServer.cs b/src/libraries/Common/tests/System/Net/Security/FakeNtlmServer.cs index 6f576d927b2190..0eadca8115b85a 100644 --- a/src/libraries/Common/tests/System/Net/Security/FakeNtlmServer.cs +++ b/src/libraries/Common/tests/System/Net/Security/FakeNtlmServer.cs @@ -361,7 +361,7 @@ private void ValidateAuthentication(byte[] incomingBlob) // Decrypt exportedSessionKey with sessionBaseKey Span exportedSessionKey = stackalloc byte[16]; if (flags.HasFlag(Flags.NegotiateKeyExchange) && - (flags.HasFlag(Flags.NegotiateSeal) || flags.HasFlag(Flags.NegotiateSign))) + (flags & (Flags.NegotiateSeal | Flags.NegotiateSign)) != 0) { using (RC4 rc4 = new RC4(sessionBaseKey)) { diff --git a/src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.ManagedNtlm.cs b/src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.ManagedNtlm.cs index df2ffee5fe2910..033e8b45d0682b 100644 --- a/src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.ManagedNtlm.cs +++ b/src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.ManagedNtlm.cs @@ -658,7 +658,7 @@ private static byte[] DeriveKey(ReadOnlySpan exportedSessionKey, ReadOnlyS RandomNumberGenerator.Fill(exportedSessionKey); // Both flags are necessary to exchange keys needed for MIC (!) - Debug.Assert(flags.HasFlag(Flags.NegotiateSign) && flags.HasFlag(Flags.NegotiateKeyExchange)); + Debug.Assert((flags & (Flags.NegotiateSign | Flags.NegotiateKeyExchange)) == (Flags.NegotiateSign | Flags.NegotiateKeyExchange)); // Derive session base key Span sessionBaseKey = stackalloc byte[HMACMD5.HashSizeInBytes]; diff --git a/src/libraries/System.Reflection.Emit/tests/TypeBuilder/TypeBuilderDefineNestedType.cs b/src/libraries/System.Reflection.Emit/tests/TypeBuilder/TypeBuilderDefineNestedType.cs index c80d56b4e5d694..56c80dccd88961 100644 --- a/src/libraries/System.Reflection.Emit/tests/TypeBuilder/TypeBuilderDefineNestedType.cs +++ b/src/libraries/System.Reflection.Emit/tests/TypeBuilder/TypeBuilderDefineNestedType.cs @@ -65,7 +65,7 @@ public void DefineNestedType(string name, TypeAttributes attributes, Type parent void Verify(TypeBuilder type, TypeBuilder declaringType) { - bool allowsNullParent = attributes.HasFlag(TypeAttributes.Abstract) && attributes.HasFlag(TypeAttributes.ClassSemanticsMask); + bool allowsNullParent = (attributes & (TypeAttributes.Abstract | TypeAttributes.ClassSemanticsMask)) == (TypeAttributes.Abstract | TypeAttributes.ClassSemanticsMask); Type baseType = allowsNullParent ? parent : (parent ?? typeof(object)); Helpers.VerifyType(type, declaringType.Module, declaringType, name, attributes, baseType, typesize, packingSize, implementedInterfaces); } diff --git a/src/libraries/System.Security.Cryptography/tests/X509Certificates/RevocationTests/DynamicRevocationTests.cs b/src/libraries/System.Security.Cryptography/tests/X509Certificates/RevocationTests/DynamicRevocationTests.cs index 015166f8f776c4..ffc6486896cdea 100644 --- a/src/libraries/System.Security.Cryptography/tests/X509Certificates/RevocationTests/DynamicRevocationTests.cs +++ b/src/libraries/System.Security.Cryptography/tests/X509Certificates/RevocationTests/DynamicRevocationTests.cs @@ -97,7 +97,7 @@ public static IEnumerable AllViableRevocation [MemberData(nameof(AllViableRevocation))] public static void NothingRevoked(PkiOptions pkiOptions) { - bool usingCrl = pkiOptions.HasFlag(PkiOptions.IssuerRevocationViaCrl) || pkiOptions.HasFlag(PkiOptions.EndEntityRevocationViaCrl); + bool usingCrl = (pkiOptions & PkiOptions.CrlEverywhere) != 0; SimpleTest( pkiOptions, (root, intermediate, endEntity, holder, responder) => @@ -1012,7 +1012,7 @@ public static void RevokeIntermediateWithExpiredRevocation(PkiOptions pkiOptions [MemberData(nameof(AllViableRevocation))] public static void CheckEndEntityWithExpiredRevocation(PkiOptions pkiOptions) { - bool usingCrl = pkiOptions.HasFlag(PkiOptions.IssuerRevocationViaCrl) || pkiOptions.HasFlag(PkiOptions.EndEntityRevocationViaCrl); + bool usingCrl = (pkiOptions & PkiOptions.CrlEverywhere) != 0; SimpleTest( pkiOptions, (root, intermediate, endEntity, holder, responder) => @@ -1039,7 +1039,7 @@ public static void CheckEndEntityWithExpiredRevocation(PkiOptions pkiOptions) [ActiveIssue("https://github.com/dotnet/runtime/issues/31249", PlatformSupport.AppleCrypto)] public static void CheckIntermediateWithExpiredRevocation(PkiOptions pkiOptions) { - bool usingCrl = pkiOptions.HasFlag(PkiOptions.IssuerRevocationViaCrl) || pkiOptions.HasFlag(PkiOptions.EndEntityRevocationViaCrl); + bool usingCrl = (pkiOptions & PkiOptions.CrlEverywhere) != 0; SimpleTest( pkiOptions, (root, intermediate, endEntity, holder, responder) => From 482518341502e3d3b86482ac8f0b0859e470dac8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 31 Jan 2026 01:59:50 +0000 Subject: [PATCH 5/5] Simplify HasFlag(A) && !HasFlag(B) patterns across libraries Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com> --- src/libraries/Common/src/System/Number.Parsing.Common.cs | 2 +- src/libraries/System.Private.Uri/src/System/Uri.cs | 8 ++++---- .../gen/UpgradeToGeneratedRegexCodeFixer.cs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libraries/Common/src/System/Number.Parsing.Common.cs b/src/libraries/Common/src/System/Number.Parsing.Common.cs index e43cbe14c29226..25f2a2035511b9 100644 --- a/src/libraries/Common/src/System/Number.Parsing.Common.cs +++ b/src/libraries/Common/src/System/Number.Parsing.Common.cs @@ -62,7 +62,7 @@ private static unsafe bool TryParseNumber(scoped ref TChar* str, TChar* s { // Eat whitespace unless we've found a sign which isn't followed by a currency symbol. // "-Kr 1231.47" is legal but "- 1231.47" is not. - if (!IsWhite(ch) || (styles & NumberStyles.AllowLeadingWhite) == 0 || ((state & StateSign) != 0 && (state & StateCurrency) == 0 && info.NumberNegativePattern != 2)) + if (!IsWhite(ch) || (styles & NumberStyles.AllowLeadingWhite) == 0 || ((state & (StateSign | StateCurrency)) == StateSign && info.NumberNegativePattern != 2)) { if (((styles & NumberStyles.AllowLeadingSign) != 0) && (state & StateSign) == 0 && ((next = MatchChars(p, strEnd, info.PositiveSignTChar())) != null || ((next = MatchNegativeSignChars(p, strEnd, info)) != null && (number.IsNegative = true)))) { diff --git a/src/libraries/System.Private.Uri/src/System/Uri.cs b/src/libraries/System.Private.Uri/src/System/Uri.cs index 51432a7cc925a1..164cdb1f4d99b1 100644 --- a/src/libraries/System.Private.Uri/src/System/Uri.cs +++ b/src/libraries/System.Private.Uri/src/System/Uri.cs @@ -2195,7 +2195,7 @@ private ParsingError PrivateParseMinimal() return ParsingError.BadAuthorityTerminator; } // When the hostTerminator is '/' on Unix, use the UnixFile syntax (preserve backslashes) - else if (!OperatingSystem.IsWindows() && hostTerminator == '/' && NotAny(Flags.ImplicitFile) && InFact(Flags.UncPath) && _syntax == UriParser.FileUri) + else if (!OperatingSystem.IsWindows() && hostTerminator == '/' && (_flags & (Flags.ImplicitFile | Flags.UncPath)) == Flags.UncPath && _syntax == UriParser.FileUri) { _syntax = UriParser.UnixFileUri; } @@ -4233,7 +4233,7 @@ private void GetCanonicalPath(ref ValueStringBuilder dest, UriFormat formatAs) else { //Note: we may produce non escaped Uri characters on the wire - if (InFact(Flags.E_PathNotCanonical) && NotAny(Flags.UserEscaped)) + if ((_flags & (Flags.E_PathNotCanonical | Flags.UserEscaped)) == Flags.E_PathNotCanonical) { ReadOnlySpan str = _string; @@ -4256,7 +4256,7 @@ private void GetCanonicalPath(ref ValueStringBuilder dest, UriFormat formatAs) } // On Unix, escape '\\' in path of file uris to '%5C' canonical form. - if (!OperatingSystem.IsWindows() && InFact(Flags.BackslashInPath) && _syntax.NotAny(UriSyntaxFlags.ConvertPathSlashes) && _syntax.InFact(UriSyntaxFlags.FileLikeUri) && !IsImplicitFile) + if (!OperatingSystem.IsWindows() && InFact(Flags.BackslashInPath) && (_syntax.Flags & (UriSyntaxFlags.ConvertPathSlashes | UriSyntaxFlags.FileLikeUri)) == UriSyntaxFlags.FileLikeUri && !IsImplicitFile) { // We can't do an in-place escape, create a copy var copy = new ValueStringBuilder(stackalloc char[StackallocThreshold]); @@ -4310,7 +4310,7 @@ private void GetCanonicalPath(ref ValueStringBuilder dest, UriFormat formatAs) } // Escape path if requested and found as not fully escaped - if (formatAs == UriFormat.UriEscaped && NotAny(Flags.UserEscaped) && InFact(Flags.E_PathNotCanonical)) + if (formatAs == UriFormat.UriEscaped && (_flags & (Flags.UserEscaped | Flags.E_PathNotCanonical)) == Flags.E_PathNotCanonical) { //Note: Flags.UserEscaped check is solely based on trusting the user diff --git a/src/libraries/System.Text.RegularExpressions/gen/UpgradeToGeneratedRegexCodeFixer.cs b/src/libraries/System.Text.RegularExpressions/gen/UpgradeToGeneratedRegexCodeFixer.cs index a8548a3bd0bfce..fec20949c0295d 100644 --- a/src/libraries/System.Text.RegularExpressions/gen/UpgradeToGeneratedRegexCodeFixer.cs +++ b/src/libraries/System.Text.RegularExpressions/gen/UpgradeToGeneratedRegexCodeFixer.cs @@ -299,7 +299,7 @@ private static Document TryAddNewMember( // If the options include IgnoreCase and don't specify CultureInvariant then we will have to calculate the user's current culture in order to pass // it in as a parameter. If the user specified IgnoreCase, but also selected CultureInvariant, then we skip as the default is to use Invariant culture. SyntaxNode? cultureNameValue = null; - if ((regexOptions & RegexOptions.IgnoreCase) != 0 && (regexOptions & RegexOptions.CultureInvariant) == 0) + if ((regexOptions & (RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)) == RegexOptions.IgnoreCase) { // If CultureInvariant wasn't specified as options, we default to the current culture. cultureNameValue = generator.LiteralExpression(CultureInfo.CurrentCulture.Name);