Bug 25231 - [iOS] 'AddMinutes' method is missing in NSDate Class after migrating sample by Xamarin.Mac Migration API tool.
Summary: [iOS] 'AddMinutes' method is missing in NSDate Class after migrating sample b...
Status: VERIFIED NOT_ON_ROADMAP
Alias: None
Product: iOS
Classification: Xamarin
Component: Samples ()
Version: XI 8.6.0
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: GouriKumari
URL:
Depends on:
Blocks:
 
Reported: 2014-12-10 09:55 UTC by Shruti
Modified: 2014-12-11 15:56 UTC (History)
5 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:
VERIFIED NOT_ON_ROADMAP

Description Shruti 2014-12-10 09:55:00 UTC

    
Comment 2 Sebastien Pouliot 2014-12-10 19:18:37 UTC
There never was a AddMinutes method on NSDate, even in classic. However there's one on .NET DateTime [1].

What happens is that we replaced the implicit cast with an explicit cast (because it's not always a lossless conversion).

That means you cannot do:

   NSDateTime dt = NSDateTime.Now.AddMinutes (x);

anymore. You need to do:

  NSDateTime dt = (NSDateTime) ((DateTime) NSDateTime.Now).AddMinutes (x);

or something cuter to avoid extra, not really required, conversions.

  NSDateTime dt = (NSDateTime) DateTime.Now.AddMinutes (x);

That's better since (even implicit) cast means extra code (and cost) to convert between the two types.

In any case that's a sample, not a class library, issue.

[1] http://msdn.microsoft.com/en-us/library/system.datetime.addminutes%28v=vs.110%29.aspx
Comment 3 Shruti 2014-12-11 00:33:14 UTC
Thanks Sebastien for describing the cause in detail.  As per comment2 , I am closing this issue.
Comment 4 Sebastien Pouliot 2014-12-11 08:17:53 UTC
Not sure you should be closing it. Comment #2 is just a description / clarification of the issue, not that there's no issues. IOW It's still a bug in the sample that needs to be fixed. 

@PJ ?
Comment 5 PJ 2014-12-11 15:56:45 UTC
> IOW It's still a bug in the sample that needs to be fixed. 

Normally this would be true, and I appreciate you double-checking! 

The sample in question has been updated on the branch intended for stable publishing to use the explicit cast, see https://github.com/xamarin/monotouch-samples/blob/monotouch-8.6-unified-api/Calendars/Calendars/Screens/Home/HomeController.cs#L138.

In this particular case Shruti is verifying the behavior of the API while testing the migration tool, so I think we can leave it VERIFIED. If the migration tool should be able to handle this scenario, we can REOPEN the bug (and move it to XS->iOS Add-in), but it's not currently part of the expected behavior.

Thanks Shruti and Sebastien!