@@ -3942,6 +3942,22 @@ AvailabilityBaseAttribute GetIntroduced (MethodInfo mi, PropertyInfo pi)
39423942 return mi . GetAvailability ( AvailabilityKind . Introduced ) ?? pi . GetAvailability ( AvailabilityKind . Introduced ) ;
39433943 }
39443944
3945+ bool Is64BitiOSOnly ( ICustomAttributeProvider provider )
3946+ {
3947+ if ( BindThirdPartyLibrary )
3948+ return false ;
3949+ if ( BindingTouch . CurrentPlatform != PlatformName . iOS )
3950+ return false ;
3951+ var attrib = provider . GetAvailability ( AvailabilityKind . Introduced ) ;
3952+ if ( attrib == null ) {
3953+ var minfo = provider as MemberInfo ;
3954+ if ( minfo != null && minfo . DeclaringType != null )
3955+ return Is64BitiOSOnly ( minfo . DeclaringType ) ;
3956+ return false ;
3957+ }
3958+ return attrib . Version . Major >= 11 ;
3959+ }
3960+
39453961 //
39463962 // Generates the code necessary to lower the MonoTouch-APIs to something suitable
39473963 // to be passed to Objective-C.
@@ -4754,6 +4770,12 @@ void GenerateProperty (Type type, PropertyInfo pi, List<string> instance_fields_
47544770 print ( "get; " ) ;
47554771 } else {
47564772 print ( "get {" ) ;
4773+ var is32BitNotSupported = Is64BitiOSOnly ( pi ) ;
4774+ if ( is32BitNotSupported ) {
4775+ print ( "#if ARCH_32" ) ;
4776+ print ( "\t throw new PlatformNotSupportedException (\" This API is not supported on this version of iOS\" );" ) ;
4777+ print ( "#else" ) ;
4778+ }
47574779 if ( debug )
47584780 print ( "Console.WriteLine (\" In {0}\" );" , pi . GetGetMethod ( ) ) ;
47594781 if ( is_model )
@@ -4778,6 +4800,8 @@ void GenerateProperty (Type type, PropertyInfo pi, List<string> instance_fields_
47784800 indent -- ;
47794801 }
47804802 }
4803+ if ( is32BitNotSupported )
4804+ print ( "#endif" ) ;
47814805 print ( "}\n " ) ;
47824806 }
47834807 }
@@ -4805,6 +4829,12 @@ void GenerateProperty (Type type, PropertyInfo pi, List<string> instance_fields_
48054829 print ( "set; " ) ;
48064830 } else {
48074831 print ( "set {" ) ;
4832+ var is32BitNotSupported = Is64BitiOSOnly ( pi ) ;
4833+ if ( is32BitNotSupported ) {
4834+ print ( "#if ARCH_32" ) ;
4835+ print ( "\t throw new PlatformNotSupportedException (\" This API is not supported on this version of iOS\" );" ) ;
4836+ print ( "#else" ) ;
4837+ }
48084838 if ( debug )
48094839 print ( "Console.WriteLine (\" In {0}\" );" , pi . GetSetMethod ( ) ) ;
48104840
@@ -4830,6 +4860,8 @@ void GenerateProperty (Type type, PropertyInfo pi, List<string> instance_fields_
48304860 }
48314861 }
48324862 }
4863+ if ( is32BitNotSupported )
4864+ print ( "#endif" ) ;
48334865 print ( "}" ) ;
48344866 }
48354867 }
@@ -5213,6 +5245,13 @@ void GenerateMethod (MemberInformation minfo)
52135245 }
52145246
52155247 print ( "{" ) ;
5248+
5249+ var is32BitNotSupported = Is64BitiOSOnly ( ( ICustomAttributeProvider ) minfo . method ?? minfo . property ) ;
5250+ if ( is32BitNotSupported ) {
5251+ print ( "#if ARCH_32" ) ;
5252+ print ( "\t throw new PlatformNotSupportedException (\" This API is not supported on this version of iOS\" );" ) ;
5253+ print ( "#else" ) ;
5254+ }
52165255 if ( debug )
52175256 print ( "\t Console.WriteLine (\" In {0}\" );" , mi ) ;
52185257
@@ -5237,6 +5276,8 @@ void GenerateMethod (MemberInformation minfo)
52375276 indent -- ;
52385277 }
52395278 }
5279+ if ( is32BitNotSupported )
5280+ print ( "#endif" ) ;
52405281 print ( "}\n " ) ;
52415282 }
52425283
@@ -6177,6 +6218,7 @@ public void Generate (Type type)
61776218 var initSelector = ( InlineSelectors || BindThirdPartyLibrary ) ? "Selector.GetHandle (\" init\" )" : "Selector.Init" ;
61786219 var initWithCoderSelector = ( InlineSelectors || BindThirdPartyLibrary ) ? "Selector.GetHandle (\" initWithCoder:\" )" : "Selector.InitWithCoder" ;
61796220 string v = UnifiedAPI && class_mod == "abstract " ? "protected" : ctor_visibility ;
6221+ var is32BitNotSupported = Is64BitiOSOnly ( type ) ;
61806222 if ( external ) {
61816223 if ( ! disable_default_ctor ) {
61826224 GeneratedCode ( sw , 2 ) ;
@@ -6188,12 +6230,19 @@ public void Generate (Type type)
61886230 sw . WriteLine ( "\t \t [Export (\" init\" )]" ) ;
61896231 sw . WriteLine ( "\t \t {0} {1} () : base (NSObjectFlag.Empty)" , v , TypeName ) ;
61906232 sw . WriteLine ( "\t \t {" ) ;
6233+ if ( is32BitNotSupported ) {
6234+ sw . WriteLine ( "\t \t #if ARCH_32" ) ;
6235+ sw . WriteLine ( "\t throw new PlatformNotSupportedException (\" This API is not supported on this version of iOS\" );" ) ;
6236+ sw . WriteLine ( "\t \t #else" ) ;
6237+ }
61916238 if ( is_direct_binding_value != null )
61926239 sw . WriteLine ( "\t \t \t IsDirectBinding = {0};" , is_direct_binding_value ) ;
61936240 if ( debug )
61946241 sw . WriteLine ( "\t \t \t Console.WriteLine (\" {0}.ctor ()\" );" , TypeName ) ;
61956242 sw . WriteLine ( "\t \t \t InitializeHandle (global::{1}.IntPtr_objc_msgSend (this.Handle, global::{2}.{0}), \" init\" );" , initSelector , ns . Messaging , ns . CoreObjCRuntime ) ;
61966243 sw . WriteLine ( "\t \t \t " ) ;
6244+ if ( is32BitNotSupported )
6245+ sw . WriteLine ( "\t \t #endif" ) ;
61976246 sw . WriteLine ( "\t \t }" ) ;
61986247 }
61996248 } else {
@@ -6207,12 +6256,19 @@ public void Generate (Type type)
62076256 sw . WriteLine ( "\t \t [Export (\" init\" )]" ) ;
62086257 sw . WriteLine ( "\t \t {0} {1} () : base (NSObjectFlag.Empty)" , v , TypeName ) ;
62096258 sw . WriteLine ( "\t \t {" ) ;
6259+ if ( is32BitNotSupported ) {
6260+ sw . WriteLine ( "\t \t #if ARCH_32" ) ;
6261+ sw . WriteLine ( "\t throw new PlatformNotSupportedException (\" This API is not supported on this version of iOS\" );" ) ;
6262+ sw . WriteLine ( "\t \t #else" ) ;
6263+ }
62106264 var indentation = 3 ;
62116265 WriteIsDirectBindingCondition ( sw , ref indentation , is_direct_binding , is_direct_binding_value ,
62126266 ( ) => string . Format ( "InitializeHandle (global::{1}.IntPtr_objc_msgSend (this.Handle, global::{2}.{0}), \" init\" );" , initSelector , ns . Messaging , ns . CoreObjCRuntime ) ,
62136267 ( ) => string . Format ( "InitializeHandle (global::{1}.IntPtr_objc_msgSendSuper (this.SuperHandle, global::{2}.{0}), \" init\" );" , initSelector , ns . Messaging , ns . CoreObjCRuntime ) ) ;
62146268
62156269 WriteMarkDirtyIfDerived ( sw , type ) ;
6270+ if ( is32BitNotSupported )
6271+ sw . WriteLine ( "\t \t #endif" ) ;
62166272 sw . WriteLine ( "\t \t }" ) ;
62176273 sw . WriteLine ( ) ;
62186274 }
@@ -6229,6 +6285,11 @@ public void Generate (Type type)
62296285 sw . WriteLine ( "\t \t [Export (\" initWithCoder:\" )]" ) ;
62306286 sw . WriteLine ( "\t \t {0} {1} (NSCoder coder) : base (NSObjectFlag.Empty)" , UnifiedAPI ? v : "public" , TypeName ) ;
62316287 sw . WriteLine ( "\t \t {" ) ;
6288+ if ( is32BitNotSupported ) {
6289+ sw . WriteLine ( "\t \t #if ARCH_32" ) ;
6290+ sw . WriteLine ( "\t throw new PlatformNotSupportedException (\" This API is not supported on this version of iOS\" );" ) ;
6291+ sw . WriteLine ( "\t \t #else" ) ;
6292+ }
62326293 if ( nscoding ) {
62336294 if ( debug )
62346295 sw . WriteLine ( "\t \t \t Console.WriteLine (\" {0}.ctor (NSCoder)\" );" , TypeName ) ;
@@ -6241,6 +6302,8 @@ public void Generate (Type type)
62416302 } else {
62426303 sw . WriteLine ( "\t \t \t throw new InvalidOperationException (\" Type does not conform to NSCoding\" );" ) ;
62436304 }
6305+ if ( is32BitNotSupported )
6306+ sw . WriteLine ( "\t \t #endif" ) ;
62446307 sw . WriteLine ( "\t \t }" ) ;
62456308 sw . WriteLine ( ) ;
62466309 }
@@ -6250,18 +6313,32 @@ public void Generate (Type type)
62506313 sw . WriteLine ( "\t \t [EditorBrowsable (EditorBrowsableState.Advanced)]" ) ;
62516314 sw . WriteLine ( "\t \t {0} {1} (NSObjectFlag t) : base (t)" , UnifiedAPI ? "protected" : "public" , TypeName ) ;
62526315 sw . WriteLine ( "\t \t {" ) ;
6316+ if ( is32BitNotSupported ) {
6317+ sw . WriteLine ( "\t \t #if ARCH_32" ) ;
6318+ sw . WriteLine ( "\t \t \t throw new PlatformNotSupportedException (\" This API is not supported on this version of iOS\" );" ) ;
6319+ sw . WriteLine ( "\t \t #else" ) ;
6320+ }
62536321 if ( is_direct_binding_value != null )
62546322 sw . WriteLine ( "\t \t \t IsDirectBinding = {0};" , is_direct_binding_value ) ;
62556323 WriteMarkDirtyIfDerived ( sw , type ) ;
6324+ if ( is32BitNotSupported )
6325+ sw . WriteLine ( "\t \t #endif" ) ;
62566326 sw . WriteLine ( "\t \t }" ) ;
62576327 sw . WriteLine ( ) ;
62586328 }
62596329 GeneratedCode ( sw , 2 ) ;
62606330 sw . WriteLine ( "\t \t [EditorBrowsable (EditorBrowsableState.Advanced)]" ) ;
62616331 sw . WriteLine ( "\t \t {0} {1} (IntPtr handle) : base (handle)" , UnifiedAPI ? "protected internal" : "public" , TypeName ) ;
62626332 sw . WriteLine ( "\t \t {" ) ;
6333+ if ( is32BitNotSupported ) {
6334+ sw . WriteLine ( "\t \t #if ARCH_32" ) ;
6335+ sw . WriteLine ( "\t \t \t throw new PlatformNotSupportedException (\" This API is not supported on this version of iOS\" );" ) ;
6336+ sw . WriteLine ( "\t \t #else" ) ;
6337+ }
62636338 if ( is_direct_binding_value != null )
62646339 sw . WriteLine ( "\t \t \t IsDirectBinding = {0};" , is_direct_binding_value ) ;
6340+ if ( is32BitNotSupported )
6341+ sw . WriteLine ( "\t \t #endif" ) ;
62656342 WriteMarkDirtyIfDerived ( sw , type ) ;
62666343 sw . WriteLine ( "\t \t }" ) ;
62676344 sw . WriteLine ( ) ;
0 commit comments