411 references to Flags
System.Private.Uri (411)
System\Uri.cs (322)
55internal Flags _flags;
141_flags |= Flags.Debug_LeftConstructor;
149Debug.Assert(InFact(Flags.MinimalUriInfoSet) == (_info is not null));
163if (InFact(Flags.AllUriInfoSet))
175if (!InFact(Flags.HasUnicode))
196Debug.Assert((_flags & Flags.Debug_LeftConstructor) == 0);
247private void InterlockedSetFlags(Flags flags)
254Debug.Assert(sizeof(Flags) == sizeof(ulong));
270get { return (_flags & Flags.ImplicitFile) != 0; }
275get { return (_flags & (Flags.UncPath | Flags.DosPath)) != 0; }
280get { return (_flags & Flags.DosPath) != 0; }
285get { return (_flags & Flags.UncPath) != 0; }
290get { return (_flags & Flags.UnixPath) != 0; }
293private Flags HostType
295get { return _flags & Flags.HostTypeMask; }
321internal bool DisablePathAndQueryCanonicalization => (_flags & Flags.DisablePathAndQueryCanonicalization) != 0;
327return (_flags & Flags.UserDrivenParsing) != 0;
346private bool NotAny(Flags flags)
351private bool InFact(Flags flags)
356private static bool StaticNotAny(Flags allFlags, Flags checkFlags)
361private static bool StaticInFact(Flags allFlags, Flags checkFlags)
369Flags cF = _flags;
370if ((cF & Flags.MinimalUriInfoSet) == 0)
375Debug.Assert(_info != null && (_flags & Flags.MinimalUriInfoSet) != 0);
381if ((_flags & Flags.AllUriInfoSet) == 0)
395if (allowDnsOptimization && InFact(Flags.CanonicalDnsHost))
578_flags = Flags.Zero;
604dontEscape = InFact(Flags.UserEscaped);
624_flags = Flags.Zero;
840case Flags.DnsHostType: return UriHostNameType.Dns;
841case Flags.IPv4HostType: return UriHostNameType.IPv4;
842case Flags.IPv6HostType: return UriHostNameType.IPv6;
843case Flags.BasicHostType: return UriHostNameType.Basic;
844case Flags.UncHostType: return UriHostNameType.Basic;
845case Flags.UnknownHostType: return UriHostNameType.Unknown;
869return NotAny(Flags.NotDefaultPort);
897return InFact(Flags.LoopbackHost);
1020if (NotAny(Flags.HostNotCanonical | Flags.PathNotCanonical | Flags.ShouldBeCompressed))
1070if (InFact(Flags.PathNotCanonical) && !IsImplicitFile)
1083if (InFact(Flags.ShouldBeCompressed))
1123if (InFact(Flags.NotDefaultPort))
1202Flags hostType = HostType;
1203if (hostType == Flags.IPv6HostType || (hostType == Flags.BasicHostType && InFact(Flags.HostNotCanonical | Flags.E_HostNotCanonical)))
1230Flags hostType = HostType;
1231if (hostType == Flags.DnsHostType)
1235else if (hostType == Flags.IPv6HostType)
1244else if (hostType == Flags.BasicHostType && InFact(Flags.HostNotCanonical | Flags.E_HostNotCanonical))
1274return InFact(Flags.UserEscaped);
1380if (NotAny(Flags.AuthorityFound) || IsDosPath)
1644ushort nonCanonical = (ushort)((ushort)_flags & (ushort)Flags.CannotDisplayCanonical);
1645if (((_flags & (Flags.ShouldBeCompressed | Flags.FirstSlashAbsent | Flags.BackslashInPath)) != 0) ||
1648nonCanonical |= (ushort)Flags.PathNotCanonical;
1774if (NotAny(Flags.AllUriInfoSet) || other.NotAny(Flags.AllUriInfoSet))
1792if (InFact(Flags.CanonicalDnsHost) && other.InFact(Flags.CanonicalDnsHost))
1936private static ParsingError ParseScheme(string uriString, ref Flags flags, ref UriParser? syntax)
1938Debug.Assert((flags & Flags.Debug_LeftConstructor) == 0);
1948flags |= (Flags)6;
1953flags |= (Flags)5;
1965flags |= (Flags)idx;
1979Debug.Assert((_flags & Flags.CustomParser_ParseMinimalAlreadyCalled) != 0);
1987_flags |= Flags.ErrorOrParsingRecursion;
2008int idx = (int)(_flags & Flags.IndexMask);
2012_flags &= ~(Flags.IndexMask | Flags.UserDrivenParsing);
2030if (!OperatingSystem.IsWindows() && InFact(Flags.UnixPath))
2032_flags |= Flags.BasicHostType;
2033_flags |= (Flags)idx;
2044&& NotAny(Flags.ImplicitFile) && (idx + 1 < length))
2062_flags |= Flags.AuthorityFound;
2077_flags |= Flags.DosPath;
2082_flags |= Flags.AuthorityFound;
2101_flags |= Flags.UncPath;
2107_flags |= Flags.UnixPath | Flags.AuthorityFound;
2115if ((_flags & (Flags.UncPath | Flags.DosPath | Flags.UnixPath)) != 0)
2128_flags |= Flags.AuthorityFound;
2136else if (_syntax.InFact(UriSyntaxFlags.OptionalAuthority) && (InFact(Flags.AuthorityFound) ||
2139_flags |= Flags.AuthorityFound;
2147if (InFact(Flags.HasUnicode))
2152_flags |= ((Flags)idx | Flags.UnknownHostType);
2165if (InFact(Flags.HasUnicode))
2170_flags |= ((Flags)idx | Flags.UnknownHostType);
2177if (InFact(Flags.DosPath))
2179_flags |= (((_flags & Flags.AuthorityFound) != 0) ? Flags.BasicHostType : Flags.UnknownHostType);
2180_flags |= (Flags)idx;
2204if (hostTerminator == '\\' && NotAny(Flags.ImplicitFile) && _syntax.NotAny(UriSyntaxFlags.AllowDOSPath))
2209else if (!OperatingSystem.IsWindows() && hostTerminator == '/' && NotAny(Flags.ImplicitFile) && InFact(Flags.UncPath) && _syntax == UriParser.FileUri)
2222_flags |= (Flags)idx;
2238private unsafe void CreateUriInfo(Flags cF)
2253if ((cF & Flags.ImplicitFile) != 0)
2262if (StaticInFact(cF, Flags.UncPath))
2267int end = (int)(cF & Flags.IndexMask);
2284if ((cF & Flags.AuthorityFound) != 0)
2290if ((cF & (Flags.UncPath | Flags.DosPath)) != 0)
2294int end = (int)(cF & Flags.IndexMask);
2309if ((cF & Flags.HostTypeMask) == Flags.UnknownHostType
2310|| StaticInFact(cF, Flags.DosPath)
2314info.Offset.User = (int)(cF & Flags.IndexMask);
2317cF &= ~Flags.IndexMask;
2320cF |= Flags.SchemeNotCanonical;
2328if (HostType == Flags.BasicHostType)
2331info.Offset.Path = (int)(cF & Flags.IndexMask);
2332cF &= ~Flags.IndexMask;
2336if ((cF & Flags.HasUserInfo) != 0)
2352idx = (int)(cF & Flags.IndexMask);
2356cF &= ~Flags.IndexMask;
2361cF |= Flags.SchemeNotCanonical;
2374if ((cF & Flags.HasUnicode) != 0)
2394cF |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2410cF |= Flags.NotDefaultPort;
2416cF |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2424cF |= Flags.MinimalUriInfoSet;
2428Flags current = _flags;
2429while ((current & Flags.MinimalUriInfoSet) == 0)
2431Flags oldValue = Interlocked.CompareExchange(ref _flags, (current & ~Flags.IndexMask) | cF, current);
2436current = (Flags)oldValue;
2452if (NotAny(Flags.ErrorOrParsingRecursion))
2454_flags |= Flags.ErrorOrParsingRecursion;
2457_flags &= ~Flags.ErrorOrParsingRecursion;
2463Flags flags = _flags;
2470if (HostType == Flags.BasicHostType)
2483if (NotAny(Flags.ImplicitFile) || (result & Check.ReservedFound) != 0)
2485flags |= Flags.HostNotCanonical;
2489if (InFact(Flags.ImplicitFile) && (result & (Check.ReservedFound | Check.EscapedCanonical)) != 0)
2498flags |= Flags.E_HostNotCanonical;
2499if (NotAny(Flags.UserEscaped))
2509else if (NotAny(Flags.CanonicalDnsHost))
2515flags |= (Flags.HostNotCanonical | Flags.E_HostNotCanonical);
2524flags |= (Flags.HostNotCanonical | Flags.E_HostNotCanonical);
2536private static string CreateHostStringHelper(string str, int idx, int end, ref Flags flags, UriInfo info)
2540switch (flags & Flags.HostTypeMask)
2542case Flags.DnsHostType:
2546case Flags.IPv6HostType:
2556case Flags.IPv4HostType:
2560case Flags.UncHostType:
2564case Flags.BasicHostType:
2565if (StaticInFact(flags, Flags.DosPath))
2582case Flags.UnknownHostType:
2593flags |= Flags.LoopbackHost;
2613Flags flags = _flags & ~Flags.HostTypeMask;
2622flags &= ~Flags.HostTypeMask;
2623flags |= Flags.UnknownHostType;
2627if (err != ParsingError.None || (flags & Flags.HostTypeMask) == Flags.UnknownHostType)
2630_flags = (_flags & ~Flags.HostTypeMask) | Flags.BasicHostType;
2640_flags |= (Flags.HostNotCanonical | Flags.E_HostNotCanonical);
2644_flags = (_flags & ~Flags.HostTypeMask) | (flags & Flags.HostTypeMask);
2655_flags &= ~Flags.NotDefaultPort;
2656_flags |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2670_flags &= ~Flags.NotDefaultPort;
2672_flags |= Flags.NotDefaultPort;
2674_flags |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2692Debug.Assert(_info != null && (_flags & Flags.MinimalUriInfoSet) != 0);
2697ushort nonCanonical = unchecked((ushort)(((ushort)_flags & ((ushort)Flags.CannotDisplayCanonical << 7)) >> 6));
2698if (InFact(Flags.SchemeNotCanonical))
2700nonCanonical |= (ushort)Flags.SchemeNotCanonical;
2706if (InFact(Flags.ShouldBeCompressed | Flags.FirstSlashAbsent | Flags.BackslashInPath))
2708nonCanonical |= (ushort)Flags.PathNotCanonical;
2713nonCanonical |= (ushort)Flags.PathNotCanonical;
2731Debug.Assert(_info != null && (_flags & Flags.MinimalUriInfoSet) != 0);
2736ushort nonCanonical = unchecked((ushort)((ushort)_flags & (ushort)Flags.CannotDisplayCanonical));
2741if ((_flags & (Flags.ShouldBeCompressed | Flags.FirstSlashAbsent | Flags.BackslashInPath)) != 0)
2743nonCanonical |= (ushort)Flags.PathNotCanonical;
2748nonCanonical |= (ushort)Flags.PathNotCanonical;
2801Debug.Assert(InFact(Flags.AllUriInfoSet));
2810if (InFact(Flags.AuthorityFound))
2819if ((parts & UriComponents.UserInfo) != 0 && InFact(Flags.HasUserInfo))
2828if (NotAny(Flags.UserEscaped))
2842InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape,
2891if (formatAs != UriFormat.UriEscaped && HostType == Flags.BasicHostType && (nonCanonical & (ushort)UriComponents.Host) != 0)
2902InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape,
2914if ((parts & UriComponents.SerializationInfoString) != 0 && HostType == Flags.IPv6HostType && _info._moreInfo?.ScopeId is string scopeId)
2925(InFact(Flags.NotDefaultPort) || ((parts & UriComponents.StrongPort) != 0 && _syntax.DefaultPort != UriParser.NoDefaultPort)))
2944if (InFact(Flags.AuthorityFound) && dest.Length != 0 && dest[0] == '/')
2989if (NotAny(Flags.UserEscaped))
3004UnescapeMode mode = InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape;
3031if (!InFact(Flags.HasUserInfo))
3041if (!InFact(Flags.HasUserInfo))
3044if (InFact(Flags.NotDefaultPort) || _syntax.DefaultPort == UriParser.NoDefaultPort)
3059if (InFact(Flags.HasUserInfo))
3092if (InFact(Flags.NotDefaultPort | Flags.PortNotCanonical))
3104if (uriParts == UriComponents.Path && InFact(Flags.AuthorityFound) &&
3145if (InFact(Flags.NotDefaultPort) || _syntax.DefaultPort == UriParser.NoDefaultPort)
3155if (InFact(Flags.HasUserInfo))
3172if (NotAny(Flags.HasUserInfo))
3213Flags cF = Flags.Zero;
3219bool buildIriStringFromPath = InFact(Flags.HasUnicode);
3235cF |= Flags.SchemeNotCanonical;
3244cF |= Flags.SchemeNotCanonical;
3248if (((_flags & Flags.AuthorityFound) != 0) && (idx + i + 3 >= length || str[idx + i + 1] != '/' ||
3251cF |= Flags.SchemeNotCanonical;
3257if ((_flags & Flags.HasUserInfo) != 0)
3263cF |= Flags.UserNotCanonical;
3267cF |= Flags.E_UserNotCanonical;
3273cF |= Flags.UserIriCanonical;
3420if (((_flags & Flags.AuthorityFound) != 0) && ((syntaxFlags & UriSyntaxFlags.PathIsRooted) != 0)
3423cF |= Flags.FirstSlashAbsent;
3430if (IsDosPath || (((_flags & Flags.AuthorityFound) != 0) &&
3436cF |= (Flags.E_PathNotCanonical | Flags.PathNotCanonical);
3442cF |= (Flags.E_PathNotCanonical | Flags.PathNotCanonical);
3446if (((syntaxFlags & (UriSyntaxFlags.CompressPath)) != 0) && ((cF & Flags.E_PathNotCanonical) != 0 ||
3449cF |= Flags.ShouldBeCompressed;
3453cF |= Flags.BackslashInPath;
3458cF |= Flags.E_PathNotCanonical;
3468if (((_flags & Flags.ImplicitFile) == 0) || ((_flags & Flags.UserEscaped) != 0) ||
3472cF |= Flags.PathNotCanonical;
3477if (((_flags & Flags.ImplicitFile) != 0) && (result & (Check.ReservedFound | Check.EscapedCanonical)) != 0)
3486cF |= Flags.E_PathNotCanonical;
3493cF |= Flags.PathIriCanonical;
3540cF |= Flags.QueryNotCanonical;
3545cF |= Flags.E_QueryNotCanonical;
3552cF |= Flags.QueryIriCanonical;
3588cF |= Flags.FragmentNotCanonical;
3593cF |= Flags.E_FragmentNotCanonical;
3600cF |= Flags.FragmentIriCanonical;
3607cF |= Flags.AllUriInfoSet;
3614private static int ParseSchemeCheckImplicitFile(string uriString, ref ParsingError err, ref Flags flags, ref UriParser? syntax)
3617Debug.Assert((flags & Flags.Debug_LeftConstructor) == 0);
3633flags |= (Flags.UnixPath | Flags.ImplicitFile | Flags.AuthorityFound);
3662flags |= (Flags.DosPath | Flags.ImplicitFile | Flags.AuthorityFound);
3679flags |= (Flags.UncPath | Flags.ImplicitFile | Flags.AuthorityFound);
3783ref ParsingError err, ref Flags flags, UriParser syntax, ref string? newHost)
3785Debug.Assert((_flags & Flags.Debug_LeftConstructor) == 0 || (!_syntax.IsSimple && Monitor.IsEntered(_info)));
3792bool hasUnicode = ((flags & Flags.HasUnicode) != 0);
3795Debug.Assert((_flags & Flags.HasUserInfo) == 0 && (_flags & Flags.HostTypeMask) == 0);
3808flags &= ~Flags.UncPath; //UNC cannot have an empty hostname
3809if (StaticInFact(flags, Flags.ImplicitFile))
3812flags |= Flags.BasicHostType;
3834flags |= Flags.HasUserInfo;
3857flags |= Flags.UnknownHostType;
3862flags |= Flags.IPv6HostType;
3870IPv4AddressHelper.IsValid(new ReadOnlySpan<char>(pString + start, end - start), out int endSeq, false, StaticNotAny(flags, Flags.ImplicitFile), syntax.InFact(UriSyntaxFlags.V1_UnknownUri)))
3873flags |= Flags.IPv4HostType;
3881DomainNameHelper.IsValid(new ReadOnlySpan<char>(pString + start, end - start), iri: false, StaticNotAny(flags, Flags.ImplicitFile), out int domainNameLength))
3888flags |= Flags.DnsHostType;
3893flags |= Flags.CanonicalDnsHost;
3898DomainNameHelper.IsValid(new ReadOnlySpan<char>(pString + start, end - start), iri: true, StaticNotAny(flags, Flags.ImplicitFile), out domainNameLength))
3910if (UncNameHelper.IsValid(pString, start, ref end, StaticNotAny(flags, Flags.ImplicitFile)))
3914flags |= Flags.UncHostType;
3925if (end < length && pString[end] == '\\' && (flags & Flags.HostTypeMask) != Flags.HostNotParsed
3931flags |= Flags.UnknownHostType;
3934flags &= ~Flags.HostTypeMask;
3963flags &= ~Flags.HostTypeMask;
3978flags &= ~Flags.HostTypeMask;
3994flags &= ~Flags.HostTypeMask;
3999if ((flags & Flags.HostTypeMask) == Flags.HostNotParsed)
4002flags &= ~Flags.HasUserInfo;
4007flags |= Flags.BasicHostType;
4053flags |= Flags.UnknownHostType;
4058flags |= Flags.BasicHostType;
4078flags |= Flags.UnknownHostType;
4087bool hasUnicode, ref Flags flags,
4092flags |= Flags.DnsHostType;
4248if ((_flags & Flags.HasUnicode) != 0)
4304if (InFact(Flags.FirstSlashAbsent))
4319if (InFact(Flags.ShouldBeCompressed))
4326if (_syntax.InFact(UriSyntaxFlags.UnEscapeDotsAndSlashes) && InFact(Flags.PathNotCanonical)
4341if (InFact(Flags.E_PathNotCanonical) && NotAny(Flags.UserEscaped))
4364if (!OperatingSystem.IsWindows() && InFact(Flags.BackslashInPath) && _syntax.NotAny(UriSyntaxFlags.ConvertPathSlashes) && _syntax.InFact(UriSyntaxFlags.FileLikeUri) && !IsImplicitFile)
4382if (InFact(Flags.ShouldBeCompressed))
4387if (_syntax.InFact(UriSyntaxFlags.UnEscapeDotsAndSlashes) && InFact(Flags.PathNotCanonical)
4413if (InFact(Flags.ShouldBeCompressed) && dest.Length - offset > 0)
4422if (formatAs == UriFormat.UriEscaped && NotAny(Flags.UserEscaped) && InFact(Flags.E_PathNotCanonical))
4439if (formatAs != UriFormat.UriEscaped && InFact(Flags.PathNotCanonical))
4456UnescapeMode mode = InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape;
4671if (basePart.HostType == Flags.IPv6HostType)
4745if (basePart.HostType == Flags.IPv6HostType)
5059return InFact(Flags.AuthorityFound);