< Summary

Line coverage
29%
Covered lines: 65
Uncovered lines: 159
Coverable lines: 224
Total lines: 703
Line coverage: 29%
Branch coverage
0%
Covered branches: 0
Total branches: 70
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Private.Uri/src/System/UriScheme.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System.Diagnostics;
 5using System.Runtime.CompilerServices;
 6using System.Threading;
 7
 8namespace System
 9{
 10    //
 11    // The class is used as a base for custom uri parsing and derived Uri factoring.
 12    // A set of protected .ctors allows to hookup on the builtin parser behaviors.
 13    //
 14    // A developer must implement at least internal default .ctor to participate in the Uri extensibility game.
 15    //
 16    public abstract partial class UriParser
 17    {
 18        internal string SchemeName
 19        {
 20            get
 69021            {
 69022                return _scheme;
 69023            }
 24        }
 25        internal int DefaultPort
 26        {
 27            get
 132228            {
 132229                return _port;
 132230            }
 31        }
 32
 33        private const UriSyntaxFlags SchemeOnlyFlags = UriSyntaxFlags.MayHavePath;
 34        // This is a "scheme-only" base parser, everything after the scheme is
 35        // returned as the path component.
 36        // The user parser will need to do the majority of the work itself.
 37        //
 38        // However when the ctor is called from OnCreateUri context the calling parser
 39        // settings will later override the result on the base class
 40        //
 041        protected UriParser() : this(SchemeOnlyFlags) { }
 42
 43        //
 44        // Is called on each Uri ctor for every non-simple parser i.e. the one that does have
 45        // user code.
 46        //
 47        protected virtual UriParser OnNewUri()
 048        {
 049            return this;
 050        }
 51
 52        //
 53        // Is called whenever a parser gets registered with some scheme
 54        // The base implementation is a nop.
 55        //
 56        protected virtual void OnRegister(string schemeName, int defaultPort)
 057        {
 058        }
 59
 60        //
 61        // Parses and validates a Uri object, is called at the Uri ctor time.
 62        //
 63        // This method returns a non null parsingError if Uri being created is invalid:
 64        //
 65        protected virtual void InitializeAndValidate(Uri uri, out UriFormatException? parsingError)
 066        {
 067            if (uri._syntax is null)
 068            {
 069                throw new InvalidOperationException(SR.net_uri_NotAbsolute);
 70            }
 71
 072            if (!ReferenceEquals(uri._syntax, this))
 073            {
 074                throw new InvalidOperationException(SR.Format(SR.net_uri_UserDrivenParsing, uri._syntax.GetType()));
 75            }
 76
 077            Debug.Assert(sizeof(Uri.Flags) == sizeof(ulong));
 78
 79            // If ParseMinimal is called multiple times this Uri instance may be corrupted, throw an exception instead
 080            Uri.Flags previous = Interlocked.Or(ref uri._flags, Uri.Flags.CustomParser_ParseMinimalAlreadyCalled);
 081            if ((previous & Uri.Flags.CustomParser_ParseMinimalAlreadyCalled) != 0)
 082            {
 083                throw new InvalidOperationException(SR.net_uri_InitializeCalledAlreadyOrTooLate);
 84            }
 85
 086            parsingError = uri.ParseMinimal();
 087        }
 88
 89        //
 90        // Resolves a relative Uri object into new AbsoluteUri.
 91        //
 92        //  baseUri         - The baseUri used to resolve this Uri.
 93        //  relativeuri     - A relative Uri string passed by the application.
 94        //
 95        // This method returns:
 96        // The result Uri value used to represent a new Uri
 97        //
 98        protected virtual string? Resolve(Uri baseUri, Uri? relativeUri, out UriFormatException? parsingError)
 099        {
 0100            if (baseUri.UserDrivenParsing)
 0101                throw new InvalidOperationException(SR.Format(SR.net_uri_UserDrivenParsing, this.GetType()));
 102
 0103            if (!baseUri.IsAbsoluteUri)
 0104                throw new InvalidOperationException(SR.net_uri_NotAbsolute);
 105
 0106            string? newUriString = null;
 0107            bool userEscaped = false;
 0108            parsingError = null;
 109
 0110            Uri? result = Uri.ResolveHelper(baseUri, relativeUri, ref newUriString, ref userEscaped);
 111
 0112            if (result != null)
 0113                return result.OriginalString;
 114
 0115            return newUriString;
 0116        }
 117
 118        protected virtual bool IsBaseOf(Uri baseUri, Uri relativeUri)
 0119        {
 0120            return baseUri.IsBaseOfHelper(relativeUri);
 0121        }
 122
 123        //
 124        // This method is invoked to allow a custom parser to override the
 125        // internal parser when serving application with Uri component strings.
 126        // The output format depends on the "format" parameter
 127        //
 128        // Parameters:
 129        //  uriComponents   - Which components are to be retrieved.
 130        //  uriFormat       - The requested output format.
 131        //
 132        // This method returns:
 133        // The final result. The base implementation could be invoked to get a suggested value
 134        //
 135        protected virtual string GetComponents(Uri uri, UriComponents components, UriFormat format)
 0136        {
 0137            if (((components & UriComponents.SerializationInfoString) != 0) && components != UriComponents.Serialization
 0138                throw new ArgumentOutOfRangeException(nameof(components), components, SR.net_uri_NotJustSerialization);
 139
 0140            if ((format & ~UriFormat.SafeUnescaped) != 0)
 0141                throw new ArgumentOutOfRangeException(nameof(format));
 142
 0143            if (uri.UserDrivenParsing)
 0144                throw new InvalidOperationException(SR.Format(SR.net_uri_UserDrivenParsing, this.GetType()));
 145
 0146            if (!uri.IsAbsoluteUri)
 0147                throw new InvalidOperationException(SR.net_uri_NotAbsolute);
 148
 0149            if (uri.DisablePathAndQueryCanonicalization && (components & (UriComponents.Path | UriComponents.Query)) != 
 0150                throw new InvalidOperationException(SR.net_uri_GetComponentsCalledWhenCanonicalizationDisabled);
 151
 0152            return uri.GetComponentsHelper(components, format);
 0153        }
 154
 155        protected virtual bool IsWellFormedOriginalString(Uri uri)
 0156        {
 0157            return uri.InternalIsWellFormedOriginalString();
 0158        }
 159
 160        //
 161        // Static Registration methods
 162        //
 163        //
 164        // Registers a custom Uri parser based on a scheme string
 165        //
 166        public static void Register(UriParser uriParser, string schemeName, int defaultPort)
 0167        {
 0168            ArgumentNullException.ThrowIfNull(uriParser);
 0169            ArgumentNullException.ThrowIfNull(schemeName);
 170
 0171            ArgumentOutOfRangeException.ThrowIfEqual(schemeName.Length, 1);
 172
 0173            if (!Uri.CheckSchemeName(schemeName))
 0174                throw new ArgumentOutOfRangeException(nameof(schemeName));
 175
 0176            if ((uint)defaultPort > 0xFFFF && defaultPort != -1)
 0177                throw new ArgumentOutOfRangeException(nameof(defaultPort));
 178
 0179            schemeName = schemeName.ToLowerInvariant();
 0180            FetchSyntax(uriParser, schemeName, defaultPort);
 0181        }
 182
 183        //
 184        // Is a Uri scheme known to System.Uri?
 185        //
 186        public static bool IsKnownScheme(string schemeName)
 0187        {
 0188            ArgumentNullException.ThrowIfNull(schemeName);
 189
 0190            if (!Uri.CheckSchemeName(schemeName))
 0191                throw new ArgumentOutOfRangeException(nameof(schemeName));
 192
 0193            UriParser? syntax = UriParser.GetSyntax(schemeName.ToLowerInvariant());
 0194            return syntax != null && syntax.NotAny(UriSyntaxFlags.V1_UnknownUri);
 0195        }
 196    }
 197}
 198

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Private.Uri/src/System/UriSyntax.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4// This file utilizes partial class feature and contains
 5// only internal implementation of UriParser type
 6
 7using System.Collections;
 8using System.Diagnostics;
 9using System.Runtime.CompilerServices;
 10using System.Threading;
 11
 12namespace System
 13{
 14    // This enum specifies the Uri syntax flags that is understood by builtin Uri parser.
 15    [Flags]
 16    internal enum UriSyntaxFlags
 17    {
 18        None = 0x0,
 19
 20        MustHaveAuthority = 0x1,  // must have "//" after scheme:
 21        OptionalAuthority = 0x2,  // used by generic parser due to unknown Uri syntax
 22        MayHaveUserInfo = 0x4,
 23        MayHavePort = 0x8,
 24        MayHavePath = 0x10,
 25        MayHaveQuery = 0x20,
 26        MayHaveFragment = 0x40,
 27
 28        AllowEmptyHost = 0x80,
 29        AllowUncHost = 0x100,
 30        AllowDnsHost = 0x200,
 31        AllowIPv4Host = 0x400,
 32        AllowIPv6Host = 0x800,
 33        AllowAnInternetHost = AllowDnsHost | AllowIPv4Host | AllowIPv6Host,
 34        AllowAnyOtherHost = 0x1000, // Relaxed authority syntax
 35
 36        FileLikeUri = 0x2000, //Special case to allow file:\\balbla or file://\\balbla
 37        MailToLikeUri = 0x4000, //V1 parser inheritance mailTo:AuthorityButNoSlashes
 38
 39        V1_UnknownUri = 0x10000, // a Compatibility with V1 parser for an unknown scheme
 40        SimpleUserSyntax = 0x20000, // It is safe to not call virtual UriParser methods
 41
 42        AllowDOSPath = 0x100000,  // will check for "x:\"
 43        PathIsRooted = 0x200000,  // For an authority based Uri the first path char is '/'
 44        ConvertPathSlashes = 0x400000,  // will turn '\' into '/'
 45        CompressPath = 0x800000,  // For an authority based Uri remove/compress /./ /../ in the path
 46        CanonicalizeAsFilePath = 0x1000000, // remove/convert sequences /.../ /x../ /x./ dangerous for a DOS path
 47        UnEscapeDotsAndSlashes = 0x2000000, // additionally unescape dots and slashes before doing path compression
 48        AllowIdn = 0x4000000,    // IDN host conversion allowed
 49        AllowIriParsing = 0x10000000,   // Iri parsing. String is normalized, bidi control
 50                                        // characters are removed, unicode char limits are checked etc.
 51    }
 52
 53    //
 54    // Only internal members are included here
 55    //
 56    public abstract partial class UriParser
 57    {
 58        // These are always available without paying hashtable lookup cost
 59        // Note: see UpdateStaticSyntaxReference()
 160        internal static readonly UriParser HttpUri = new BuiltInUriParser("http", 80, HttpSyntaxFlags);
 161        internal static readonly UriParser HttpsUri = new BuiltInUriParser("https", 443, HttpUri._flags);
 162        internal static readonly UriParser WsUri = new BuiltInUriParser("ws", 80, HttpSyntaxFlags);
 163        internal static readonly UriParser WssUri = new BuiltInUriParser("wss", 443, HttpSyntaxFlags);
 164        internal static readonly UriParser FtpUri = new BuiltInUriParser("ftp", 21, FtpSyntaxFlags);
 165        internal static readonly UriParser FileUri = new BuiltInUriParser("file", NoDefaultPort, FileSyntaxFlags);
 166        internal static readonly UriParser UnixFileUri = new BuiltInUriParser("file", NoDefaultPort, UnixFileSyntaxFlags
 167        internal static readonly UriParser GopherUri = new BuiltInUriParser("gopher", 70, GopherSyntaxFlags);
 168        internal static readonly UriParser NntpUri = new BuiltInUriParser("nntp", 119, NntpSyntaxFlags);
 169        internal static readonly UriParser NewsUri = new BuiltInUriParser("news", NoDefaultPort, NewsSyntaxFlags);
 170        internal static readonly UriParser MailToUri = new BuiltInUriParser("mailto", 25, MailtoSyntaxFlags);
 171        internal static readonly UriParser UuidUri = new BuiltInUriParser("uuid", NoDefaultPort, NewsUri._flags);
 172        internal static readonly UriParser TelnetUri = new BuiltInUriParser("telnet", 23, TelnetSyntaxFlags);
 173        internal static readonly UriParser LdapUri = new BuiltInUriParser("ldap", 389, LdapSyntaxFlags);
 174        internal static readonly UriParser NetTcpUri = new BuiltInUriParser("net.tcp", 808, NetTcpSyntaxFlags);
 175        internal static readonly UriParser NetPipeUri = new BuiltInUriParser("net.pipe", NoDefaultPort, NetPipeSyntaxFla
 176        internal static readonly UriParser VsMacrosUri = new BuiltInUriParser("vsmacros", NoDefaultPort, VsmacrosSyntaxF
 77
 178        private static readonly Hashtable s_table = new Hashtable(16) // Hashtable used instead of Dictionary<> for lock
 179        {
 180            { HttpUri.SchemeName, HttpUri }, // HTTP
 181            { HttpsUri.SchemeName, HttpsUri }, // HTTPS cloned from HTTP
 182            { WsUri.SchemeName, WsUri }, // WebSockets
 183            { WssUri.SchemeName, WssUri }, // Secure WebSockets
 184            { FtpUri.SchemeName, FtpUri }, //FTP
 185            { FileUri.SchemeName, FileUri }, //FILE
 186            { GopherUri.SchemeName, GopherUri }, //GOPHER
 187            { NntpUri.SchemeName, NntpUri }, //NNTP
 188            { NewsUri.SchemeName, NewsUri }, //NEWS
 189            { MailToUri.SchemeName, MailToUri }, //MAILTO
 190            { UuidUri.SchemeName, UuidUri }, //UUID cloned from NEWS
 191            { TelnetUri.SchemeName, TelnetUri }, //TELNET
 192            { LdapUri.SchemeName, LdapUri }, //LDAP
 193            { NetTcpUri.SchemeName, NetTcpUri },
 194            { NetPipeUri.SchemeName, NetPipeUri },
 195            { VsMacrosUri.SchemeName, VsMacrosUri }, //VSMACROS
 196        };
 197        private static Hashtable s_tempTable = new Hashtable(c_InitialTableSize); // Hashtable used instead of Dictionar
 98
 99        private UriSyntaxFlags _flags;
 100
 101        private int _port;
 102        private string _scheme;
 103
 104        internal const int NoDefaultPort = -1;
 105        private const int c_InitialTableSize = 25;
 106
 107        private sealed class BuiltInUriParser : UriParser
 108        {
 109            //
 110            // All BuiltIn parsers use that ctor. They are marked with "simple" and "built-in" flags
 111            //
 112            internal BuiltInUriParser(string lwrCaseScheme, int defaultPort, UriSyntaxFlags syntaxFlags)
 17113                : base(syntaxFlags | UriSyntaxFlags.SimpleUserSyntax)
 17114            {
 17115                _scheme = lwrCaseScheme;
 17116                _port = defaultPort;
 17117            }
 118        }
 119
 120        internal UriSyntaxFlags Flags
 121        {
 122            get
 661123            {
 661124                return _flags;
 661125            }
 126        }
 127
 128        internal bool NotAny(UriSyntaxFlags flags)
 0129        {
 130            // Return true if none of the flags specified in 'flags' are set.
 0131            return (_flags & flags) == 0;
 0132        }
 133
 134        internal bool InFact(UriSyntaxFlags flags)
 3305135        {
 136            // Return true if at least one of the flags in 'flags' is set.
 3305137            return (_flags & flags) != 0;
 3305138        }
 139
 140        internal bool IsAllSet(UriSyntaxFlags flags)
 661141        {
 142            // Return true if all flags in 'flags' are set.
 661143            return (_flags & flags) == flags;
 661144        }
 145
 146        //
 147        // Internal .ctor, any ctor eventually goes through this one
 148        //
 17149        internal UriParser(UriSyntaxFlags flags)
 17150        {
 17151            _flags = flags;
 17152            _scheme = string.Empty;
 17153        }
 154
 155        private static void FetchSyntax(UriParser syntax, string lwrCaseSchemeName, int defaultPort)
 0156        {
 0157            if (syntax.SchemeName.Length != 0)
 0158                throw new InvalidOperationException(SR.Format(SR.net_uri_NeedFreshParser, syntax.SchemeName));
 159
 0160            lock (s_table)
 0161            {
 0162                syntax._flags &= ~UriSyntaxFlags.V1_UnknownUri;
 0163                UriParser? oldSyntax = (UriParser?)s_table[lwrCaseSchemeName];
 0164                if (oldSyntax != null)
 0165                    throw new InvalidOperationException(SR.Format(SR.net_uri_AlreadyRegistered, oldSyntax.SchemeName));
 166
 0167                oldSyntax = (UriParser?)s_tempTable[syntax.SchemeName];
 0168                if (oldSyntax != null)
 0169                {
 170                    // optimization on schemeName, will try to keep the first reference
 0171                    lwrCaseSchemeName = oldSyntax._scheme;
 0172                    s_tempTable.Remove(lwrCaseSchemeName);
 0173                }
 174
 0175                syntax.OnRegister(lwrCaseSchemeName, defaultPort);
 0176                syntax._scheme = lwrCaseSchemeName;
 0177                syntax.CheckSetIsSimpleFlag();
 0178                syntax._port = defaultPort;
 179
 0180                s_table[syntax.SchemeName] = syntax;
 0181            }
 0182        }
 183
 184        private const int c_MaxCapacity = 512;
 185        //schemeStr must be in lower case!
 186        internal static UriParser FindOrFetchAsUnknownV1Syntax(string lwrCaseScheme)
 0187        {
 188            // check may be other thread just added one
 0189            UriParser? syntax = (UriParser?)s_table[lwrCaseScheme];
 0190            if (syntax != null)
 0191            {
 0192                return syntax;
 193            }
 0194            syntax = (UriParser?)s_tempTable[lwrCaseScheme];
 0195            if (syntax != null)
 0196            {
 0197                return syntax;
 198            }
 0199            lock (s_table)
 0200            {
 0201                if (s_tempTable.Count >= c_MaxCapacity)
 0202                {
 0203                    s_tempTable = new Hashtable(c_InitialTableSize);
 0204                }
 0205                syntax = new BuiltInUriParser(lwrCaseScheme, NoDefaultPort, UnknownV1SyntaxFlags);
 0206                s_tempTable[lwrCaseScheme] = syntax;
 0207                return syntax;
 208            }
 0209        }
 210
 211        internal static UriParser? GetSyntax(string lwrCaseScheme) =>
 0212            (UriParser?)(s_table[lwrCaseScheme] ?? s_tempTable[lwrCaseScheme]);
 213
 214        //
 215        // Builtin and User Simple syntaxes do not need custom validation/parsing (i.e. virtual method calls),
 216        //
 217        internal bool IsSimple
 218        {
 219            get
 1322220            {
 1322221                return InFact(UriSyntaxFlags.SimpleUserSyntax);
 1322222            }
 223        }
 224
 225        internal void CheckSetIsSimpleFlag()
 0226        {
 0227            Type type = this.GetType();
 228
 0229            if (type == typeof(GenericUriParser)
 0230                || type == typeof(HttpStyleUriParser)
 0231                || type == typeof(FtpStyleUriParser)
 0232                || type == typeof(FileStyleUriParser)
 0233                || type == typeof(NewsStyleUriParser)
 0234                || type == typeof(GopherStyleUriParser)
 0235                || type == typeof(NetPipeStyleUriParser)
 0236                || type == typeof(NetTcpStyleUriParser)
 0237                || type == typeof(LdapStyleUriParser)
 0238                )
 0239            {
 0240                _flags |= UriSyntaxFlags.SimpleUserSyntax;
 0241            }
 0242        }
 243
 244        //
 245        // These are simple internal wrappers that will call protected virtual methods
 246        // (to avoid "protected internal" signatures in the public docs)
 247        //
 248        internal UriParser InternalOnNewUri()
 0249        {
 0250            UriParser effectiveParser = OnNewUri();
 0251            if ((object)this != (object)effectiveParser)
 0252            {
 0253                effectiveParser._scheme = _scheme;
 0254                effectiveParser._port = _port;
 0255                effectiveParser._flags = _flags;
 0256            }
 0257            return effectiveParser;
 0258        }
 259
 260        internal void InternalValidate(Uri thisUri, out UriFormatException? parsingError)
 0261        {
 0262            thisUri.DebugAssertInCtor();
 0263            InitializeAndValidate(thisUri, out parsingError);
 264
 265            // InitializeAndValidate should not be called outside of the constructor
 0266            Debug.Assert(sizeof(Uri.Flags) == sizeof(ulong));
 0267            Interlocked.Or(ref thisUri._flags, Uri.Flags.CustomParser_ParseMinimalAlreadyCalled);
 0268        }
 269
 270        internal string? InternalResolve(Uri thisBaseUri, Uri uriLink, out UriFormatException? parsingError)
 0271        {
 0272            return Resolve(thisBaseUri, uriLink, out parsingError);
 0273        }
 274
 275        internal bool InternalIsBaseOf(Uri thisBaseUri, Uri uriLink)
 0276        {
 0277            return IsBaseOf(thisBaseUri, uriLink);
 0278        }
 279
 280        internal string InternalGetComponents(Uri thisUri, UriComponents uriComponents, UriFormat uriFormat)
 0281        {
 0282            return GetComponents(thisUri, uriComponents, uriFormat);
 0283        }
 284
 285        internal bool InternalIsWellFormedOriginalString(Uri thisUri)
 0286        {
 0287            return IsWellFormedOriginalString(thisUri);
 0288        }
 289
 290        //
 291        // Various Uri scheme syntax flags
 292        //
 293        private const UriSyntaxFlags UnknownV1SyntaxFlags =
 294                                            UriSyntaxFlags.V1_UnknownUri | // This flag must be always set here
 295                                            UriSyntaxFlags.OptionalAuthority |
 296                                            //
 297                                            UriSyntaxFlags.MayHaveUserInfo |
 298                                            UriSyntaxFlags.MayHavePort |
 299                                            UriSyntaxFlags.MayHavePath |
 300                                            UriSyntaxFlags.MayHaveQuery |
 301                                            UriSyntaxFlags.MayHaveFragment |
 302                                            //
 303                                            UriSyntaxFlags.AllowEmptyHost |
 304                                            UriSyntaxFlags.AllowUncHost |       // V1 compat
 305                                            UriSyntaxFlags.AllowAnInternetHost |
 306                                            UriSyntaxFlags.PathIsRooted |
 307                                            UriSyntaxFlags.AllowDOSPath |        // V1 compat, actually we should not pa
 308                                            UriSyntaxFlags.ConvertPathSlashes |  // V1 compat, it will always convert ba
 309                                            UriSyntaxFlags.CompressPath |        // V1 compat, it will always compress p
 310                                            UriSyntaxFlags.AllowIdn |
 311                                            UriSyntaxFlags.AllowIriParsing;
 312
 313        private const UriSyntaxFlags HttpSyntaxFlags =
 314                                        UriSyntaxFlags.MustHaveAuthority |
 315                                        //
 316                                        UriSyntaxFlags.MayHaveUserInfo |
 317                                        UriSyntaxFlags.MayHavePort |
 318                                        UriSyntaxFlags.MayHavePath |
 319                                        UriSyntaxFlags.MayHaveQuery |
 320                                        UriSyntaxFlags.MayHaveFragment |
 321                                        //
 322                                        UriSyntaxFlags.AllowUncHost |       // V1 compat
 323                                        UriSyntaxFlags.AllowAnInternetHost |
 324                                        //
 325                                        UriSyntaxFlags.PathIsRooted |
 326                                        //
 327                                        UriSyntaxFlags.ConvertPathSlashes |
 328                                        UriSyntaxFlags.CompressPath |
 329                                        UriSyntaxFlags.CanonicalizeAsFilePath |
 330                                        UriSyntaxFlags.AllowIdn |
 331                                        UriSyntaxFlags.AllowIriParsing;
 332
 333        private const UriSyntaxFlags FtpSyntaxFlags =
 334                                        UriSyntaxFlags.MustHaveAuthority |
 335                                        //
 336                                        UriSyntaxFlags.MayHaveUserInfo |
 337                                        UriSyntaxFlags.MayHavePort |
 338                                        UriSyntaxFlags.MayHavePath |
 339                                        UriSyntaxFlags.MayHaveFragment |
 340                                        //
 341                                        UriSyntaxFlags.AllowUncHost |       // V1 compat
 342                                        UriSyntaxFlags.AllowAnInternetHost |
 343                                        //
 344                                        UriSyntaxFlags.PathIsRooted |
 345                                        //
 346                                        UriSyntaxFlags.ConvertPathSlashes |
 347                                        UriSyntaxFlags.CompressPath |
 348                                        UriSyntaxFlags.CanonicalizeAsFilePath |
 349                                        UriSyntaxFlags.AllowIdn |
 350                                        UriSyntaxFlags.AllowIriParsing;
 351
 352        private const UriSyntaxFlags FileSyntaxFlags =
 353                                        UriSyntaxFlags.MustHaveAuthority |
 354                                        //
 355                                        UriSyntaxFlags.AllowEmptyHost |
 356                                        UriSyntaxFlags.AllowUncHost |
 357                                        UriSyntaxFlags.AllowAnInternetHost |
 358                                        //
 359                                        UriSyntaxFlags.MayHavePath |
 360                                        UriSyntaxFlags.MayHaveFragment |
 361                                        UriSyntaxFlags.MayHaveQuery |
 362                                        //
 363                                        UriSyntaxFlags.FileLikeUri |
 364                                        //
 365                                        UriSyntaxFlags.PathIsRooted |
 366                                        UriSyntaxFlags.AllowDOSPath |
 367                                        //
 368                                        UriSyntaxFlags.ConvertPathSlashes |
 369                                        UriSyntaxFlags.CompressPath |
 370                                        UriSyntaxFlags.CanonicalizeAsFilePath |
 371                                        UriSyntaxFlags.UnEscapeDotsAndSlashes |
 372                                        UriSyntaxFlags.AllowIdn |
 373                                        UriSyntaxFlags.AllowIriParsing;
 374
 375        private const UriSyntaxFlags UnixFileSyntaxFlags =
 376                                        FileSyntaxFlags & ~UriSyntaxFlags.ConvertPathSlashes;
 377
 378        private const UriSyntaxFlags VsmacrosSyntaxFlags =
 379                                        UriSyntaxFlags.MustHaveAuthority |
 380                                        //
 381                                        UriSyntaxFlags.AllowEmptyHost |
 382                                        UriSyntaxFlags.AllowUncHost |
 383                                        UriSyntaxFlags.AllowAnInternetHost |
 384                                        //
 385                                        UriSyntaxFlags.MayHavePath |
 386                                        UriSyntaxFlags.MayHaveFragment |
 387                                        //
 388                                        UriSyntaxFlags.FileLikeUri |
 389                                        //
 390                                        UriSyntaxFlags.AllowDOSPath |
 391                                        UriSyntaxFlags.ConvertPathSlashes |
 392                                        UriSyntaxFlags.CompressPath |
 393                                        UriSyntaxFlags.CanonicalizeAsFilePath |
 394                                        UriSyntaxFlags.UnEscapeDotsAndSlashes |
 395                                        UriSyntaxFlags.AllowIdn |
 396                                        UriSyntaxFlags.AllowIriParsing;
 397
 398        private const UriSyntaxFlags GopherSyntaxFlags =
 399                                        UriSyntaxFlags.MustHaveAuthority |
 400                                        //
 401                                        UriSyntaxFlags.MayHaveUserInfo |
 402                                        UriSyntaxFlags.MayHavePort |
 403                                        UriSyntaxFlags.MayHavePath |
 404                                        UriSyntaxFlags.MayHaveFragment |
 405                                        //
 406                                        UriSyntaxFlags.AllowUncHost |       // V1 compat
 407                                        UriSyntaxFlags.AllowAnInternetHost |
 408                                        //
 409                                        UriSyntaxFlags.PathIsRooted |
 410                                        UriSyntaxFlags.AllowIdn |
 411                                        UriSyntaxFlags.AllowIriParsing;
 412
 413        //Note that NNTP and NEWS are quite different in syntax
 414        private const UriSyntaxFlags NewsSyntaxFlags =
 415                                        UriSyntaxFlags.MayHavePath |
 416                                        UriSyntaxFlags.MayHaveFragment |
 417                                        UriSyntaxFlags.AllowIriParsing;
 418
 419        private const UriSyntaxFlags NntpSyntaxFlags =
 420                                        UriSyntaxFlags.MustHaveAuthority |
 421                                        //
 422                                        UriSyntaxFlags.MayHaveUserInfo |
 423                                        UriSyntaxFlags.MayHavePort |
 424                                        UriSyntaxFlags.MayHavePath |
 425                                        UriSyntaxFlags.MayHaveFragment |
 426                                        //
 427                                        UriSyntaxFlags.AllowUncHost |       // V1 compat
 428                                        UriSyntaxFlags.AllowAnInternetHost |
 429                                        //
 430                                        UriSyntaxFlags.PathIsRooted |
 431                                        UriSyntaxFlags.AllowIdn |
 432                                        UriSyntaxFlags.AllowIriParsing;
 433
 434
 435        private const UriSyntaxFlags TelnetSyntaxFlags =
 436                                        UriSyntaxFlags.MustHaveAuthority |
 437                                        //
 438                                        UriSyntaxFlags.MayHaveUserInfo |
 439                                        UriSyntaxFlags.MayHavePort |
 440                                        UriSyntaxFlags.MayHavePath |
 441                                        UriSyntaxFlags.MayHaveFragment |
 442                                        //
 443                                        UriSyntaxFlags.AllowUncHost |       // V1 compat
 444                                        UriSyntaxFlags.AllowAnInternetHost |
 445                                        //
 446                                        UriSyntaxFlags.PathIsRooted |
 447                                        UriSyntaxFlags.AllowIdn |
 448                                        UriSyntaxFlags.AllowIriParsing;
 449
 450
 451        private const UriSyntaxFlags LdapSyntaxFlags =
 452                                        UriSyntaxFlags.MustHaveAuthority |
 453                                        //
 454                                        UriSyntaxFlags.AllowEmptyHost |
 455                                        UriSyntaxFlags.AllowUncHost |       // V1 compat
 456                                        UriSyntaxFlags.AllowAnInternetHost |
 457                                        //
 458                                        UriSyntaxFlags.MayHaveUserInfo |
 459                                        UriSyntaxFlags.MayHavePort |
 460                                        UriSyntaxFlags.MayHavePath |
 461                                        UriSyntaxFlags.MayHaveQuery |
 462                                        UriSyntaxFlags.MayHaveFragment |
 463                                        //
 464                                        UriSyntaxFlags.PathIsRooted |
 465                                        UriSyntaxFlags.AllowIdn |
 466                                        UriSyntaxFlags.AllowIriParsing;
 467
 468
 469        private const UriSyntaxFlags MailtoSyntaxFlags =
 470                                        //
 471                                        UriSyntaxFlags.AllowEmptyHost |
 472                                        UriSyntaxFlags.AllowUncHost |       // V1 compat
 473                                        UriSyntaxFlags.AllowAnInternetHost |
 474                                        //
 475                                        UriSyntaxFlags.MayHaveUserInfo |
 476                                        UriSyntaxFlags.MayHavePort |
 477                                        UriSyntaxFlags.MayHavePath |
 478                                        UriSyntaxFlags.MayHaveFragment |
 479                                        UriSyntaxFlags.MayHaveQuery | //to maintain compat
 480                                                                      //
 481                                        UriSyntaxFlags.MailToLikeUri |
 482                                        UriSyntaxFlags.AllowIdn |
 483                                        UriSyntaxFlags.AllowIriParsing;
 484
 485
 486
 487        private const UriSyntaxFlags NetPipeSyntaxFlags =
 488                                        UriSyntaxFlags.MustHaveAuthority |
 489                                        UriSyntaxFlags.MayHavePath |
 490                                        UriSyntaxFlags.MayHaveQuery |
 491                                        UriSyntaxFlags.MayHaveFragment |
 492                                        UriSyntaxFlags.AllowAnInternetHost |
 493                                        UriSyntaxFlags.PathIsRooted |
 494                                        UriSyntaxFlags.ConvertPathSlashes |
 495                                        UriSyntaxFlags.CompressPath |
 496                                        UriSyntaxFlags.CanonicalizeAsFilePath |
 497                                        UriSyntaxFlags.UnEscapeDotsAndSlashes |
 498                                        UriSyntaxFlags.AllowIdn |
 499                                        UriSyntaxFlags.AllowIriParsing;
 500
 501
 502        private const UriSyntaxFlags NetTcpSyntaxFlags = NetPipeSyntaxFlags | UriSyntaxFlags.MayHavePort;
 503    }
 504}
 505