Bug 40282 - Wrong access modifier for extensions generated for internal protocol from ApiDefinitions
Summary: Wrong access modifier for extensions generated for internal protocol from Api...
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 9.6 (iOS 9.3)
Hardware: Macintosh Mac OS
: --- minor
Target Milestone: Untriaged
Assignee: Alex Soto [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2016-04-11 18:46 UTC by igofed
Modified: 2016-04-13 19:57 UTC (History)
3 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 igofed 2016-04-11 18:46:34 UTC
I would like to hide protocol with unsafe arrays and provide "good" protocol to my consumers, so I try to do my protocol [Internal] in ApiDefinitions.cs:

[Internal]
[Protocol(Name = "PBDataLoggingServiceDelegate"), Model]
[BaseType (typeof(NSObject))]
interface PBDataLoggingServiceDelegateInternal
{
    //  // @optional -(BOOL)dataLoggingService:(PBDataLoggingService * _Nonnull)service hasUInt32s:(const UInt32 *)data numberOfItems:(UInt16)numberOfItems forDataLoggingSession:(PBDataLoggingSessionMetadata * _Nonnull)session;
    [Export ("dataLoggingService:hasUInt32s:numberOfItems:forDataLoggingSession:")]
    bool DataLoggingServiceUInt32 (PBDataLoggingService service, IntPtr data, ushort numberOfItems, PBDataLoggingSessionMetadata session);

    //  // @optional -(BOOL)dataLoggingService:(PBDataLoggingService * _Nonnull)service hasSInt16s:(const SInt16 *)data numberOfItems:(UInt16)numberOfItems forDataLoggingSession:(PBDataLoggingSessionMetadata * _Nonnull)session;
    [Export ("dataLoggingService:hasSInt16s:numberOfItems:forDataLoggingSession:")]
    bool DataLoggingServiceSInt16 (PBDataLoggingService service, IntPtr data, ushort numberOfItems, PBDataLoggingSessionMetadata session);

    // @optional -(void)dataLoggingService:(PBDataLoggingService * _Nonnull)service sessionDidFinish:(PBDataLoggingSessionMetadata * _Nonnull)session;
    [Export ("dataLoggingService:sessionDidFinish:")]
    void DataLoggingService (PBDataLoggingService service, PBDataLoggingSessionMetadata session);
}
But I have issues with that, as automatically generated PBDataLoggingServiceDelegateInternal.g.cs in obj has following strange code:

public static partial class PBDataLoggingServiceDelegateInternal_Extensions {
    [CompilerGenerated]
    public static bool DataLoggingServiceUInt32 (this IPBDataLoggingServiceDelegateInternal This, PBDataLoggingService service, global::System.IntPtr data, global::System.UInt16 numberOfItems, PBDataLoggingSessionMetadata session)
    {
        if (service == null)
            throw new ArgumentNullException ("service");
        if (session == null)
            throw new ArgumentNullException ("session");
        return global::ApiDefinitions.Messaging.bool_objc_msgSend_IntPtr_IntPtr_UInt16_IntPtr (This.Handle, Selector.GetHandle ("dataLoggingService:hasUInt32s:numberOfItems:forDataLoggingSession:"), service.Handle, data, numberOfItems, session.Handle);
    }

    [CompilerGenerated]
    public static bool DataLoggingServiceSInt16 (this IPBDataLoggingServiceDelegateInternal This, PBDataLoggingService service, global::System.IntPtr data, global::System.UInt16 numberOfItems, PBDataLoggingSessionMetadata session)
    {
        if (service == null)
            throw new ArgumentNullException ("service");
        if (session == null)
            throw new ArgumentNullException ("session");
        return global::ApiDefinitions.Messaging.bool_objc_msgSend_IntPtr_IntPtr_UInt16_IntPtr (This.Handle, Selector.GetHandle ("dataLoggingService:hasSInt16s:numberOfItems:forDataLoggingSession:"), service.Handle, data, numberOfItems, session.Handle);
    }

    [CompilerGenerated]
    public static void DataLoggingService (this IPBDataLoggingServiceDelegateInternal This, PBDataLoggingService service, PBDataLoggingSessionMetadata session)
    {
        if (service == null)
            throw new ArgumentNullException ("service");
        if (session == null)
            throw new ArgumentNullException ("session");
        global::ApiDefinitions.Messaging.void_objc_msgSend_IntPtr_IntPtr (This.Handle, Selector.GetHandle ("dataLoggingService:sessionDidFinish:"), service.Handle, session.Handle);
    }

}
Generated extension class has public access and public extension methods instead of internal access like generated protocol class and interface. This lead to compile time error 
Error CS0051: Inconsistent accessibility: parameter type `PebbleKit.IPBDataLoggingServiceDelegateInternal' is less accessible than method `PebbleKit.PBDataLoggingServiceDelegateInternal_Extensions.DataLoggingServiceHasByteArrays(this PebbleKit.IPBDataLoggingServiceDelegateInternal, PebbleKit.PBDataLoggingService, System.IntPtr, ushort, PebbleKit.PBDataLoggingSessionMetadata)
Comment 1 Rolf Bjarne Kvinge [MSFT] 2016-04-12 08:51:55 UTC
I think the [Internal] attribute should apply to any _Extensions classes as well.

Alex, can you have a look at this?
Comment 2 Alex Soto [MSFT] 2016-04-13 19:57:09 UTC
Fixed in maccore/master @ 3bfa8ef010b104ab4b1df492853027ab32e95b72