405 references to Flags
System.Private.Uri (405)
System\Uri.cs (321)
57internal Flags _flags;
148_flags |= Flags.Debug_LeftConstructor;
156Debug.Assert(InFact(Flags.MinimalUriInfoSet) == (_info is not null));
170if (InFact(Flags.AllUriInfoSet))
182if (!InFact(Flags.HasUnicode))
203Debug.Assert((_flags & Flags.Debug_LeftConstructor) == 0);
254private void InterlockedSetFlags(Flags flags)
261Debug.Assert(sizeof(Flags) == sizeof(ulong));
277get { return (_flags & Flags.ImplicitFile) != 0; }
282get { return (_flags & (Flags.UncPath | Flags.DosPath)) != 0; }
287get { return (_flags & Flags.DosPath) != 0; }
292get { return (_flags & Flags.UncPath) != 0; }
297get { return (_flags & Flags.UnixPath) != 0; }
300private Flags HostType
302get { return _flags & Flags.HostTypeMask; }
328internal bool DisablePathAndQueryCanonicalization => (_flags & Flags.DisablePathAndQueryCanonicalization) != 0;
334return (_flags & Flags.UserDrivenParsing) != 0;
353private bool NotAny(Flags flags)
358private bool InFact(Flags flags)
363private static bool StaticNotAny(Flags allFlags, Flags checkFlags)
368private static bool StaticInFact(Flags allFlags, Flags checkFlags)
376Flags cF = _flags;
377if ((cF & Flags.MinimalUriInfoSet) == 0)
382Debug.Assert(_info != null && (_flags & Flags.MinimalUriInfoSet) != 0);
388if ((_flags & Flags.AllUriInfoSet) == 0)
402if (allowDnsOptimization && InFact(Flags.CanonicalDnsHost))
585_flags = Flags.Zero;
612dontEscape = InFact(Flags.UserEscaped);
632_flags = Flags.Zero;
839case Flags.DnsHostType: return UriHostNameType.Dns;
840case Flags.IPv4HostType: return UriHostNameType.IPv4;
841case Flags.IPv6HostType: return UriHostNameType.IPv6;
842case Flags.BasicHostType: return UriHostNameType.Basic;
843case Flags.UncHostType: return UriHostNameType.Basic;
844case Flags.UnknownHostType: return UriHostNameType.Unknown;
868return NotAny(Flags.NotDefaultPort);
896return InFact(Flags.LoopbackHost);
1019if (NotAny(Flags.HostNotCanonical | Flags.PathNotCanonical | Flags.ShouldBeCompressed))
1069if (InFact(Flags.PathNotCanonical) && !IsImplicitFile)
1082if (InFact(Flags.ShouldBeCompressed))
1122if (InFact(Flags.NotDefaultPort))
1201Flags hostType = HostType;
1202if (hostType == Flags.IPv6HostType || (hostType == Flags.BasicHostType && InFact(Flags.HostNotCanonical | Flags.E_HostNotCanonical)))
1229Flags hostType = HostType;
1230if (hostType == Flags.DnsHostType)
1234else if (hostType == Flags.IPv6HostType)
1243else if (hostType == Flags.BasicHostType && InFact(Flags.HostNotCanonical | Flags.E_HostNotCanonical))
1273return 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))
1934private static ParsingError ParseScheme(string uriString, ref Flags flags, ref UriParser? syntax)
1936Debug.Assert((flags & Flags.Debug_LeftConstructor) == 0);
1946flags |= (Flags)6;
1951flags |= (Flags)5;
1963flags |= (Flags)idx;
1977Debug.Assert((_flags & Flags.CustomParser_ParseMinimalAlreadyCalled) != 0);
1985_flags |= Flags.ErrorOrParsingRecursion;
2004int idx = (int)(_flags & Flags.IndexMask);
2007_flags &= ~(Flags.IndexMask | Flags.UserDrivenParsing);
2018if (!OperatingSystem.IsWindows() && InFact(Flags.UnixPath))
2020_flags |= Flags.BasicHostType;
2021_flags |= (Flags)idx;
2031NotAny(Flags.ImplicitFile) &&
2051_flags |= Flags.AuthorityFound;
2066_flags |= Flags.DosPath;
2071_flags |= Flags.AuthorityFound;
2091_flags |= Flags.UncPath;
2097_flags |= Flags.UnixPath | Flags.AuthorityFound;
2104if ((_flags & (Flags.UncPath | Flags.DosPath | Flags.UnixPath)) != 0)
2118_flags |= Flags.AuthorityFound;
2126else if (_syntax.InFact(UriSyntaxFlags.OptionalAuthority) && (InFact(Flags.AuthorityFound) ||
2129_flags |= Flags.AuthorityFound;
2137if (InFact(Flags.HasUnicode))
2142_flags |= ((Flags)idx | Flags.UnknownHostType);
2155if (InFact(Flags.HasUnicode))
2160_flags |= ((Flags)idx | Flags.UnknownHostType);
2167if (InFact(Flags.DosPath))
2169_flags |= (((_flags & Flags.AuthorityFound) != 0) ? Flags.BasicHostType : Flags.UnknownHostType);
2170_flags |= (Flags)idx;
2193if (hostTerminator == '\\' && NotAny(Flags.ImplicitFile) && _syntax.NotAny(UriSyntaxFlags.AllowDOSPath))
2198else if (!OperatingSystem.IsWindows() && hostTerminator == '/' && NotAny(Flags.ImplicitFile) && InFact(Flags.UncPath) && _syntax == UriParser.FileUri)
2211_flags |= (Flags)idx;
2226private void CreateUriInfo(Flags cF)
2249if ((cF & Flags.ImplicitFile) != 0)
2251if (StaticInFact(cF, Flags.UncPath))
2259int end = (int)(cF & Flags.IndexMask);
2272if ((cF & Flags.AuthorityFound) != 0)
2290if ((cF & (Flags.UncPath | Flags.DosPath)) != 0)
2294int end = (int)(cF & Flags.IndexMask);
2313if ((cF & Flags.HasUserInfo) != 0)
2328idx = (int)(cF & Flags.IndexMask);
2332cF &= ~Flags.IndexMask;
2336cF |= Flags.SchemeNotCanonical;
2340if ((cF & Flags.HostTypeMask) != Flags.UnknownHostType && (cF & Flags.DosPath) == 0 &&
2361cF |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2379cF |= Flags.NotDefaultPort;
2385cF |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2395cF |= Flags.MinimalUriInfoSet;
2399Flags current = _flags;
2400while ((current & Flags.MinimalUriInfoSet) == 0)
2402Flags oldValue = Interlocked.CompareExchange(ref _flags, (current & ~Flags.IndexMask) | cF, current);
2423if (NotAny(Flags.ErrorOrParsingRecursion))
2425_flags |= Flags.ErrorOrParsingRecursion;
2428_flags &= ~Flags.ErrorOrParsingRecursion;
2434Flags flags = _flags;
2441if (HostType == Flags.BasicHostType)
2449if (NotAny(Flags.ImplicitFile) || (result & Check.ReservedFound) != 0)
2451flags |= Flags.HostNotCanonical;
2455if (InFact(Flags.ImplicitFile) && (result & (Check.ReservedFound | Check.EscapedCanonical)) != 0)
2464flags |= Flags.E_HostNotCanonical;
2465if (NotAny(Flags.UserEscaped))
2475else if (NotAny(Flags.CanonicalDnsHost))
2481flags |= (Flags.HostNotCanonical | Flags.E_HostNotCanonical);
2490flags |= (Flags.HostNotCanonical | Flags.E_HostNotCanonical);
2502private static string CreateHostStringHelper(string str, int idx, int end, ref Flags flags, UriInfo info)
2506switch (flags & Flags.HostTypeMask)
2508case Flags.DnsHostType:
2512case Flags.IPv6HostType:
2522case Flags.IPv4HostType:
2526case Flags.UncHostType:
2530case Flags.BasicHostType:
2531if (StaticInFact(flags, Flags.DosPath))
2548case Flags.UnknownHostType:
2559flags |= Flags.LoopbackHost;
2578Flags flags = _flags & ~Flags.HostTypeMask;
2585_flags = (_flags & ~Flags.HostTypeMask) | Flags.BasicHostType;
2595_flags |= (Flags.HostNotCanonical | Flags.E_HostNotCanonical);
2599_flags = (_flags & ~Flags.HostTypeMask) | (flags & Flags.HostTypeMask);
2610_flags &= ~Flags.NotDefaultPort;
2611_flags |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2625_flags &= ~Flags.NotDefaultPort;
2627_flags |= Flags.NotDefaultPort;
2629_flags |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2647Debug.Assert(_info != null && (_flags & Flags.MinimalUriInfoSet) != 0);
2652ushort nonCanonical = unchecked((ushort)(((ushort)_flags & ((ushort)Flags.CannotDisplayCanonical << 7)) >> 6));
2653if (InFact(Flags.SchemeNotCanonical))
2655nonCanonical |= (ushort)Flags.SchemeNotCanonical;
2661if (InFact(Flags.ShouldBeCompressed | Flags.FirstSlashAbsent | Flags.BackslashInPath))
2663nonCanonical |= (ushort)Flags.PathNotCanonical;
2668nonCanonical |= (ushort)Flags.PathNotCanonical;
2686Debug.Assert(_info != null && (_flags & Flags.MinimalUriInfoSet) != 0);
2691ushort nonCanonical = unchecked((ushort)((ushort)_flags & (ushort)Flags.CannotDisplayCanonical));
2696if ((_flags & (Flags.ShouldBeCompressed | Flags.FirstSlashAbsent | Flags.BackslashInPath)) != 0)
2698nonCanonical |= (ushort)Flags.PathNotCanonical;
2703nonCanonical |= (ushort)Flags.PathNotCanonical;
2756Debug.Assert(InFact(Flags.AllUriInfoSet));
2765if (InFact(Flags.AuthorityFound))
2774if ((parts & UriComponents.UserInfo) != 0 && InFact(Flags.HasUserInfo))
2783if (NotAny(Flags.UserEscaped))
2797InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape,
2846if (formatAs != UriFormat.UriEscaped && HostType == Flags.BasicHostType && (nonCanonical & (ushort)UriComponents.Host) != 0)
2857InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape,
2869if ((parts & UriComponents.SerializationInfoString) != 0 && HostType == Flags.IPv6HostType && _info._moreInfo?.ScopeId is string scopeId)
2880(InFact(Flags.NotDefaultPort) || ((parts & UriComponents.StrongPort) != 0 && _syntax.DefaultPort != UriParser.NoDefaultPort)))
2899if (InFact(Flags.AuthorityFound) && dest.Length != 0 && dest[0] == '/')
2944if (NotAny(Flags.UserEscaped))
2959UnescapeMode mode = InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape;
2986if (!InFact(Flags.HasUserInfo))
2996if (!InFact(Flags.HasUserInfo))
2999if (InFact(Flags.NotDefaultPort) || _syntax.DefaultPort == UriParser.NoDefaultPort)
3014if (InFact(Flags.HasUserInfo))
3047if (InFact(Flags.NotDefaultPort | Flags.PortNotCanonical))
3059if (uriParts == UriComponents.Path && InFact(Flags.AuthorityFound) &&
3100if (InFact(Flags.NotDefaultPort) || _syntax.DefaultPort == UriParser.NoDefaultPort)
3110if (InFact(Flags.HasUserInfo))
3127if (NotAny(Flags.HasUserInfo))
3159Flags cF = _flags | Flags.AllUriInfoSet;
3161if ((cF & Flags.UserDrivenParsing) != 0)
3167if ((cF & Flags.HasUnicode) != 0)
3182if ((cF & Flags.ImplicitFile) != 0)
3184cF |= Flags.SchemeNotCanonical;
3201cF |= Flags.SchemeNotCanonical;
3208if ((cF & Flags.AuthorityFound) != 0 && !str.Slice(schemeLength).StartsWith("://", StringComparison.Ordinal))
3210cF |= Flags.SchemeNotCanonical | Flags.SchemeNotCanonical_NoTrailingSlashes;
3218if ((cF & Flags.HasUserInfo) != 0)
3225cF |= Flags.UserNotCanonical;
3229cF |= Flags.E_UserNotCanonical;
3235cF |= Flags.UserIriCanonical;
3248if ((cF & Flags.DisablePathAndQueryCanonicalization) != 0)
3251if ((cF & Flags.ImplicitFile) != 0 || (syntaxFlags & UriSyntaxFlags.MayHaveQuery) == 0)
3278(cF & Flags.ImplicitFile) != 0 || (syntaxFlags & (UriSyntaxFlags.MayHaveQuery | UriSyntaxFlags.MayHaveFragment)) == 0 ? c_DummyChar :
3294if (((cF & Flags.AuthorityFound) != 0) && ((syntaxFlags & UriSyntaxFlags.PathIsRooted) != 0)
3297cF |= Flags.FirstSlashAbsent;
3304if ((cF & Flags.DosPath) != 0 || (((cF & Flags.AuthorityFound) != 0) &&
3310cF |= (Flags.E_PathNotCanonical | Flags.PathNotCanonical);
3316cF |= (Flags.E_PathNotCanonical | Flags.PathNotCanonical);
3320if (((syntaxFlags & (UriSyntaxFlags.CompressPath)) != 0) && ((cF & Flags.E_PathNotCanonical) != 0 ||
3323cF |= Flags.ShouldBeCompressed;
3327cF |= Flags.BackslashInPath;
3332cF |= Flags.E_PathNotCanonical;
3342if (((cF & Flags.ImplicitFile) == 0) || ((cF & Flags.UserEscaped) != 0) ||
3346cF |= Flags.PathNotCanonical;
3351if (((cF & Flags.ImplicitFile) != 0) && (result & (Check.ReservedFound | Check.EscapedCanonical)) != 0)
3360cF |= Flags.E_PathNotCanonical;
3367cF |= Flags.PathIriCanonical;
3382cF |= Flags.QueryNotCanonical;
3387cF |= Flags.E_QueryNotCanonical;
3394cF |= Flags.QueryIriCanonical;
3410cF |= Flags.FragmentNotCanonical;
3415cF |= Flags.E_FragmentNotCanonical;
3422cF |= Flags.FragmentIriCanonical;
3436Debug.Assert(InFact(Flags.HasUnicode));
3437Debug.Assert(InFact(Flags.MinimalUriInfoSet));
3438Debug.Assert(!InFact(Flags.UserDrivenParsing));
3442Flags flags = _flags;
3447if ((flags & (Flags.DosPath | Flags.UnixPath)) != 0)
3449if ((flags & Flags.ImplicitFile) == 0)
3453if ((flags & Flags.AuthorityFound) != 0)
3476if ((flags & Flags.DisablePathAndQueryCanonicalization) != 0)
3489int pathLength = (flags & Flags.ImplicitFile) != 0 || (syntaxFlags & UriSyntaxFlags.MayHaveQuery) == 0
3526private static int ParseSchemeCheckImplicitFile(string uriString, ref ParsingError err, ref Flags flags, ref UriParser? syntax)
3529Debug.Assert((flags & Flags.Debug_LeftConstructor) == 0);
3545flags |= (Flags.UnixPath | Flags.ImplicitFile | Flags.AuthorityFound);
3574flags |= (Flags.DosPath | Flags.ImplicitFile | Flags.AuthorityFound);
3591flags |= (Flags.UncPath | Flags.ImplicitFile | Flags.AuthorityFound);
3693private int CheckAuthorityHelper(ReadOnlySpan<char> str, int startOffset, out ParsingError err, ref Flags flags, UriSyntaxFlags syntaxFlags, ref string? newHost)
3695Debug.Assert((_flags & Flags.Debug_LeftConstructor) == 0 || (!_syntax.IsSimple && Monitor.IsEntered(_info)));
3696Debug.Assert((_flags & Flags.HasUserInfo) == 0 && (_flags & Flags.HostTypeMask) == 0);
3701bool hasUnicode = ((flags & Flags.HasUnicode) != 0);
3716flags &= ~Flags.UncPath; //UNC cannot have an empty hostname
3717if (StaticInFact(flags, Flags.ImplicitFile))
3720flags |= Flags.BasicHostType;
3746flags |= Flags.HasUserInfo;
3780flags |= Flags.IPv6HostType;
3788IPv4AddressHelper.IsValid(str.Slice(i), out hostLength, allowIPv6: false, StaticNotAny(flags, Flags.ImplicitFile), (syntaxFlags & UriSyntaxFlags.V1_UnknownUri) != 0))
3790flags |= Flags.IPv4HostType;
3798DomainNameHelper.IsValid(str.Slice(i), iri: false, StaticNotAny(flags, Flags.ImplicitFile), out hostLength))
3803flags |= Flags.DnsHostType;
3808flags |= Flags.CanonicalDnsHost;
3813DomainNameHelper.IsValid(str.Slice(i), iri: true, StaticNotAny(flags, Flags.ImplicitFile), out hostLength))
3815flags |= Flags.DnsHostType;
3839if (UncNameHelper.IsValid(str.Slice(i), StaticNotAny(flags, Flags.ImplicitFile), out hostLength))
3843flags |= Flags.UncHostType;
3857if (hostDelimiter == '\\' && (flags & Flags.HostTypeMask) != Flags.HostNotParsed && (syntaxFlags & UriSyntaxFlags.FileLikeUri) == 0)
3865flags &= ~Flags.HostTypeMask;
3894flags &= ~Flags.HostTypeMask;
3910flags &= ~Flags.HostTypeMask;
3926flags &= ~Flags.HostTypeMask;
3931if ((flags & Flags.HostTypeMask) == Flags.HostNotParsed)
3934flags &= ~Flags.HasUserInfo;
3939flags |= Flags.BasicHostType;
3988flags |= Flags.BasicHostType;
4155if ((_flags & Flags.HasUnicode) != 0)
4206if (InFact(Flags.FirstSlashAbsent))
4221if (InFact(Flags.ShouldBeCompressed))
4228if (_syntax.InFact(UriSyntaxFlags.UnEscapeDotsAndSlashes) && InFact(Flags.PathNotCanonical)
4237if (InFact(Flags.E_PathNotCanonical) && NotAny(Flags.UserEscaped))
4260if (!OperatingSystem.IsWindows() && InFact(Flags.BackslashInPath) && _syntax.NotAny(UriSyntaxFlags.ConvertPathSlashes) && _syntax.InFact(UriSyntaxFlags.FileLikeUri) && !IsImplicitFile)
4278if (InFact(Flags.ShouldBeCompressed))
4283if (_syntax.InFact(UriSyntaxFlags.UnEscapeDotsAndSlashes) && InFact(Flags.PathNotCanonical)
4303if (InFact(Flags.ShouldBeCompressed) && dest.Length - offset > 0)
4314if (formatAs == UriFormat.UriEscaped && NotAny(Flags.UserEscaped) && InFact(Flags.E_PathNotCanonical))
4331if (formatAs != UriFormat.UriEscaped && InFact(Flags.PathNotCanonical))
4348UnescapeMode mode = InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape;
4523if (basePart.HostType == Flags.IPv6HostType)
4597if (basePart.HostType == Flags.IPv6HostType)
4911return InFact(Flags.AuthorityFound);