Bug 57708 - Increase strong typing for some APIs.
Summary: Increase strong typing for some APIs.
Status: CONFIRMED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll (show other bugs)
Version: XI 10.99 (xcode9)
Hardware: PC Mac OS
: --- enhancement
Target Milestone: Xcode9
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-06-23 02:04 UTC by Miguel de Icaza [MSFT]
Modified: 2017-06-23 04:17 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 for Bug 57708 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Miguel de Icaza [MSFT] 2017-06-23 02:04:58 UTC
Apple started introducing in a handful of places new typedefs for NSString to be able to tag valid parameters, for example this:

+typedef NSString * NSAttributedStringDocumentType NS_EXTENSIBLE_STRING_ENUM;
+
 // Supported document types for the NSDocumentTypeDocumentAttribute key in the document attributes dictionary.
-UIKIT_EXTERN NSString * const NSPlainTextDocumentType NS_AVAILABLE(10_0, 7_0);
-UIKIT_EXTERN NSString * const NSRTFTextDocumentType NS_AVAILABLE(10_0, 7_0);
-UIKIT_EXTERN NSString * const NSRTFDTextDocumentType NS_AVAILABLE(10_0, 7_0);
-UIKIT_EXTERN NSString * const NSHTMLTextDocumentType NS_AVAILABLE(10_0, 7_0);
+UIKIT_EXTERN NSAttributedStringDocumentType const NSPlainTextDocumentType NS_AVAILABLE(10_0, 7_0);
+UIKIT_EXTERN NSAttributedStringDocumentType const NSRTFTextDocumentType  NS_AVAILABLE(10_0, 7_0);
+UIKIT_EXTERN NSAttributedStringDocumentType const NSRTFDTextDocumentType NS_AVAILABLE(10_0, 7_0);
+UIKIT_EXTERN NSAttributedStringDocumentType const NSHTMLTextDocumentType  NS_AVAILABLE(10_0, 7_0);
+
+typedef NSString * NSTextLayoutSectionKey NS_STRING_ENUM;
 
We currently surface those as NSStrings, it would be easy to make the generator expose these NSString values as the more derived type NSAttributedStringDocumentType" in a few places.   We have most of the code in place.

Now due to the API compatibility, the challenge is that we would break the API if we changed the consuming API.   So we would probably have to do some Obsolete dance.   The problem really is that in the short term, the override methods could not be stronger.

Now - we do not usually have this problem because we provide alternative even stronger typed APIs in a few places, but this is a nice to have.
Comment 1 Miguel de Icaza [MSFT] 2017-06-23 02:34:39 UTC
Types as I find them:

NSAttributedStringKey 
NSTextEffectStyle
NSAttributedStringDocumentType
NSTextLayoutSectionKey
NSAttributedStringDocumentAttributeKey
NSAttributedStringDocumentReadingOptionKey

Searching for a few of these new changes where these parameters are in some new strong typed NSDictionary types, we do not have strong typed equivalents.   We should look into adding some [Wrap] version of the methods so that we can provide some strong typed versions.
Comment 2 Alex Soto [MSFT] 2017-06-23 04:17:05 UTC
We can use SmartEnums[1] + WrapAttribute in order to achieve this

https://github.com/xamarin/xamarin-macios/blob/master/docs/website/binding_types_reference_guide.md#enum-attributes