397 references to Flags
System.Private.Uri (397)
System\Uri.cs (321)
57internal Flags _flags;
150_flags |= Flags.Debug_LeftConstructor;
158Debug.Assert(InFact(Flags.MinimalUriInfoSet) == (_info is not null));
172if (InFact(Flags.AllUriInfoSet))
184if (!InFact(Flags.HasUnicode))
205Debug.Assert((_flags & Flags.Debug_LeftConstructor) == 0);
256private void InterlockedSetFlags(Flags flags)
263Debug.Assert(sizeof(Flags) == sizeof(ulong));
279get { return (_flags & Flags.ImplicitFile) != 0; }
284get { return (_flags & (Flags.UncPath | Flags.DosPath)) != 0; }
289get { return (_flags & Flags.DosPath) != 0; }
294get { return (_flags & Flags.UncPath) != 0; }
299get { return (_flags & Flags.UnixPath) != 0; }
302private Flags HostType
304get { return _flags & Flags.HostTypeMask; }
330internal bool DisablePathAndQueryCanonicalization => (_flags & Flags.DisablePathAndQueryCanonicalization) != 0;
336return (_flags & Flags.UserDrivenParsing) != 0;
355private bool NotAny(Flags flags)
360private bool InFact(Flags flags)
365private static bool StaticNotAny(Flags allFlags, Flags checkFlags)
370private static bool StaticInFact(Flags allFlags, Flags checkFlags)
378Flags cF = _flags;
379if ((cF & Flags.MinimalUriInfoSet) == 0)
384Debug.Assert(_info != null && (_flags & Flags.MinimalUriInfoSet) != 0);
390if ((_flags & Flags.AllUriInfoSet) == 0)
404if (allowDnsOptimization && InFact(Flags.CanonicalDnsHost))
579_flags = Flags.Zero;
606dontEscape = InFact(Flags.UserEscaped);
625_flags = Flags.Zero;
820case Flags.DnsHostType: return UriHostNameType.Dns;
821case Flags.IPv4HostType: return UriHostNameType.IPv4;
822case Flags.IPv6HostType: return UriHostNameType.IPv6;
823case Flags.BasicHostType: return UriHostNameType.Basic;
824case Flags.UncHostType: return UriHostNameType.Basic;
825case Flags.UnknownHostType: return UriHostNameType.Unknown;
849return NotAny(Flags.NotDefaultPort);
877return InFact(Flags.LoopbackHost);
1000if (NotAny(Flags.HostNotCanonical | Flags.PathNotCanonical | Flags.ShouldBeCompressed))
1050if (InFact(Flags.PathNotCanonical) && !IsImplicitFile)
1063if (InFact(Flags.ShouldBeCompressed))
1103if (InFact(Flags.NotDefaultPort))
1182Flags hostType = HostType;
1183if (hostType == Flags.IPv6HostType || (hostType == Flags.BasicHostType && InFact(Flags.HostNotCanonical | Flags.E_HostNotCanonical)))
1210Flags hostType = HostType;
1211if (hostType == Flags.DnsHostType)
1215else if (hostType == Flags.IPv6HostType)
1224else if (hostType == Flags.BasicHostType && InFact(Flags.HostNotCanonical | Flags.E_HostNotCanonical))
1254return InFact(Flags.UserEscaped);
1361if (NotAny(Flags.AuthorityFound) || IsDosPath)
1625ushort nonCanonical = (ushort)((ushort)_flags & (ushort)Flags.CannotDisplayCanonical);
1626if (((_flags & (Flags.ShouldBeCompressed | Flags.FirstSlashAbsent | Flags.BackslashInPath)) != 0) ||
1629nonCanonical |= (ushort)Flags.PathNotCanonical;
1755if (NotAny(Flags.AllUriInfoSet) || other.NotAny(Flags.AllUriInfoSet))
1773if (InFact(Flags.CanonicalDnsHost) && other.InFact(Flags.CanonicalDnsHost))
1915private static ParsingError ParseScheme(string uriString, ref Flags flags, ref UriParser? syntax)
1917Debug.Assert((flags & Flags.Debug_LeftConstructor) == 0);
1927flags |= (Flags)6;
1932flags |= (Flags)5;
1944flags |= (Flags)idx;
1958Debug.Assert((_flags & Flags.CustomParser_ParseMinimalAlreadyCalled) != 0);
1966_flags |= Flags.ErrorOrParsingRecursion;
1985int idx = (int)(_flags & Flags.IndexMask);
1988_flags &= ~(Flags.IndexMask | Flags.UserDrivenParsing);
1999if (!OperatingSystem.IsWindows() && InFact(Flags.UnixPath))
2001_flags |= Flags.BasicHostType;
2002_flags |= (Flags)idx;
2012NotAny(Flags.ImplicitFile) &&
2032_flags |= Flags.AuthorityFound;
2047_flags |= Flags.DosPath;
2052_flags |= Flags.AuthorityFound;
2072_flags |= Flags.UncPath;
2078_flags |= Flags.UnixPath | Flags.AuthorityFound;
2085if ((_flags & (Flags.UncPath | Flags.DosPath | Flags.UnixPath)) != 0)
2099_flags |= Flags.AuthorityFound;
2107else if (_syntax.InFact(UriSyntaxFlags.OptionalAuthority) && (InFact(Flags.AuthorityFound) ||
2110_flags |= Flags.AuthorityFound;
2118if (InFact(Flags.HasUnicode))
2123_flags |= ((Flags)idx | Flags.UnknownHostType);
2136if (InFact(Flags.HasUnicode))
2141_flags |= ((Flags)idx | Flags.UnknownHostType);
2148if (InFact(Flags.DosPath))
2150_flags |= (((_flags & Flags.AuthorityFound) != 0) ? Flags.BasicHostType : Flags.UnknownHostType);
2151_flags |= (Flags)idx;
2174if (hostTerminator == '\\' && NotAny(Flags.ImplicitFile) && _syntax.NotAny(UriSyntaxFlags.AllowDOSPath))
2179else if (!OperatingSystem.IsWindows() && hostTerminator == '/' && NotAny(Flags.ImplicitFile) && InFact(Flags.UncPath) && _syntax == UriParser.FileUri)
2192_flags |= (Flags)idx;
2207private void CreateUriInfo(Flags cF)
2230if ((cF & Flags.ImplicitFile) != 0)
2232if (StaticInFact(cF, Flags.UncPath))
2240int end = (int)(cF & Flags.IndexMask);
2253if ((cF & Flags.AuthorityFound) != 0)
2271if ((cF & (Flags.UncPath | Flags.DosPath)) != 0)
2275int end = (int)(cF & Flags.IndexMask);
2294if ((cF & Flags.HasUserInfo) != 0)
2309idx = (int)(cF & Flags.IndexMask);
2313cF &= ~Flags.IndexMask;
2317cF |= Flags.SchemeNotCanonical;
2321if ((cF & Flags.HostTypeMask) != Flags.UnknownHostType && (cF & Flags.DosPath) == 0 &&
2342cF |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2360cF |= Flags.NotDefaultPort;
2366cF |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2376cF |= Flags.MinimalUriInfoSet;
2380Flags current = _flags;
2381while ((current & Flags.MinimalUriInfoSet) == 0)
2383Flags oldValue = Interlocked.CompareExchange(ref _flags, (current & ~Flags.IndexMask) | cF, current);
2404if (NotAny(Flags.ErrorOrParsingRecursion))
2406_flags |= Flags.ErrorOrParsingRecursion;
2409_flags &= ~Flags.ErrorOrParsingRecursion;
2415Flags flags = _flags;
2422if (HostType == Flags.BasicHostType)
2430if (NotAny(Flags.ImplicitFile) || (result & Check.ReservedFound) != 0)
2432flags |= Flags.HostNotCanonical;
2436if (InFact(Flags.ImplicitFile) && (result & (Check.ReservedFound | Check.EscapedCanonical)) != 0)
2445flags |= Flags.E_HostNotCanonical;
2446if (NotAny(Flags.UserEscaped))
2456else if (NotAny(Flags.CanonicalDnsHost))
2462flags |= (Flags.HostNotCanonical | Flags.E_HostNotCanonical);
2471flags |= (Flags.HostNotCanonical | Flags.E_HostNotCanonical);
2483private static string CreateHostStringHelper(string str, int idx, int end, ref Flags flags, UriInfo info)
2487switch (flags & Flags.HostTypeMask)
2489case Flags.DnsHostType:
2493case Flags.IPv6HostType:
2503case Flags.IPv4HostType:
2507case Flags.UncHostType:
2511case Flags.BasicHostType:
2512if (StaticInFact(flags, Flags.DosPath))
2529case Flags.UnknownHostType:
2540flags |= Flags.LoopbackHost;
2559Flags flags = _flags & ~Flags.HostTypeMask;
2566_flags = (_flags & ~Flags.HostTypeMask) | Flags.BasicHostType;
2576_flags |= (Flags.HostNotCanonical | Flags.E_HostNotCanonical);
2580_flags = (_flags & ~Flags.HostTypeMask) | (flags & Flags.HostTypeMask);
2591_flags &= ~Flags.NotDefaultPort;
2592_flags |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2606_flags &= ~Flags.NotDefaultPort;
2608_flags |= Flags.NotDefaultPort;
2610_flags |= (Flags.PortNotCanonical | Flags.E_PortNotCanonical);
2628Debug.Assert(_info != null && (_flags & Flags.MinimalUriInfoSet) != 0);
2633ushort nonCanonical = unchecked((ushort)(((ushort)_flags & ((ushort)Flags.CannotDisplayCanonical << 7)) >> 6));
2634if (InFact(Flags.SchemeNotCanonical))
2636nonCanonical |= (ushort)Flags.SchemeNotCanonical;
2642if (InFact(Flags.ShouldBeCompressed | Flags.FirstSlashAbsent | Flags.BackslashInPath))
2644nonCanonical |= (ushort)Flags.PathNotCanonical;
2649nonCanonical |= (ushort)Flags.PathNotCanonical;
2667Debug.Assert(_info != null && (_flags & Flags.MinimalUriInfoSet) != 0);
2672ushort nonCanonical = unchecked((ushort)((ushort)_flags & (ushort)Flags.CannotDisplayCanonical));
2677if ((_flags & (Flags.ShouldBeCompressed | Flags.FirstSlashAbsent | Flags.BackslashInPath)) != 0)
2679nonCanonical |= (ushort)Flags.PathNotCanonical;
2684nonCanonical |= (ushort)Flags.PathNotCanonical;
2737Debug.Assert(InFact(Flags.AllUriInfoSet));
2746if (InFact(Flags.AuthorityFound))
2755if ((parts & UriComponents.UserInfo) != 0 && InFact(Flags.HasUserInfo))
2764if (NotAny(Flags.UserEscaped))
2778InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape,
2827if (formatAs != UriFormat.UriEscaped && HostType == Flags.BasicHostType && (nonCanonical & (ushort)UriComponents.Host) != 0)
2838InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape,
2850if ((parts & UriComponents.SerializationInfoString) != 0 && HostType == Flags.IPv6HostType && _info._moreInfo?.ScopeId is string scopeId)
2861(InFact(Flags.NotDefaultPort) || ((parts & UriComponents.StrongPort) != 0 && _syntax.DefaultPort != UriParser.NoDefaultPort)))
2880if (InFact(Flags.AuthorityFound) && dest.Length != 0 && dest[0] == '/')
2925if (NotAny(Flags.UserEscaped))
2940UnescapeMode mode = InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape;
2967if (!InFact(Flags.HasUserInfo))
2977if (!InFact(Flags.HasUserInfo))
2980if (InFact(Flags.NotDefaultPort) || _syntax.DefaultPort == UriParser.NoDefaultPort)
2995if (InFact(Flags.HasUserInfo))
3028if (InFact(Flags.NotDefaultPort | Flags.PortNotCanonical))
3040if (uriParts == UriComponents.Path && InFact(Flags.AuthorityFound) &&
3081if (InFact(Flags.NotDefaultPort) || _syntax.DefaultPort == UriParser.NoDefaultPort)
3091if (InFact(Flags.HasUserInfo))
3108if (NotAny(Flags.HasUserInfo))
3140Flags cF = _flags | Flags.AllUriInfoSet;
3142if ((cF & Flags.UserDrivenParsing) != 0)
3148if ((cF & Flags.HasUnicode) != 0)
3163if ((cF & Flags.ImplicitFile) != 0)
3165cF |= Flags.SchemeNotCanonical;
3182cF |= Flags.SchemeNotCanonical;
3189if ((cF & Flags.AuthorityFound) != 0 && !str.Slice(schemeLength).StartsWith("://", StringComparison.Ordinal))
3191cF |= Flags.SchemeNotCanonical | Flags.SchemeNotCanonical_NoTrailingSlashes;
3199if ((cF & Flags.HasUserInfo) != 0)
3206cF |= Flags.UserNotCanonical;
3210cF |= Flags.E_UserNotCanonical;
3216cF |= Flags.UserIriCanonical;
3229if ((cF & Flags.DisablePathAndQueryCanonicalization) != 0)
3232if ((cF & Flags.ImplicitFile) != 0 || (syntaxFlags & UriSyntaxFlags.MayHaveQuery) == 0)
3259(cF & Flags.ImplicitFile) != 0 || (syntaxFlags & (UriSyntaxFlags.MayHaveQuery | UriSyntaxFlags.MayHaveFragment)) == 0 ? c_DummyChar :
3275if (((cF & Flags.AuthorityFound) != 0) && ((syntaxFlags & UriSyntaxFlags.PathIsRooted) != 0)
3278cF |= Flags.FirstSlashAbsent;
3285if ((cF & Flags.DosPath) != 0 || (((cF & Flags.AuthorityFound) != 0) &&
3291cF |= (Flags.E_PathNotCanonical | Flags.PathNotCanonical);
3297cF |= (Flags.E_PathNotCanonical | Flags.PathNotCanonical);
3301if (((syntaxFlags & (UriSyntaxFlags.CompressPath)) != 0) && ((cF & Flags.E_PathNotCanonical) != 0 ||
3304cF |= Flags.ShouldBeCompressed;
3308cF |= Flags.BackslashInPath;
3313cF |= Flags.E_PathNotCanonical;
3323if (((cF & Flags.ImplicitFile) == 0) || ((cF & Flags.UserEscaped) != 0) ||
3327cF |= Flags.PathNotCanonical;
3332if (((cF & Flags.ImplicitFile) != 0) && (result & (Check.ReservedFound | Check.EscapedCanonical)) != 0)
3341cF |= Flags.E_PathNotCanonical;
3348cF |= Flags.PathIriCanonical;
3363cF |= Flags.QueryNotCanonical;
3368cF |= Flags.E_QueryNotCanonical;
3375cF |= Flags.QueryIriCanonical;
3391cF |= Flags.FragmentNotCanonical;
3396cF |= Flags.E_FragmentNotCanonical;
3403cF |= Flags.FragmentIriCanonical;
3417Debug.Assert(InFact(Flags.HasUnicode));
3418Debug.Assert(InFact(Flags.MinimalUriInfoSet));
3419Debug.Assert(!InFact(Flags.UserDrivenParsing));
3423Flags flags = _flags;
3428if ((flags & (Flags.DosPath | Flags.UnixPath)) != 0)
3430if ((flags & Flags.ImplicitFile) == 0)
3434if ((flags & Flags.AuthorityFound) != 0)
3457if ((flags & Flags.DisablePathAndQueryCanonicalization) != 0)
3470int pathLength = (flags & Flags.ImplicitFile) != 0 || (syntaxFlags & UriSyntaxFlags.MayHaveQuery) == 0
3507private static int ParseSchemeCheckImplicitFile(string uriString, ref ParsingError err, ref Flags flags, ref UriParser? syntax)
3510Debug.Assert((flags & Flags.Debug_LeftConstructor) == 0);
3526flags |= (Flags.UnixPath | Flags.ImplicitFile | Flags.AuthorityFound);
3551flags |= (Flags.DosPath | Flags.ImplicitFile | Flags.AuthorityFound);
3568flags |= (Flags.UncPath | Flags.ImplicitFile | Flags.AuthorityFound);
3673private int CheckAuthorityHelper(ReadOnlySpan<char> str, int startOffset, out ParsingError err, ref Flags flags, UriSyntaxFlags syntaxFlags, ref string? newHost)
3675Debug.Assert((_flags & Flags.Debug_LeftConstructor) == 0 || (!_syntax.IsSimple && Monitor.IsEntered(_info)));
3676Debug.Assert((_flags & Flags.HasUserInfo) == 0 && (_flags & Flags.HostTypeMask) == 0);
3681bool hasUnicode = ((flags & Flags.HasUnicode) != 0);
3696flags &= ~Flags.UncPath; //UNC cannot have an empty hostname
3697if (StaticInFact(flags, Flags.ImplicitFile))
3700flags |= Flags.BasicHostType;
3722flags |= Flags.HasUserInfo;
3751flags |= Flags.IPv6HostType;
3759IPv4AddressHelper.IsValid(str.Slice(i), out hostLength, allowIPv6: false, StaticNotAny(flags, Flags.ImplicitFile), (syntaxFlags & UriSyntaxFlags.V1_UnknownUri) != 0))
3761flags |= Flags.IPv4HostType;
3769DomainNameHelper.IsValid(str.Slice(i), iri: false, StaticNotAny(flags, Flags.ImplicitFile), out hostLength))
3774flags |= Flags.DnsHostType;
3779flags |= Flags.CanonicalDnsHost;
3784DomainNameHelper.IsValid(str.Slice(i), iri: true, StaticNotAny(flags, Flags.ImplicitFile), out hostLength))
3786flags |= Flags.DnsHostType;
3810if (UncNameHelper.IsValid(str.Slice(i), StaticNotAny(flags, Flags.ImplicitFile), out hostLength))
3814flags |= Flags.UncHostType;
3828if (hostDelimiter == '\\' && (flags & Flags.HostTypeMask) != Flags.HostNotParsed && (syntaxFlags & UriSyntaxFlags.FileLikeUri) == 0)
3836flags &= ~Flags.HostTypeMask;
3865flags &= ~Flags.HostTypeMask;
3881flags &= ~Flags.HostTypeMask;
3897flags &= ~Flags.HostTypeMask;
3902if ((flags & Flags.HostTypeMask) == Flags.HostNotParsed)
3905flags &= ~Flags.HasUserInfo;
3910flags |= Flags.BasicHostType;
3954flags |= Flags.BasicHostType;
4121if ((_flags & Flags.HasUnicode) != 0)
4172if (InFact(Flags.FirstSlashAbsent))
4187if (InFact(Flags.ShouldBeCompressed))
4194if (_syntax.InFact(UriSyntaxFlags.UnEscapeDotsAndSlashes) && InFact(Flags.PathNotCanonical)
4203if (InFact(Flags.E_PathNotCanonical) && NotAny(Flags.UserEscaped))
4226if (!OperatingSystem.IsWindows() && InFact(Flags.BackslashInPath) && _syntax.NotAny(UriSyntaxFlags.ConvertPathSlashes) && _syntax.InFact(UriSyntaxFlags.FileLikeUri) && !IsImplicitFile)
4244if (InFact(Flags.ShouldBeCompressed))
4249if (_syntax.InFact(UriSyntaxFlags.UnEscapeDotsAndSlashes) && InFact(Flags.PathNotCanonical)
4269if (InFact(Flags.ShouldBeCompressed) && dest.Length - offset > 0)
4280if (formatAs == UriFormat.UriEscaped && NotAny(Flags.UserEscaped) && InFact(Flags.E_PathNotCanonical))
4297if (formatAs != UriFormat.UriEscaped && InFact(Flags.PathNotCanonical))
4314UnescapeMode mode = InFact(Flags.UserEscaped) ? UnescapeMode.Unescape : UnescapeMode.EscapeUnescape;
4489if (basePart.HostType == Flags.IPv6HostType)
4563if (basePart.HostType == Flags.IPv6HostType)
4877return InFact(Flags.AuthorityFound);