Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libraries/Common/src/System/Number.Parsing.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private static unsafe bool TryParseNumber<TChar>(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<TChar>())) != null || ((next = MatchNegativeSignChars(p, strEnd, info)) != null && (number.IsNegative = true))))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ private void ValidateAuthentication(byte[] incomingBlob)
// Decrypt exportedSessionKey with sessionBaseKey
Span<byte> 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))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ private static byte[] DeriveKey(ReadOnlySpan<byte> 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<byte> sessionBaseKey = stackalloc byte[HMACMD5.HashSizeInBytes];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ private static bool TryParseHelloExtensions(ReadOnlySpan<byte> 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))
{
Expand Down
13 changes: 6 additions & 7 deletions src/libraries/System.Private.Uri/src/System/Uri.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -3693,7 +3692,7 @@ private static int ParseSchemeCheckImplicitFile(string uriString, ref ParsingErr
private int CheckAuthorityHelper(ReadOnlySpan<char> 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;
Expand Down Expand Up @@ -4234,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<char> str = _string;

Expand All @@ -4257,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]);
Expand Down Expand Up @@ -4311,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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public IEnumerable<StatementSyntax> GenerateMarshalStatements(StubIdentifierCont

public IEnumerable<StatementSyntax> 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);
Expand Down Expand Up @@ -111,7 +111,7 @@ public IEnumerable<StatementSyntax> GenerateUnmarshalStatements(StubIdentifierCo

public IEnumerable<StatementSyntax> 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);
Expand Down Expand Up @@ -375,7 +375,7 @@ public IEnumerable<StatementSyntax> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public IEnumerable<StatementSyntax> GenerateGuaranteedUnmarshalStatements(StubId

public IEnumerable<StatementSyntax> 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);
Expand Down Expand Up @@ -384,7 +384,7 @@ public IEnumerable<StatementSyntax> GenerateGuaranteedUnmarshalStatements(StubId

public IEnumerable<StatementSyntax> 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)
Expand Down Expand Up @@ -672,7 +672,7 @@ public IEnumerable<StatementSyntax> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static IEnumerable<object[]> 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) =>
Expand Down Expand Up @@ -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) =>
Expand All @@ -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) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading