Bug 13069 - protocol, host, port lost in Uri to NSUrl implicit conversion
Summary: protocol, host, port lost in Uri to NSUrl implicit conversion
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 6.2.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2013-07-05 08:35 UTC by Andrew
Modified: 2013-07-05 16:15 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Andrew 2013-07-05 08:35:44 UTC
Here's an example:

var u = new Uri("http://google.com");
var ns1 = (NSUrl)u;
var ns2 = new NSUrl(u.ToString());

Console.Out.WriteLine("ns1: " + ns1);
Console.Out.WriteLine("ns2: " + ns2);

Executed in iOS 6.1 simulator:

//ns1: /
//ns2: http://google.com/

---------------
Xamarin.iOS
Version: 6.2.7.1 (Business Edition)
Hash: 947e664
Branch: 
Build date: 2013-30-05 18:02:40-0400
Comment 1 Andrew 2013-07-05 08:41:49 UTC
Looks like it should be uri.AbsoluteUri or uri.ToString() in the code, instead of uri.AbsolutePath:

public static implicit operator NSUrl(Uri uri)
{
  if (uri.IsAbsoluteUri)
	return new NSUrl(uri.AbsolutePath);
  else
	return new NSUrl(uri.PathAndQuery);
}
Comment 2 Sebastien Pouliot 2013-07-05 15:52:42 UTC
Right, that looks like a code-completion induced bug.
Comment 3 Sebastien Pouliot 2013-07-05 16:15:44 UTC
Fixed in d58b08216205d99ba9e90db1c51b69075af7ac89
QA: unit tests added in the same revision