Brad Moore
Brad Moore

Reputation: 356

Binding Mixpanel for Xamarin.iOS, issues with objective-c category type

I am trying to update my Xamarin Mixpanel iOS bindings that I have here. While updating I figured I'd try re-enable a thing I had disabled before I continue to roll out updates all the way to the latest 5.0 release.

Current status is I am attempting to bind v3.6.2 (which is a little outdated) and I am having issues with the binding of some protocol/interface things. The source file that is being bound is MixpanelType.h.

A short example of this is

@protocol MixpanelType <NSObject>

- (BOOL)equalToMixpanelType:(id<MixpanelType>)rhs;

@end

@interface NSString (MixpanelTypeCategory) <MixpanelType>

@end

The generated code that comes out of objective sharpie looks like this,

    // @protocol MixpanelType <NSObject>
    /*
  Check whether adding [Model] to this declaration is appropriate.
  [Model] is used to generate a C# class that implements this protocol,
  and might be useful for protocols that consumers are supposed to implement,
  since consumers can subclass the generated class instead of implementing
  the generated interface. If consumers are not supposed to implement this
  protocol, then [Model] is redundant and will generate code that will never
  be used.
*/[Protocol]
    [BaseType (typeof(NSObject))]
    interface MixpanelType
    {
        // @required -(BOOL)equalToMixpanelType:(id<MixpanelType>)rhs;
        [Abstract]
        [Export ("equalToMixpanelType:")]
        bool EqualToMixpanelType (MixpanelType rhs);
    }

    // @interface MixpanelTypeCategory (NSString) <MixpanelType>
    [Category]
    [BaseType (typeof(NSString))]
    interface NSString_MixpanelTypeCategory : IMixpanelType
    {
    }

I don't understand Category, Model, or Protocols in objective-c is so I am not entirely sure what it is trying to become. Based on the other things in MixpanelType.h it looks like the code is just trying to allow certain class types to exist.

The code is natively used in a method like this,

- (void)addGroup:(NSString *)groupKey groupID:(id<MixpanelType>)groupID {

which gets bound automatically to look like:

// -(void)addGroup:(NSString * _Nonnull)groupKey groupID:(id<MixpanelType> _Nonnull)groupID;
[Export ("addGroup:groupID:")]
void AddGroup (string groupKey, MixpanelType groupID);

I am unsure if MixpanelType is meant to be IMixpanelType and I am unsure if things like NSString_MixpanelTypeCategory are meant to exist.

Keeping it as above (but changing MixpanelType to `IMixpanelType) and attempting to compile I get the following errors:

Xam.Plugin.Mixpanel.iOS/NSString_MixpanelTypeCategory.g.cs(51,69,51,83): error CS0714: 'NSString_MixpanelTypeCategory': static classes cannot implement interfaces
Xam.Plugin.Mixpanel.iOS/NSString_MixpanelTypeCategory.g.cs(51,69,51,83): error CS0535: 'NSString_MixpanelTypeCategory' does not implement interface member 'IIMixpanelType.EqualToMixpanelType(IMixpanelType)'
Xam.Plugin.Mixpanel.iOS/NSString_MixpanelTypeCategory.g.cs(51,69,51,83): error CS0535: 'NSString_MixpanelTypeCategory' does not implement interface member 'INativeObject.Handle'
Xam.Plugin.Mixpanel.iOS/NSString_MixpanelTypeCategory.g.cs(51,69,51,83): error CS0535: 'NSString_MixpanelTypeCategory' does not implement interface member 'IDisposable.Dispose()'

The first error is odd as this isn't a static class.

The second error is odd and I can't get rid of it by implementing the method.

The third and fourth errors are odd because this class has a base type of NSString and I thought this would have been handled.

Any help on this so I can successfully bind the entire library without MixpanelGroups being disabled would be appreciated.

Upvotes: 0

Views: 119

Answers (0)

Related Questions