Bug 51299 - UTType.GetDescription throws ArgumentNullException
Summary: UTType.GetDescription throws ArgumentNullException
Status: RESOLVED FIXED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: 2.10.0 (C8)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-01-09 11:46 UTC by juanjo.a
Modified: 2017-01-09 19:02 UTC (History)
2 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 juanjo.a 2017-01-09 11:46:59 UTC
UTType.GetDescription(string uti) in Mobilecoreservices

throws ArgumentNullException when the argument is not null, and does not throw the exception when the argument is null.

Looking at the Xamarin source code /src/MobileCoreServices/UTType.cs

public string GetDescription (string uti)
		{
			if (uti != null)
				throw new ArgumentNullException ("uti");

			var a = NSString.CreateNative (uti);
			var ret = NSString.FromHandle (UTTypeCopyDescription (a));
			NSString.ReleaseNative (a);
			return ret;
		}

It should be 
if (uti == null)
instead
Comment 1 Chris Hamons 2017-01-09 14:59:37 UTC
Woops. You are correct.
Comment 2 Chris Hamons 2017-01-09 15:02:57 UTC
https://github.com/xamarin/xamarin-macios/pull/1455
Comment 3 Chris Hamons 2017-01-09 19:02:25 UTC
Fixed in master and cycle9.

Thanks for the report. This will be fixed in the next major release.