When does Uri.CheckHostName() return UriHostNameType.Basic instead of UriHostNameType.Dns or UriHostNameType.Unknown?
Now the .NET Core is open source we can know for sure.
Just like Mono, it never returns UriHostNameType.Basic
.
Link to source code
It occurred to me that I could just check the Mono source code to answer my question. Here is the CheckHostName
method from https://github.com/mono/mono/blob/master/mcs/class/System/System/Uri.cs:
public static UriHostNameType CheckHostName (string name)
{
if (name == null || name.Length == 0)
return UriHostNameType.Unknown;
if (IsIPv4Address (name))
return UriHostNameType.IPv4;
if (IsDomainAddress (name))
return UriHostNameType.Dns;
IPv6Address addr;
if (IPv6Address.TryParse (name, out addr))
return UriHostNameType.IPv6;
return UriHostNameType.Unknown;
}
It appears that UriHostNameType.Basic
isn't used at all. Maybe the Microsoft implementation can return this value?