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);
1381if (NotAny(Flags.AuthorityFound) || IsDosPath)
1645ushort nonCanonical = (ushort)((ushort)_flags & (ushort)Flags.CannotDisplayCanonical);
1646if (((_flags & (Flags.ShouldBeCompressed | Flags.FirstSlashAbsent | Flags.BackslashInPath)) != 0) ||
1649nonCanonical |= (ushort)Flags.PathNotCanonical;
1775if (NotAny(Flags.AllUriInfoSet) || other.NotAny(Flags.AllUriInfoSet))
1793if (InFact(Flags.CanonicalDnsHost) && other.InFact(Flags.CanonicalDnsHost))
1937private static ParsingError ParseScheme(string uriString, ref Flags flags, ref UriParser? syntax)
1939Debug.Assert((flags & Flags.Debug_LeftConstructor) == 0);
1949flags |= (Flags)6;
1954flags |= (Flags)5;
1966flags |= (Flags)idx;
1980Debug.Assert((_flags & Flags.CustomParser_ParseMinimalAlreadyCalled) != 0);
1988_flags |= Flags.ErrorOrParsingRecursion;
2009int idx = (int)(_flags & Flags.IndexMask);
2013_flags &= ~(Flags.IndexMask | Flags.UserDrivenParsing);
2031if (!OperatingSystem.IsWindows() && InFact(Flags.UnixPath))
2033_flags |= Flags.BasicHostType;
2034_flags |= (Flags)idx;
2045&& NotAny(Flags.ImplicitFile) && (idx + 1 < length))
2063_flags |= Flags.AuthorityFound;
2078_flags |= Flags.DosPath;
2083_flags |= Flags.AuthorityFound;
2102_flags |= Flags.UncPath;
2108_flags |= Flags.UnixPath | Flags.AuthorityFound;
2116if ((_flags & (Flags.UncPath | Flags.DosPath | Flags.UnixPath)) != 0)
2129_flags |= Flags.AuthorityFound;
2137else if (_syntax.InFact(UriSyntaxFlags.OptionalAuthority) && (InFact(Flags.AuthorityFound) ||
2140_flags |= Flags.AuthorityFound;
2148if (InFact(Flags.HasUnicode))
2153_flags |= ((Flags)idx | Flags.UnknownHostType);
2166if (InFact(Flags.HasUnicode))
2171_flags |= ((Flags)idx | Flags.UnknownHostType);
2178if (InFact(Flags.DosPath))
2180_flags |= (((_flags & Flags.AuthorityFound) != 0) ? Flags.BasicHostType : Flags.UnknownHostType);
2181_flags |= (Flags)idx;
2205if (hostTerminator == '\\' && NotAny(Flags.ImplicitFile) && _syntax.NotAny(UriSyntaxFlags.AllowDOSPath))
2210else if (!OperatingSystem.IsWindows() && hostTerminator == '/' && NotAny(Flags.ImplicitFile) && InFact(Flags.UncPath) && _syntax == UriParser.FileUri)
2223_flags |= (Flags)idx;
2239private unsafe void CreateUriInfo(Flags cF)
2254if ((cF & Flags.ImplicitFile) != 0)
2263if (StaticInFact(cF, Flags.UncPath))
2268int end = (int)(cF & Flags.IndexMask);
2285if ((cF & Flags.AuthorityFound) != 0)
2291if ((cF & (Flags.UncPath | Flags.DosPath)) != 0)
2295int end = (int)(cF & Flags.IndexMask);
2310if ((cF & Flags.HostTypeMask) == Flags.UnknownHostType
2311|| StaticInFact(cF, Flags.DosPath)
2315info.Offset.User = (int)(cF & Flags.IndexMask);
2318cF &= ~Flags.IndexMask;
2321cF |= Flags.SchemeNotCanonical;
2329if (HostType == Flags.BasicHostType)
2332info.Offset.Path = (int)(cF & Flags.IndexMask);
2333cF &= ~Flags.IndexMask;
2337if ((cF & Flags.HasUserInfo) != 0)
2353idx = (int)(cF & Flags.IndexMask);
2357cF &= ~Flags.IndexMask;
2362cF |= Flags.SchemeNotCanonical;
2375if ((cF & Flags.HasUnicode) != 0)
2395cF |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2411cF |= Flags.NotDefaultPort;
2417cF |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2425cF |= Flags.MinimalUriInfoSet;
2429Flags current = _flags;
2430while ((current & Flags.MinimalUriInfoSet) == 0)
2432Flags oldValue = Interlocked.CompareExchange(ref _flags, (current & ~Flags.IndexMask) | cF, current);
2437current = (Flags)oldValue;
2453if (NotAny(Flags.ErrorOrParsingRecursion))
2455_flags |= Flags.ErrorOrParsingRecursion;
2458_flags &= ~Flags.ErrorOrParsingRecursion;
2464Flags flags = _flags;
2471if (HostType == Flags.BasicHostType)
2484if (NotAny(Flags.ImplicitFile) || (result & Check.ReservedFound) != 0)
2486flags |= Flags.HostNotCanonical;
2490if (InFact(Flags.ImplicitFile) && (result & (Check.ReservedFound | Check.EscapedCanonical)) != 0)
2499flags |= Flags.E_HostNotCanonical;
2500if (NotAny(Flags.UserEscaped))
2510else if (NotAny(Flags.CanonicalDnsHost))
2516flags |= (Flags.HostNotCanonical | Flags.E_HostNotCanonical);
2525flags |= (Flags.HostNotCanonical | Flags.E_HostNotCanonical);
2537private static string CreateHostStringHelper(string str, int idx, int end, ref Flags flags, UriInfo info)
2541switch (flags & Flags.HostTypeMask)
2543case Flags.DnsHostType:
2547case Flags.IPv6HostType:
2557case Flags.IPv4HostType:
2561case Flags.UncHostType:
2565case Flags.BasicHostType:
2566if (StaticInFact(flags, Flags.DosPath))
2583case Flags.UnknownHostType:
2594flags |= Flags.LoopbackHost;
2614Flags flags = _flags & ~Flags.HostTypeMask;
2623flags &= ~Flags.HostTypeMask;
2624flags |= Flags.UnknownHostType;
2628if (err != ParsingError.None || (flags & Flags.HostTypeMask) == Flags.UnknownHostType)
2631_flags = (_flags & ~Flags.HostTypeMask) | Flags.BasicHostType;
2641_flags |= (Flags.HostNotCanonical | Flags.E_HostNotCanonical);
2645_flags = (_flags & ~Flags.HostTypeMask) | (flags & Flags.HostTypeMask);
2656_flags &= ~Flags.NotDefaultPort;
2657_flags |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2671_flags &= ~Flags.NotDefaultPort;
2673_flags |= Flags.NotDefaultPort;
2675_flags |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2693Debug.Assert(_info != null && (_flags & Flags.MinimalUriInfoSet) != 0);
2698ushort nonCanonical = unchecked((ushort)(((ushort)_flags & ((ushort)Flags.CannotDisplayCanonical << 7)) >> 6));
2699if (InFact(Flags.SchemeNotCanonical))
2701nonCanonical |= (ushort)Flags.SchemeNotCanonical;
2707if (InFact(Flags.ShouldBeCompressed | Flags.FirstSlashAbsent | Flags.BackslashInPath))
2709nonCanonical |= (ushort)Flags.PathNotCanonical;
2714nonCanonical |= (ushort)Flags.PathNotCanonical;
2732Debug.Assert(_info != null && (_flags & Flags.MinimalUriInfoSet) != 0);
2737ushort nonCanonical = unchecked((ushort)((ushort)_flags & (ushort)Flags.CannotDisplayCanonical));
2742if ((_flags & (Flags.ShouldBeCompressed | Flags.FirstSlashAbsent | Flags.BackslashInPath)) != 0)
2744nonCanonical |= (ushort)Flags.PathNotCanonical;
2749nonCanonical |= (ushort)Flags.PathNotCanonical;
2802Debug.Assert(InFact(Flags.AllUriInfoSet));
2811if (InFact(Flags.AuthorityFound))
2820if ((parts & UriComponents.UserInfo) != 0 && InFact(Flags.HasUserInfo))
2829if (NotAny(Flags.UserEscaped))
2843InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape,
2892if (formatAs != UriFormat.UriEscaped && HostType == Flags.BasicHostType && (nonCanonical & (ushort)UriComponents.Host) != 0)
2903InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape,
2915if ((parts & UriComponents.SerializationInfoString) != 0 && HostType == Flags.IPv6HostType && _info._moreInfo?.ScopeId is string scopeId)
2926(InFact(Flags.NotDefaultPort) || ((parts & UriComponents.StrongPort) != 0 && _syntax.DefaultPort != UriParser.NoDefaultPort)))
2945if (InFact(Flags.AuthorityFound) && dest.Length != 0 && dest[0] == '/')
2990if (NotAny(Flags.UserEscaped))
3005UnescapeMode mode = InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape;
3032if (!InFact(Flags.HasUserInfo))
3042if (!InFact(Flags.HasUserInfo))
3045if (InFact(Flags.NotDefaultPort) || _syntax.DefaultPort == UriParser.NoDefaultPort)
3060if (InFact(Flags.HasUserInfo))
3093if (InFact(Flags.NotDefaultPort | Flags.PortNotCanonical))
3105if (uriParts == UriComponents.Path && InFact(Flags.AuthorityFound) &&
3146if (InFact(Flags.NotDefaultPort) || _syntax.DefaultPort == UriParser.NoDefaultPort)
3156if (InFact(Flags.HasUserInfo))
3173if (NotAny(Flags.HasUserInfo))
3214Flags cF = Flags.Zero;
3220bool buildIriStringFromPath = InFact(Flags.HasUnicode);
3236cF |= Flags.SchemeNotCanonical;
3245cF |= Flags.SchemeNotCanonical;
3249if (((_flags & Flags.AuthorityFound) != 0) && (idx + i + 3 >= length || str[idx + i + 1] != '/' ||
3252cF |= Flags.SchemeNotCanonical;
3258if ((_flags & Flags.HasUserInfo) != 0)
3264cF |= Flags.UserNotCanonical;
3268cF |= Flags.E_UserNotCanonical;
3274cF |= Flags.UserIriCanonical;
3421if (((_flags & Flags.AuthorityFound) != 0) && ((syntaxFlags & UriSyntaxFlags.PathIsRooted) != 0)
3424cF |= Flags.FirstSlashAbsent;
3431if (IsDosPath || (((_flags & Flags.AuthorityFound) != 0) &&
3437cF |= (Flags.E_PathNotCanonical | Flags.PathNotCanonical);
3443cF |= (Flags.E_PathNotCanonical | Flags.PathNotCanonical);
3447if (((syntaxFlags & (UriSyntaxFlags.CompressPath)) != 0) && ((cF & Flags.E_PathNotCanonical) != 0 ||
3450cF |= Flags.ShouldBeCompressed;
3454cF |= Flags.BackslashInPath;
3459cF |= Flags.E_PathNotCanonical;
3469if (((_flags & Flags.ImplicitFile) == 0) || ((_flags & Flags.UserEscaped) != 0) ||
3473cF |= Flags.PathNotCanonical;
3478if (((_flags & Flags.ImplicitFile) != 0) && (result & (Check.ReservedFound | Check.EscapedCanonical)) != 0)
3487cF |= Flags.E_PathNotCanonical;
3494cF |= Flags.PathIriCanonical;
3541cF |= Flags.QueryNotCanonical;
3546cF |= Flags.E_QueryNotCanonical;
3553cF |= Flags.QueryIriCanonical;
3589cF |= Flags.FragmentNotCanonical;
3594cF |= Flags.E_FragmentNotCanonical;
3601cF |= Flags.FragmentIriCanonical;
3608cF |= Flags.AllUriInfoSet;
3615private static int ParseSchemeCheckImplicitFile(string uriString, ref ParsingError err, ref Flags flags, ref UriParser? syntax)
3618Debug.Assert((flags & Flags.Debug_LeftConstructor) == 0);
3634flags |= (Flags.UnixPath | Flags.ImplicitFile | Flags.AuthorityFound);
3663flags |= (Flags.DosPath | Flags.ImplicitFile | Flags.AuthorityFound);
3680flags |= (Flags.UncPath | Flags.ImplicitFile | Flags.AuthorityFound);
3784ref ParsingError err, ref Flags flags, UriParser syntax, ref string? newHost)
3786Debug.Assert((_flags & Flags.Debug_LeftConstructor) == 0 || (!_syntax.IsSimple && Monitor.IsEntered(_info)));
3793bool hasUnicode = ((flags & Flags.HasUnicode) != 0);
3796Debug.Assert((_flags & Flags.HasUserInfo) == 0 && (_flags & Flags.HostTypeMask) == 0);
3809flags &= ~Flags.UncPath; //UNC cannot have an empty hostname
3810if (StaticInFact(flags, Flags.ImplicitFile))
3813flags |= Flags.BasicHostType;
3835flags |= Flags.HasUserInfo;
3858flags |= Flags.UnknownHostType;
3863flags |= Flags.IPv6HostType;
3871IPv4AddressHelper.IsValid(new ReadOnlySpan<char>(pString + start, end - start), out int endSeq, false, StaticNotAny(flags, Flags.ImplicitFile), syntax.InFact(UriSyntaxFlags.V1_UnknownUri)))
3874flags |= Flags.IPv4HostType;
3882DomainNameHelper.IsValid(new ReadOnlySpan<char>(pString + start, end - start), iri: false, StaticNotAny(flags, Flags.ImplicitFile), out int domainNameLength))
3889flags |= Flags.DnsHostType;
3894flags |= Flags.CanonicalDnsHost;
3899DomainNameHelper.IsValid(new ReadOnlySpan<char>(pString + start, end - start), iri: true, StaticNotAny(flags, Flags.ImplicitFile), out domainNameLength))
3911if (UncNameHelper.IsValid(pString, start, ref end, StaticNotAny(flags, Flags.ImplicitFile)))
3915flags |= Flags.UncHostType;
3926if (end < length && pString[end] == '\\' && (flags & Flags.HostTypeMask) != Flags.HostNotParsed
3932flags |= Flags.UnknownHostType;
3935flags &= ~Flags.HostTypeMask;
3964flags &= ~Flags.HostTypeMask;
3979flags &= ~Flags.HostTypeMask;
3995flags &= ~Flags.HostTypeMask;
4000if ((flags & Flags.HostTypeMask) == Flags.HostNotParsed)
4003flags &= ~Flags.HasUserInfo;
4008flags |= Flags.BasicHostType;
4054flags |= Flags.UnknownHostType;
4059flags |= Flags.BasicHostType;
4079flags |= Flags.UnknownHostType;
4088bool hasUnicode, ref Flags flags,
4093flags |= Flags.DnsHostType;
4249if ((_flags & Flags.HasUnicode) != 0)
4305if (InFact(Flags.FirstSlashAbsent))
4320if (InFact(Flags.ShouldBeCompressed))
4327if (_syntax.InFact(UriSyntaxFlags.UnEscapeDotsAndSlashes) && InFact(Flags.PathNotCanonical)
4336if (InFact(Flags.E_PathNotCanonical) && NotAny(Flags.UserEscaped))
4359if (!OperatingSystem.IsWindows() && InFact(Flags.BackslashInPath) && _syntax.NotAny(UriSyntaxFlags.ConvertPathSlashes) && _syntax.InFact(UriSyntaxFlags.FileLikeUri) && !IsImplicitFile)
4377if (InFact(Flags.ShouldBeCompressed))
4382if (_syntax.InFact(UriSyntaxFlags.UnEscapeDotsAndSlashes) && InFact(Flags.PathNotCanonical)
4402if (InFact(Flags.ShouldBeCompressed) && dest.Length - offset > 0)
4411if (formatAs == UriFormat.UriEscaped && NotAny(Flags.UserEscaped) && InFact(Flags.E_PathNotCanonical))
4428if (formatAs != UriFormat.UriEscaped && InFact(Flags.PathNotCanonical))
4445UnescapeMode mode = InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape;
4620if (basePart.HostType == Flags.IPv6HostType)
4694if (basePart.HostType == Flags.IPv6HostType)
5008return InFact(Flags.AuthorityFound);