I have encountered an interesting situation where I get NRE
from Uri.TryCreate
method when it's supposed to return false
.
You can reproduce the issue like below:
Uri url;
if (Uri.TryCreate("http:Ç", UriKind.RelativeOrAbsolute, out url))
{
Console.WriteLine("success");
}
I guess it's failing during the parse, but when I try "http:A"
for example, it returns true
and parses it as relative url. Even if fails on parse it should just return false
as I understand, what could be the problem here? This seems like a bug in the implementation cause documentation doesn't mention about any exception on this method.
The error occurs in .NET 4.6.1 but not 4.0