Bug 57708 - Increase strong typing for some APIs.
Summary: Increase strong typing for some APIs.
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
Depends on:
Reported: 2017-06-23 02:04 UTC by Miguel de Icaza [MSFT]
Modified: 2017-06-23 04:17 UTC (History)
2 users (show)

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


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:


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


Note You need to log in before you can comment on or make changes to this bug.