Bug 43640 - Subtypes of UIGraphicsRendererFormat should return type-specific object from static DefaultFormat, not base-class implementation
Summary: Subtypes of UIGraphicsRendererFormat should return type-specific object from ...
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 9.99 (iOS 10 previews)
Hardware: PC Mac OS
: Normal normal
Target Milestone: Xcode8 (iOS10)
Assignee: Sebastien Pouliot
Depends on:
Reported: 2016-08-22 23:36 UTC by Larry O'Brien
Modified: 2016-08-25 18:24 UTC (History)
4 users (show)

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:

Description Larry O'Brien 2016-08-22 23:36:16 UTC
In the current binding:

var f = (UIGraphicsImageRendererFormat) UIGraphicsImageRendererFormat.DefaultFormat;

throws an InvalidCastException but in Swift:

var s = UIGraphicsImageRendererFormat.default()

works fine. 

I think the subtypes of UIGraphicsRendererFormat need to 'new' the DefaultFormat property and have it return an instance of the subtype.
Comment 1 Sebastien Pouliot 2016-08-22 23:58:00 UTC
It looks like it. It's not clear, at least I did not find documentation beside the headers, but UIGraphicsRenderer is abstract 

> /*
>  An abstract base class for creating graphics renderers. Do not use this class directly.
>  */
> NS_CLASS_AVAILABLE_IOS(10_0) @interface UIGraphicsRenderer : NSObject

and I suspect its sibling types, UIGraphicsRendererFormat and UIGraphicsRendererContext, should also be abstract.
Comment 2 Sebastien Pouliot 2016-08-23 01:22:34 UTC
Not sure enough about UIGraphicsRendererFormat and UIGraphicsRendererContext as they seems to work... but UIGraphicsRenderer was made abstract.

Both subclasses of UIGraphicsRendererFormat also redefine (new) the static property so they return `instancetype`

Comment 3 Sebastien Pouliot 2016-08-23 15:03:21 UTC
Fixed in xamarin-macios/xcode8 f63ecd7a21161bae43e162114cbd6e14dda8fc4e
Comment 4 Oleg Demchenko 2016-08-25 18:24:32 UTC
Verified with XI