Subject to valid options on the public System.GenericUriParserOptions being mappable to the specific private System.UriSyntaxFlags you can probably create an instance of System.GenericUriParser that /does/ allow UserInfo.
But then you can't System.UriParser.Register for an existing (and, in this case, built-in) scheme. (But it would only be a "little bit" of reflection to write your own Unregister, or even Reregister, if you really want to correct this issue now yourself.) On 12 November 2015 at 15:37, Mark Hurd <markeh...@gmail.com> wrote: > Yeah, note that NetPipeSyntaxFlags > > http://referencesource.microsoft.com/System/R/88aaba2e83d81ad0.html > > and thus NetTcpSyntaxFlags does not include UriSyntaxFlags.MayHaveUserInfo > > so, they intended to not allow user:password in these Uris, or it is a > large oversight. > > > On 12 November 2015 at 14:33, Thomas Koster <tkos...@gmail.com> wrote: >> On 11 November 2015 at 17:43, Thomas Koster <tkos...@gmail.com> wrote: >>> I am parsing a URL to connect to a WCF service. Try this: >>> >>> new Uri("net.tcp://guest:guest@myserver:12345"); >>> >>> I get a UriFormatException that complains about an invalid port >>> number. Uri.TryCreate is no better. >>> >>> It works if I remove the userinfo (credentials). It also works if I >>> don't use a scheme with a dot in it. I need both, however. >>> >>> As far as I can tell, this *is* a valid URI according to RFC 2396 and >>> RFC 3986. It works in Mono. It works in other languages. I think >>> .NET's URI parser is busted (Framework 4.5). >> >> On 12 November 2015 at 10:32, Thomas Koster <tkos...@gmail.com> wrote: >>> Using UriBuilder to create this Uri is also broken. Try this: >>> >>> var ub = new UriBuilder(); >>> ub.Scheme = "net.tcp"; >>> ub.UserName = "guest"; >>> ub.Password = "guest"; >>> ub.Host = "myserver"; >>> ub.Port = 12345; >>> >>> The Uri property getter for ub throws the same UriFormatException as above. >> >> On 12 November 2015 at 12:52, Mark Hurd <markeh...@gmail.com> wrote: >>> Yeah, I tried a couple of variations on >>> >>> var ub = new UriBuilder("net+tcp://guest:guest@myserver:12345/") >>> ub.Scheme = "net.tcp" >>> >>> and ub.Uri property throws as you mention. >> >> This means UriBuilder is implementing the Uri property with something >> silly like this: >> >> public Uri Uri >> { >> get >> { >> return new Uri(ToString()); >> } >> } >> >> This suspicion is confirmed by the reference sources[1]. >> >> The round-trip via string is wasteful and unnecessary and spreads the >> parsing bug in Uri over the UriBuilder class as well. UriBuilder >> should be able to trivially construct a Uri instance without parsing >> or round-tripping via string. >> >> Speaking of reference sources, I had a quick scan over the parsing >> code here[2]. OMG, it's thousands of lines of manual string twiddling, >> like a kid with no comp sci education might have done. The cyclomatic >> complexity must be astronomical. No wonder it's broken. >> >> [1] >> http://referencesource.microsoft.com/#System/net/System/uribuilder.cs,b59ac7e3edbfe76c >> [2] http://referencesource.microsoft.com/#System/net/System/URI.cs >> >> -- >> Thomas Koster > > > > -- > Regards, > Mark Hurd, B.Sc.(Ma.)(Hons.) -- Regards, Mark Hurd, B.Sc.(Ma.)(Hons.)