394 references to Flags
System.Private.Uri (394)
System\Uri.cs (310)
55internal Flags _flags; 146_flags |= Flags.Debug_LeftConstructor; 154Debug.Assert(InFact(Flags.MinimalUriInfoSet) == (_info is not null)); 168if (InFact(Flags.AllUriInfoSet)) 180if (!InFact(Flags.HasUnicode)) 201Debug.Assert((_flags & Flags.Debug_LeftConstructor) == 0); 252private void InterlockedSetFlags(Flags flags) 259Debug.Assert(sizeof(Flags) == sizeof(ulong)); 275get { return (_flags & Flags.ImplicitFile) != 0; } 280get { return (_flags & (Flags.UncPath | Flags.DosPath)) != 0; } 285get { return (_flags & Flags.DosPath) != 0; } 290get { return (_flags & Flags.UncPath) != 0; } 295get { return (_flags & Flags.UnixPath) != 0; } 298private Flags HostType 300get { return _flags & Flags.HostTypeMask; } 326internal bool DisablePathAndQueryCanonicalization => (_flags & Flags.DisablePathAndQueryCanonicalization) != 0; 332return (_flags & Flags.UserDrivenParsing) != 0; 351private bool NotAny(Flags flags) 356private bool InFact(Flags flags) 361private static bool StaticNotAny(Flags allFlags, Flags checkFlags) 366private static bool StaticInFact(Flags allFlags, Flags checkFlags) 374Flags cF = _flags; 375if ((cF & Flags.MinimalUriInfoSet) == 0) 380Debug.Assert(_info != null && (_flags & Flags.MinimalUriInfoSet) != 0); 386if ((_flags & Flags.AllUriInfoSet) == 0) 400if (allowDnsOptimization && InFact(Flags.CanonicalDnsHost)) 583_flags = Flags.Zero; 609dontEscape = InFact(Flags.UserEscaped); 629_flags = Flags.Zero; 836case Flags.DnsHostType: return UriHostNameType.Dns; 837case Flags.IPv4HostType: return UriHostNameType.IPv4; 838case Flags.IPv6HostType: return UriHostNameType.IPv6; 839case Flags.BasicHostType: return UriHostNameType.Basic; 840case Flags.UncHostType: return UriHostNameType.Basic; 841case Flags.UnknownHostType: return UriHostNameType.Unknown; 865return NotAny(Flags.NotDefaultPort); 893return InFact(Flags.LoopbackHost); 1016if (NotAny(Flags.HostNotCanonical | Flags.PathNotCanonical | Flags.ShouldBeCompressed)) 1066if (InFact(Flags.PathNotCanonical) && !IsImplicitFile) 1079if (InFact(Flags.ShouldBeCompressed)) 1119if (InFact(Flags.NotDefaultPort)) 1198Flags hostType = HostType; 1199if (hostType == Flags.IPv6HostType || (hostType == Flags.BasicHostType && InFact(Flags.HostNotCanonical | Flags.E_HostNotCanonical))) 1226Flags hostType = HostType; 1227if (hostType == Flags.DnsHostType) 1231else if (hostType == Flags.IPv6HostType) 1240else if (hostType == Flags.BasicHostType && InFact(Flags.HostNotCanonical | Flags.E_HostNotCanonical)) 1270return InFact(Flags.UserEscaped); 1377if (NotAny(Flags.AuthorityFound) || IsDosPath) 1641ushort nonCanonical = (ushort)((ushort)_flags & (ushort)Flags.CannotDisplayCanonical); 1642if (((_flags & (Flags.ShouldBeCompressed | Flags.FirstSlashAbsent | Flags.BackslashInPath)) != 0) || 1645nonCanonical |= (ushort)Flags.PathNotCanonical; 1771if (NotAny(Flags.AllUriInfoSet) || other.NotAny(Flags.AllUriInfoSet)) 1789if (InFact(Flags.CanonicalDnsHost) && other.InFact(Flags.CanonicalDnsHost)) 1931private static ParsingError ParseScheme(string uriString, ref Flags flags, ref UriParser? syntax) 1933Debug.Assert((flags & Flags.Debug_LeftConstructor) == 0); 1943flags |= (Flags)6; 1948flags |= (Flags)5; 1960flags |= (Flags)idx; 1974Debug.Assert((_flags & Flags.CustomParser_ParseMinimalAlreadyCalled) != 0); 1982_flags |= Flags.ErrorOrParsingRecursion; 2001int idx = (int)(_flags & Flags.IndexMask); 2004_flags &= ~(Flags.IndexMask | Flags.UserDrivenParsing); 2015if (!OperatingSystem.IsWindows() && InFact(Flags.UnixPath)) 2017_flags |= Flags.BasicHostType; 2018_flags |= (Flags)idx; 2028NotAny(Flags.ImplicitFile) && 2048_flags |= Flags.AuthorityFound; 2063_flags |= Flags.DosPath; 2068_flags |= Flags.AuthorityFound; 2088_flags |= Flags.UncPath; 2094_flags |= Flags.UnixPath | Flags.AuthorityFound; 2101if ((_flags & (Flags.UncPath | Flags.DosPath | Flags.UnixPath)) != 0) 2115_flags |= Flags.AuthorityFound; 2123else if (_syntax.InFact(UriSyntaxFlags.OptionalAuthority) && (InFact(Flags.AuthorityFound) || 2126_flags |= Flags.AuthorityFound; 2134if (InFact(Flags.HasUnicode)) 2139_flags |= ((Flags)idx | Flags.UnknownHostType); 2152if (InFact(Flags.HasUnicode)) 2157_flags |= ((Flags)idx | Flags.UnknownHostType); 2164if (InFact(Flags.DosPath)) 2166_flags |= (((_flags & Flags.AuthorityFound) != 0) ? Flags.BasicHostType : Flags.UnknownHostType); 2167_flags |= (Flags)idx; 2190if (hostTerminator == '\\' && NotAny(Flags.ImplicitFile) && _syntax.NotAny(UriSyntaxFlags.AllowDOSPath)) 2195else if (!OperatingSystem.IsWindows() && hostTerminator == '/' && NotAny(Flags.ImplicitFile) && InFact(Flags.UncPath) && _syntax == UriParser.FileUri) 2208_flags |= (Flags)idx; 2223private void CreateUriInfo(Flags cF) 2246if ((cF & Flags.ImplicitFile) != 0) 2248if (StaticInFact(cF, Flags.UncPath)) 2256int end = (int)(cF & Flags.IndexMask); 2269if ((cF & Flags.AuthorityFound) != 0) 2287if ((cF & (Flags.UncPath | Flags.DosPath)) != 0) 2291int end = (int)(cF & Flags.IndexMask); 2310if ((cF & Flags.HasUserInfo) != 0) 2325idx = (int)(cF & Flags.IndexMask); 2329cF &= ~Flags.IndexMask; 2333cF |= Flags.SchemeNotCanonical; 2337if ((cF & Flags.HostTypeMask) != Flags.UnknownHostType && (cF & Flags.DosPath) == 0 && 2358cF |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical); 2376cF |= Flags.NotDefaultPort; 2382cF |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical); 2392cF |= Flags.MinimalUriInfoSet; 2396Flags current = _flags; 2397while ((current & Flags.MinimalUriInfoSet) == 0) 2399Flags oldValue = Interlocked.CompareExchange(ref _flags, (current & ~Flags.IndexMask) | cF, current); 2420if (NotAny(Flags.ErrorOrParsingRecursion)) 2422_flags |= Flags.ErrorOrParsingRecursion; 2425_flags &= ~Flags.ErrorOrParsingRecursion; 2431Flags flags = _flags; 2438if (HostType == Flags.BasicHostType) 2446if (NotAny(Flags.ImplicitFile) || (result & Check.ReservedFound) != 0) 2448flags |= Flags.HostNotCanonical; 2452if (InFact(Flags.ImplicitFile) && (result & (Check.ReservedFound | Check.EscapedCanonical)) != 0) 2461flags |= Flags.E_HostNotCanonical; 2462if (NotAny(Flags.UserEscaped)) 2472else if (NotAny(Flags.CanonicalDnsHost)) 2478flags |= (Flags.HostNotCanonical | Flags.E_HostNotCanonical); 2487flags |= (Flags.HostNotCanonical | Flags.E_HostNotCanonical); 2499private static string CreateHostStringHelper(string str, int idx, int end, ref Flags flags, UriInfo info) 2503switch (flags & Flags.HostTypeMask) 2505case Flags.DnsHostType: 2509case Flags.IPv6HostType: 2519case Flags.IPv4HostType: 2523case Flags.UncHostType: 2527case Flags.BasicHostType: 2528if (StaticInFact(flags, Flags.DosPath)) 2545case Flags.UnknownHostType: 2556flags |= Flags.LoopbackHost; 2575Flags flags = _flags & ~Flags.HostTypeMask; 2582_flags = (_flags & ~Flags.HostTypeMask) | Flags.BasicHostType; 2592_flags |= (Flags.HostNotCanonical | Flags.E_HostNotCanonical); 2596_flags = (_flags & ~Flags.HostTypeMask) | (flags & Flags.HostTypeMask); 2607_flags &= ~Flags.NotDefaultPort; 2608_flags |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical); 2622_flags &= ~Flags.NotDefaultPort; 2624_flags |= Flags.NotDefaultPort; 2626_flags |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical); 2644Debug.Assert(_info != null && (_flags & Flags.MinimalUriInfoSet) != 0); 2649ushort nonCanonical = unchecked((ushort)(((ushort)_flags & ((ushort)Flags.CannotDisplayCanonical << 7)) >> 6)); 2650if (InFact(Flags.SchemeNotCanonical)) 2652nonCanonical |= (ushort)Flags.SchemeNotCanonical; 2658if (InFact(Flags.ShouldBeCompressed | Flags.FirstSlashAbsent | Flags.BackslashInPath)) 2660nonCanonical |= (ushort)Flags.PathNotCanonical; 2665nonCanonical |= (ushort)Flags.PathNotCanonical; 2683Debug.Assert(_info != null && (_flags & Flags.MinimalUriInfoSet) != 0); 2688ushort nonCanonical = unchecked((ushort)((ushort)_flags & (ushort)Flags.CannotDisplayCanonical)); 2693if ((_flags & (Flags.ShouldBeCompressed | Flags.FirstSlashAbsent | Flags.BackslashInPath)) != 0) 2695nonCanonical |= (ushort)Flags.PathNotCanonical; 2700nonCanonical |= (ushort)Flags.PathNotCanonical; 2753Debug.Assert(InFact(Flags.AllUriInfoSet)); 2762if (InFact(Flags.AuthorityFound)) 2771if ((parts & UriComponents.UserInfo) != 0 && InFact(Flags.HasUserInfo)) 2780if (NotAny(Flags.UserEscaped)) 2794InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape, 2843if (formatAs != UriFormat.UriEscaped && HostType == Flags.BasicHostType && (nonCanonical & (ushort)UriComponents.Host) != 0) 2854InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape, 2866if ((parts & UriComponents.SerializationInfoString) != 0 && HostType == Flags.IPv6HostType && _info._moreInfo?.ScopeId is string scopeId) 2877(InFact(Flags.NotDefaultPort) || ((parts & UriComponents.StrongPort) != 0 && _syntax.DefaultPort != UriParser.NoDefaultPort))) 2896if (InFact(Flags.AuthorityFound) && dest.Length != 0 && dest[0] == '/') 2941if (NotAny(Flags.UserEscaped)) 2956UnescapeMode mode = InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape; 2983if (!InFact(Flags.HasUserInfo)) 2993if (!InFact(Flags.HasUserInfo)) 2996if (InFact(Flags.NotDefaultPort) || _syntax.DefaultPort == UriParser.NoDefaultPort) 3011if (InFact(Flags.HasUserInfo)) 3044if (InFact(Flags.NotDefaultPort | Flags.PortNotCanonical)) 3056if (uriParts == UriComponents.Path && InFact(Flags.AuthorityFound) && 3097if (InFact(Flags.NotDefaultPort) || _syntax.DefaultPort == UriParser.NoDefaultPort) 3107if (InFact(Flags.HasUserInfo)) 3124if (NotAny(Flags.HasUserInfo)) 3165Flags cF = Flags.Zero; 3171bool buildIriStringFromPath = InFact(Flags.HasUnicode); 3185cF |= Flags.SchemeNotCanonical; 3202cF |= Flags.SchemeNotCanonical; 3209if ((_flags & Flags.AuthorityFound) != 0 && !str.Slice(schemeLength).StartsWith("://", StringComparison.Ordinal)) 3211cF |= Flags.SchemeNotCanonical | Flags.SchemeNotCanonical_NoTrailingSlashes; 3216if ((_flags & Flags.HasUserInfo) != 0) 3223cF |= Flags.UserNotCanonical; 3227cF |= Flags.E_UserNotCanonical; 3233cF |= Flags.UserIriCanonical; 3252if (InFact(Flags.DosPath | Flags.UnixPath)) 3254Debug.Assert(!InFact(Flags.HasUserInfo)); 3258InFact(Flags.AuthorityFound) ? _syntax.SchemeName + SchemeDelimiter : 3369if (((_flags & Flags.AuthorityFound) != 0) && ((syntaxFlags & UriSyntaxFlags.PathIsRooted) != 0) 3372cF |= Flags.FirstSlashAbsent; 3379if (IsDosPath || (((_flags & Flags.AuthorityFound) != 0) && 3385cF |= (Flags.E_PathNotCanonical | Flags.PathNotCanonical); 3391cF |= (Flags.E_PathNotCanonical | Flags.PathNotCanonical); 3395if (((syntaxFlags & (UriSyntaxFlags.CompressPath)) != 0) && ((cF & Flags.E_PathNotCanonical) != 0 || 3398cF |= Flags.ShouldBeCompressed; 3402cF |= Flags.BackslashInPath; 3407cF |= Flags.E_PathNotCanonical; 3417if (((_flags & Flags.ImplicitFile) == 0) || ((_flags & Flags.UserEscaped) != 0) || 3421cF |= Flags.PathNotCanonical; 3426if (((_flags & Flags.ImplicitFile) != 0) && (result & (Check.ReservedFound | Check.EscapedCanonical)) != 0) 3435cF |= Flags.E_PathNotCanonical; 3442cF |= Flags.PathIriCanonical; 3488cF |= Flags.QueryNotCanonical; 3493cF |= Flags.E_QueryNotCanonical; 3500cF |= Flags.QueryIriCanonical; 3536cF |= Flags.FragmentNotCanonical; 3541cF |= Flags.E_FragmentNotCanonical; 3548cF |= Flags.FragmentIriCanonical; 3554cF |= Flags.AllUriInfoSet; 3561private static int ParseSchemeCheckImplicitFile(string uriString, ref ParsingError err, ref Flags flags, ref UriParser? syntax) 3564Debug.Assert((flags & Flags.Debug_LeftConstructor) == 0); 3580flags |= (Flags.UnixPath | Flags.ImplicitFile | Flags.AuthorityFound); 3609flags |= (Flags.DosPath | Flags.ImplicitFile | Flags.AuthorityFound); 3626flags |= (Flags.UncPath | Flags.ImplicitFile | Flags.AuthorityFound); 3728private int CheckAuthorityHelper(ReadOnlySpan<char> str, int startOffset, out ParsingError err, ref Flags flags, UriSyntaxFlags syntaxFlags, ref string? newHost) 3730Debug.Assert((_flags & Flags.Debug_LeftConstructor) == 0 || (!_syntax.IsSimple && Monitor.IsEntered(_info))); 3731Debug.Assert((_flags & Flags.HasUserInfo) == 0 && (_flags & Flags.HostTypeMask) == 0); 3736bool hasUnicode = ((flags & Flags.HasUnicode) != 0); 3751flags &= ~Flags.UncPath; //UNC cannot have an empty hostname 3752if (StaticInFact(flags, Flags.ImplicitFile)) 3755flags |= Flags.BasicHostType; 3781flags |= Flags.HasUserInfo; 3812flags |= Flags.IPv6HostType; 3820IPv4AddressHelper.IsValid(str.Slice(i), out hostLength, allowIPv6: false, StaticNotAny(flags, Flags.ImplicitFile), (syntaxFlags & UriSyntaxFlags.V1_UnknownUri) != 0)) 3822flags |= Flags.IPv4HostType; 3830DomainNameHelper.IsValid(str.Slice(i), iri: false, StaticNotAny(flags, Flags.ImplicitFile), out hostLength)) 3835flags |= Flags.DnsHostType; 3840flags |= Flags.CanonicalDnsHost; 3845DomainNameHelper.IsValid(str.Slice(i), iri: true, StaticNotAny(flags, Flags.ImplicitFile), out hostLength)) 3847flags |= Flags.DnsHostType; 3871if (UncNameHelper.IsValid(str.Slice(i), StaticNotAny(flags, Flags.ImplicitFile), out hostLength)) 3875flags |= Flags.UncHostType; 3889if (hostDelimiter == '\\' && (flags & Flags.HostTypeMask) != Flags.HostNotParsed && (syntaxFlags & UriSyntaxFlags.FileLikeUri) == 0) 3897flags &= ~Flags.HostTypeMask; 3926flags &= ~Flags.HostTypeMask; 3942flags &= ~Flags.HostTypeMask; 3958flags &= ~Flags.HostTypeMask; 3963if ((flags & Flags.HostTypeMask) == Flags.HostNotParsed) 3966flags &= ~Flags.HasUserInfo; 3971flags |= Flags.BasicHostType; 4020flags |= Flags.BasicHostType; 4187if ((_flags & Flags.HasUnicode) != 0) 4238if (InFact(Flags.FirstSlashAbsent)) 4253if (InFact(Flags.ShouldBeCompressed)) 4260if (_syntax.InFact(UriSyntaxFlags.UnEscapeDotsAndSlashes) && InFact(Flags.PathNotCanonical) 4269if (InFact(Flags.E_PathNotCanonical) && NotAny(Flags.UserEscaped)) 4292if (!OperatingSystem.IsWindows() && InFact(Flags.BackslashInPath) && _syntax.NotAny(UriSyntaxFlags.ConvertPathSlashes) && _syntax.InFact(UriSyntaxFlags.FileLikeUri) && !IsImplicitFile) 4310if (InFact(Flags.ShouldBeCompressed)) 4315if (_syntax.InFact(UriSyntaxFlags.UnEscapeDotsAndSlashes) && InFact(Flags.PathNotCanonical) 4335if (InFact(Flags.ShouldBeCompressed) && dest.Length - offset > 0) 4344if (formatAs == UriFormat.UriEscaped && NotAny(Flags.UserEscaped) && InFact(Flags.E_PathNotCanonical)) 4361if (formatAs != UriFormat.UriEscaped && InFact(Flags.PathNotCanonical)) 4378UnescapeMode mode = InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape; 4553if (basePart.HostType == Flags.IPv6HostType) 4627if (basePart.HostType == Flags.IPv6HostType) 4941return InFact(Flags.AuthorityFound);
System\UriExt.cs (78)
31Debug.Assert(_originalUnicodeString is null && _info is null && _syntax is null && _flags == Flags.Zero); 34_flags |= Flags.UserEscaped; 37_flags |= Flags.DisablePathAndQueryCanonicalization; 55_flags |= Flags.HasUnicode; 66_flags &= Flags.UserEscaped | Flags.HasUnicode; // the only flags that makes sense for a relative uri 87_flags &= Flags.UserEscaped; // the only flag that makes sense for a relative uri 95if (NotAny(Flags.DosPath) && uriKind == UriKind.RelativeOrAbsolute && 97|| (!OperatingSystem.IsWindows() && InFact(Flags.UnixPath)))) 100_flags &= Flags.UserEscaped; // the only flag that makes sense for a relative uri 114_flags &= Flags.UserEscaped; // the only flag that makes sense for a relative uri 133_flags |= Flags.UserDrivenParsing; 143if (InFact(Flags.ErrorOrParsingRecursion)) 147_flags = Flags.UserDrivenParsing | (_flags & Flags.UserEscaped); 406Flags nonCanonical = (_flags & (Flags.E_CannotDisplayCanonical | Flags.IriCanonical)); 409if ((nonCanonical & (Flags.UserIriCanonical | Flags.PathIriCanonical | Flags.QueryIriCanonical | Flags.FragmentIriCanonical)) != 0) 411if ((nonCanonical & (Flags.E_UserNotCanonical | Flags.UserIriCanonical)) == (Flags.E_UserNotCanonical | Flags.UserIriCanonical)) 413nonCanonical &= ~(Flags.E_UserNotCanonical | Flags.UserIriCanonical); 416if ((nonCanonical & (Flags.E_PathNotCanonical | Flags.PathIriCanonical)) == (Flags.E_PathNotCanonical | Flags.PathIriCanonical)) 418nonCanonical &= ~(Flags.E_PathNotCanonical | Flags.PathIriCanonical); 421if ((nonCanonical & (Flags.E_QueryNotCanonical | Flags.QueryIriCanonical)) == (Flags.E_QueryNotCanonical | Flags.QueryIriCanonical)) 423nonCanonical &= ~(Flags.E_QueryNotCanonical | Flags.QueryIriCanonical); 426if ((nonCanonical & (Flags.E_FragmentNotCanonical | Flags.FragmentIriCanonical)) == (Flags.E_FragmentNotCanonical | Flags.FragmentIriCanonical)) 428nonCanonical &= ~(Flags.E_FragmentNotCanonical | Flags.FragmentIriCanonical); 433if (((nonCanonical & Flags.E_CannotDisplayCanonical & (Flags.E_UserNotCanonical | Flags.E_PathNotCanonical | 434Flags.E_QueryNotCanonical | Flags.E_FragmentNotCanonical)) != Flags.Zero)) 440if (InFact(Flags.AuthorityFound)) 442if (InFact(Flags.SchemeNotCanonical_NoTrailingSlashes)) 447if (InFact(Flags.UncPath | Flags.DosPath)) 462if (InFact(Flags.FirstSlashAbsent) && _info.Offset.Query > _info.Offset.Path) 468if (InFact(Flags.BackslashInPath)) 477if ((_flags & Flags.CanonicalDnsHost) == 0 && HostType != Flags.IPv6HostType) 644private Uri(Flags flags, UriParser? uriParser, string uri) 674Flags flags = Flags.Zero; 678flags |= Flags.UserEscaped; 681flags |= Flags.DisablePathAndQueryCanonicalization; 688return new Uri((flags & Flags.UserEscaped), null, uriString); 786if (baseUri.InFact(Flags.AuthorityFound)) 858if (((_flags & Flags.NotDefaultPort) != 0) || (uriComponents == UriComponents.StrongPort 875|| ((_flags & (Flags.HostNotCanonical | Flags.E_HostNotCanonical)) == 0))) 959if (InFact(Flags.AllUriInfoSet)) 966Debug.Assert(!InFact(Flags.HasUnicode) || otherUri.IsNotAbsoluteUri); 972if (InFact(Flags.MinimalUriInfoSet)) 974_flags &= ~(Flags.MinimalUriInfoSet | Flags.AllUriInfoSet | Flags.IndexMask); 977if (InFact(Flags.NotDefaultPort)) 991_flags |= (Flags)portIndex; // Port or path
System\UriScheme.cs (4)
77Debug.Assert(sizeof(Uri.Flags) == sizeof(ulong)); 80Uri.Flags previous = Interlocked.Or(ref uri._flags, Uri.Flags.CustomParser_ParseMinimalAlreadyCalled); 81if ((previous & Uri.Flags.CustomParser_ParseMinimalAlreadyCalled) != 0)
System\UriSyntax.cs (2)
271Debug.Assert(sizeof(Uri.Flags) == sizeof(ulong)); 272Interlocked.Or(ref thisUri._flags, Uri.Flags.CustomParser_ParseMinimalAlreadyCalled);