412 references to Flags
System.Private.Uri (412)
System\Uri.cs (323)
57internal Flags _flags;
142_flags |= Flags.Debug_LeftConstructor;
148Debug.Assert((_flags & Flags.Debug_LeftConstructor) == 0);
200private void InterlockedSetFlags(Flags flags)
207Debug.Assert(sizeof(Flags) == sizeof(ulong));
208Interlocked.Or(ref Unsafe.As<Flags, ulong>(ref _flags), (ulong)flags);
223get { return (_flags & Flags.ImplicitFile) != 0; }
228get { return (_flags & (Flags.UncPath | Flags.DosPath)) != 0; }
233get { return (_flags & Flags.DosPath) != 0; }
238get { return (_flags & Flags.UncPath) != 0; }
243get { return (_flags & Flags.UnixPath) != 0; }
246private Flags HostType
248get { return _flags & Flags.HostTypeMask; }
274internal bool DisablePathAndQueryCanonicalization => (_flags & Flags.DisablePathAndQueryCanonicalization) != 0;
280return (_flags & Flags.UserDrivenParsing) != 0;
299private bool NotAny(Flags flags)
304private bool InFact(Flags flags)
309private static bool StaticNotAny(Flags allFlags, Flags checkFlags)
314private static bool StaticInFact(Flags allFlags, Flags checkFlags)
322Flags cF = _flags;
323if ((cF & Flags.MinimalUriInfoSet) == 0)
327Debug.Assert(_info != null && (_flags & Flags.MinimalUriInfoSet) != 0);
333if ((_flags & Flags.AllUriInfoSet) == 0)
346if (allowDnsOptimization && InFact(Flags.CanonicalDnsHost))
529_flags = Flags.Zero;
555dontEscape = InFact(Flags.UserEscaped);
575_flags = Flags.Zero;
793case Flags.DnsHostType: return UriHostNameType.Dns;
794case Flags.IPv4HostType: return UriHostNameType.IPv4;
795case Flags.IPv6HostType: return UriHostNameType.IPv6;
796case Flags.BasicHostType: return UriHostNameType.Basic;
797case Flags.UncHostType: return UriHostNameType.Basic;
798case Flags.UnknownHostType: return UriHostNameType.Unknown;
822return NotAny(Flags.NotDefaultPort);
850return InFact(Flags.LoopbackHost);
970if (NotAny(Flags.HostNotCanonical | Flags.PathNotCanonical | Flags.ShouldBeCompressed))
1024UnescapeMode mode = (InFact(Flags.PathNotCanonical) && !IsImplicitFile)
1033if (InFact(Flags.ShouldBeCompressed))
1073if (InFact(Flags.NotDefaultPort))
1152Flags hostType = HostType;
1153if (hostType == Flags.IPv6HostType || (hostType == Flags.BasicHostType && InFact(Flags.HostNotCanonical | Flags.E_HostNotCanonical)))
1180Flags hostType = HostType;
1181if (hostType == Flags.DnsHostType)
1185else if (hostType == Flags.IPv6HostType)
1194else if (hostType == Flags.BasicHostType && InFact(Flags.HostNotCanonical | Flags.E_HostNotCanonical))
1232return InFact(Flags.UserEscaped);
1350if (NotAny(Flags.AuthorityFound) || IsDosPath)
1614ushort nonCanonical = (ushort)((ushort)_flags & (ushort)Flags.CannotDisplayCanonical);
1615if (((_flags & (Flags.ShouldBeCompressed | Flags.FirstSlashAbsent | Flags.BackslashInPath)) != 0) ||
1618nonCanonical |= (ushort)Flags.PathNotCanonical;
1744if (NotAny(Flags.AllUriInfoSet) || other.NotAny(Flags.AllUriInfoSet))
1762if (InFact(Flags.CanonicalDnsHost) && other.InFact(Flags.CanonicalDnsHost))
1906private static unsafe ParsingError ParseScheme(string uriString, ref Flags flags, ref UriParser? syntax)
1908Debug.Assert((flags & Flags.Debug_LeftConstructor) == 0);
1921flags |= (Flags)6;
1926flags |= (Flags)5;
1938flags |= (Flags)idx;
1952Debug.Assert((_flags & Flags.CustomParser_ParseMinimalAlreadyCalled) != 0);
1960_flags |= Flags.ErrorOrParsingRecursion;
1981int idx = (int)(_flags & Flags.IndexMask);
1985_flags &= ~(Flags.IndexMask | Flags.UserDrivenParsing);
2003if (!OperatingSystem.IsWindows() && InFact(Flags.UnixPath))
2005_flags |= Flags.BasicHostType;
2006_flags |= (Flags)idx;
2017&& NotAny(Flags.ImplicitFile) && (idx + 1 < length))
2035_flags |= Flags.AuthorityFound;
2050_flags |= Flags.DosPath;
2055_flags |= Flags.AuthorityFound;
2074_flags |= Flags.UncPath;
2080_flags |= Flags.UnixPath | Flags.AuthorityFound;
2088if ((_flags & (Flags.UncPath | Flags.DosPath | Flags.UnixPath)) != 0)
2101_flags |= Flags.AuthorityFound;
2109else if (_syntax.InFact(UriSyntaxFlags.OptionalAuthority) && (InFact(Flags.AuthorityFound) ||
2112_flags |= Flags.AuthorityFound;
2120if (InFact(Flags.HasUnicode))
2125_flags |= ((Flags)idx | Flags.UnknownHostType);
2138if (InFact(Flags.HasUnicode))
2143_flags |= ((Flags)idx | Flags.UnknownHostType);
2150if (InFact(Flags.DosPath))
2152_flags |= (((_flags & Flags.AuthorityFound) != 0) ? Flags.BasicHostType : Flags.UnknownHostType);
2153_flags |= (Flags)idx;
2177if (hostTerminator == '\\' && NotAny(Flags.ImplicitFile) && _syntax.NotAny(UriSyntaxFlags.AllowDOSPath))
2182else if (!OperatingSystem.IsWindows() && hostTerminator == '/' && NotAny(Flags.ImplicitFile) && InFact(Flags.UncPath) && _syntax == UriParser.FileUri)
2195_flags |= (Flags)idx;
2211private unsafe void CreateUriInfo(Flags cF)
2226if ((cF & Flags.ImplicitFile) != 0)
2235if (StaticInFact(cF, Flags.UncPath))
2240int end = (int)(cF & Flags.IndexMask);
2257if ((cF & Flags.AuthorityFound) != 0)
2263if ((cF & (Flags.UncPath | Flags.DosPath)) != 0)
2267int end = (int)(cF & Flags.IndexMask);
2282if ((cF & Flags.HostTypeMask) == Flags.UnknownHostType
2283|| StaticInFact(cF, Flags.DosPath)
2287info.Offset.User = (ushort)(cF & Flags.IndexMask);
2290cF &= ~Flags.IndexMask;
2293cF |= Flags.SchemeNotCanonical;
2301if (HostType == Flags.BasicHostType)
2304info.Offset.Path = (ushort)(cF & Flags.IndexMask);
2305cF &= ~Flags.IndexMask;
2309if ((cF & Flags.HasUserInfo) != 0)
2326idx = (int)(cF & Flags.IndexMask);
2330cF &= ~Flags.IndexMask;
2335cF |= Flags.SchemeNotCanonical;
2348if ((cF & Flags.HasUnicode) != 0)
2368cF |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2384cF |= Flags.NotDefaultPort;
2390cF |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2398cF |= Flags.MinimalUriInfoSet;
2402Flags current = _flags;
2403while ((current & Flags.MinimalUriInfoSet) == 0)
2405Flags oldValue = Interlocked.CompareExchange(ref _flags, (current & ~Flags.IndexMask) | cF, current);
2410current = (Flags)oldValue;
2426if (NotAny(Flags.ErrorOrParsingRecursion))
2428_flags |= Flags.ErrorOrParsingRecursion;
2431_flags &= ~Flags.ErrorOrParsingRecursion;
2436Flags flags = _flags;
2443if (HostType == Flags.BasicHostType)
2456if (NotAny(Flags.ImplicitFile) || (result & Check.ReservedFound) != 0)
2458flags |= Flags.HostNotCanonical;
2462if (InFact(Flags.ImplicitFile) && (result & (Check.ReservedFound | Check.EscapedCanonical)) != 0)
2471flags |= Flags.E_HostNotCanonical;
2472if (NotAny(Flags.UserEscaped))
2482else if (NotAny(Flags.CanonicalDnsHost))
2488flags |= (Flags.HostNotCanonical | Flags.E_HostNotCanonical);
2497flags |= (Flags.HostNotCanonical | Flags.E_HostNotCanonical);
2509private static string CreateHostStringHelper(string str, int idx, int end, ref Flags flags, ref string? scopeId)
2513switch (flags & Flags.HostTypeMask)
2515case Flags.DnsHostType:
2519case Flags.IPv6HostType:
2525case Flags.IPv4HostType:
2529case Flags.UncHostType:
2533case Flags.BasicHostType:
2534if (StaticInFact(flags, Flags.DosPath))
2551case Flags.UnknownHostType:
2562flags |= Flags.LoopbackHost;
2585Flags flags = _flags & ~Flags.HostTypeMask;
2594flags &= ~Flags.HostTypeMask;
2595flags |= Flags.UnknownHostType;
2599if (err != ParsingError.None || (flags & Flags.HostTypeMask) == Flags.UnknownHostType)
2602_flags = (_flags & ~Flags.HostTypeMask) | Flags.BasicHostType;
2611_flags |= (Flags.HostNotCanonical | Flags.E_HostNotCanonical);
2615_flags = (_flags & ~Flags.HostTypeMask) | (flags & Flags.HostTypeMask);
2626_flags &= ~Flags.NotDefaultPort;
2627_flags |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2641_flags &= ~Flags.NotDefaultPort;
2643_flags |= Flags.NotDefaultPort;
2645_flags |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2663Debug.Assert(_info != null && (_flags & Flags.MinimalUriInfoSet) != 0);
2668ushort nonCanonical = unchecked((ushort)(((ushort)_flags & ((ushort)Flags.CannotDisplayCanonical << 7)) >> 6));
2669if (InFact(Flags.SchemeNotCanonical))
2671nonCanonical |= (ushort)Flags.SchemeNotCanonical;
2677if (InFact(Flags.ShouldBeCompressed | Flags.FirstSlashAbsent | Flags.BackslashInPath))
2679nonCanonical |= (ushort)Flags.PathNotCanonical;
2684nonCanonical |= (ushort)Flags.PathNotCanonical;
2702Debug.Assert(_info != null && (_flags & Flags.MinimalUriInfoSet) != 0);
2707ushort nonCanonical = unchecked((ushort)((ushort)_flags & (ushort)Flags.CannotDisplayCanonical));
2712if ((_flags & (Flags.ShouldBeCompressed | Flags.FirstSlashAbsent | Flags.BackslashInPath)) != 0)
2714nonCanonical |= (ushort)Flags.PathNotCanonical;
2719nonCanonical |= (ushort)Flags.PathNotCanonical;
2779if (InFact(Flags.AuthorityFound))
2788if ((parts & UriComponents.UserInfo) != 0 && InFact(Flags.HasUserInfo))
2797if (NotAny(Flags.UserEscaped))
2811InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape,
2848if (formatAs != UriFormat.UriEscaped && HostType == Flags.BasicHostType
2854(InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape);
2883if ((parts & UriComponents.SerializationInfoString) != 0 && HostType == Flags.IPv6HostType && _info.ScopeId != null)
2894(InFact(Flags.NotDefaultPort) || ((parts & UriComponents.StrongPort) != 0 && _syntax.DefaultPort != UriParser.NoDefaultPort)))
2913if (InFact(Flags.AuthorityFound) && dest.Length != 0 && dest[0] == '/')
2939if (NotAny(Flags.UserEscaped))
2952V1ToStringUnescape => (InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape) | UnescapeMode.V1ToStringFlag,
2954_ => InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape
2978if (NotAny(Flags.UserEscaped))
2991V1ToStringUnescape => (InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape) | UnescapeMode.V1ToStringFlag,
2993_ => InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape
3019if (!InFact(Flags.HasUserInfo))
3029if (!InFact(Flags.HasUserInfo))
3032if (InFact(Flags.NotDefaultPort) || _syntax.DefaultPort == UriParser.NoDefaultPort)
3047if (InFact(Flags.HasUserInfo))
3080if (InFact(Flags.NotDefaultPort | Flags.PortNotCanonical))
3092if (uriParts == UriComponents.Path && InFact(Flags.AuthorityFound) &&
3133if (InFact(Flags.NotDefaultPort) || _syntax.DefaultPort == UriParser.NoDefaultPort)
3143if (InFact(Flags.HasUserInfo))
3160if (NotAny(Flags.HasUserInfo))
3201Flags cF = Flags.Zero;
3207bool buildIriStringFromPath = InFact(Flags.HasUnicode);
3223cF |= Flags.SchemeNotCanonical;
3232cF |= Flags.SchemeNotCanonical;
3236if (((_flags & Flags.AuthorityFound) != 0) && (idx + i + 3 >= length || str[idx + i + 1] != '/' ||
3239cF |= Flags.SchemeNotCanonical;
3245if ((_flags & Flags.HasUserInfo) != 0)
3251cF |= Flags.UserNotCanonical;
3255cF |= Flags.E_UserNotCanonical;
3261cF |= Flags.UserIriCanonical;
3410if (((_flags & Flags.AuthorityFound) != 0) && ((syntaxFlags & UriSyntaxFlags.PathIsRooted) != 0)
3413cF |= Flags.FirstSlashAbsent;
3420if (IsDosPath || (((_flags & Flags.AuthorityFound) != 0) &&
3426cF |= (Flags.E_PathNotCanonical | Flags.PathNotCanonical);
3432cF |= (Flags.E_PathNotCanonical | Flags.PathNotCanonical);
3436if (((syntaxFlags & (UriSyntaxFlags.CompressPath)) != 0) && ((cF & Flags.E_PathNotCanonical) != 0 ||
3439cF |= Flags.ShouldBeCompressed;
3443cF |= Flags.BackslashInPath;
3448cF |= Flags.E_PathNotCanonical;
3458if (((_flags & Flags.ImplicitFile) == 0) || ((_flags & Flags.UserEscaped) != 0) ||
3462cF |= Flags.PathNotCanonical;
3467if (((_flags & Flags.ImplicitFile) != 0) && (result & (Check.ReservedFound | Check.EscapedCanonical)) != 0)
3476cF |= Flags.E_PathNotCanonical;
3483cF |= Flags.PathIriCanonical;
3536cF |= Flags.QueryNotCanonical;
3541cF |= Flags.E_QueryNotCanonical;
3548cF |= Flags.QueryIriCanonical;
3590cF |= Flags.FragmentNotCanonical;
3595cF |= Flags.E_FragmentNotCanonical;
3602cF |= Flags.FragmentIriCanonical;
3609cF |= Flags.AllUriInfoSet;
3616private static int ParseSchemeCheckImplicitFile(string uriString, ref ParsingError err, ref Flags flags, ref UriParser? syntax)
3619Debug.Assert((flags & Flags.Debug_LeftConstructor) == 0);
3635flags |= (Flags.UnixPath | Flags.ImplicitFile | Flags.AuthorityFound);
3664flags |= (Flags.DosPath | Flags.ImplicitFile | Flags.AuthorityFound);
3681flags |= (Flags.UncPath | Flags.ImplicitFile | Flags.AuthorityFound);
3785ref ParsingError err, ref Flags flags, UriParser syntax, ref string? newHost)
3787Debug.Assert((_flags & Flags.Debug_LeftConstructor) == 0 || (!_syntax.IsSimple && Monitor.IsEntered(_info)));
3794bool hasUnicode = ((flags & Flags.HasUnicode) != 0);
3797Debug.Assert((_flags & Flags.HasUserInfo) == 0 && (_flags & Flags.HostTypeMask) == 0);
3810flags &= ~Flags.UncPath; //UNC cannot have an empty hostname
3811if (StaticInFact(flags, Flags.ImplicitFile))
3814flags |= Flags.BasicHostType;
3836flags |= Flags.HasUserInfo;
3860flags |= Flags.IPv6HostType;
3868IPv4AddressHelper.IsValid(pString, start, ref end, false, StaticNotAny(flags, Flags.ImplicitFile), syntax.InFact(UriSyntaxFlags.V1_UnknownUri)))
3870flags |= Flags.IPv4HostType;
3878DomainNameHelper.IsValid(new ReadOnlySpan<char>(pString + start, end - start), iri: false, StaticNotAny(flags, Flags.ImplicitFile), out int domainNameLength))
3883flags |= Flags.DnsHostType;
3888flags |= Flags.CanonicalDnsHost;
3893DomainNameHelper.IsValid(new ReadOnlySpan<char>(pString + start, end - start), iri: true, StaticNotAny(flags, Flags.ImplicitFile), out domainNameLength))
3905if (UncNameHelper.IsValid(pString, start, ref end, StaticNotAny(flags, Flags.ImplicitFile)))
3909flags |= Flags.UncHostType;
3920if (end < length && pString[end] == '\\' && (flags & Flags.HostTypeMask) != Flags.HostNotParsed
3926flags |= Flags.UnknownHostType;
3929flags &= ~Flags.HostTypeMask;
3958flags &= ~Flags.HostTypeMask;
3973flags &= ~Flags.HostTypeMask;
3989flags &= ~Flags.HostTypeMask;
3994if ((flags & Flags.HostTypeMask) == Flags.HostNotParsed)
3997flags &= ~Flags.HasUserInfo;
4002flags |= Flags.BasicHostType;
4050flags |= Flags.UnknownHostType;
4055flags |= Flags.BasicHostType;
4076flags |= Flags.UnknownHostType;
4085bool hasUnicode, ref Flags flags,
4090flags |= Flags.DnsHostType;
4240if ((_flags & Flags.HasUnicode) != 0)
4296if (InFact(Flags.FirstSlashAbsent))
4311if (InFact(Flags.ShouldBeCompressed))
4318if (_syntax.InFact(UriSyntaxFlags.UnEscapeDotsAndSlashes) && InFact(Flags.PathNotCanonical)
4333if (InFact(Flags.E_PathNotCanonical) && NotAny(Flags.UserEscaped))
4356if (!OperatingSystem.IsWindows() && InFact(Flags.BackslashInPath) && _syntax.NotAny(UriSyntaxFlags.ConvertPathSlashes) && _syntax.InFact(UriSyntaxFlags.FileLikeUri) && !IsImplicitFile)
4374if (InFact(Flags.ShouldBeCompressed))
4379if (_syntax.InFact(UriSyntaxFlags.UnEscapeDotsAndSlashes) && InFact(Flags.PathNotCanonical)
4405if (InFact(Flags.ShouldBeCompressed) && dest.Length - offset > 0)
4413if (formatAs == UriFormat.UriEscaped && NotAny(Flags.UserEscaped) && InFact(Flags.E_PathNotCanonical))
4430if (formatAs != UriFormat.UriEscaped && InFact(Flags.PathNotCanonical))
4437mode = (InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape)
4450mode = InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape;
4771if (basePart.HostType == Flags.IPv6HostType)
4845if (basePart.HostType == Flags.IPv6HostType)
5163return InFact(Flags.AuthorityFound);