Binding obj-c to Xamarin: static method in category

descorpdescorp RUUniversity ✭✭

Any ideas how to wrap static method in category into .Net extension ?

Obj-c :

@interface SomeClass (Model) <ModelDelegate> 

+ (void)model:(NSObject<ModelDelegate>*)delegate order:(NSArray*)order;

@end

Sharpie converted it into :

    [Category]
    [BaseType(typeof(SomeClass))]
    interface SomeClass_Model : ModelDelegate
    {
        // +(void)model:(NSObject<ModelDelegate> *)delegate order:(NSArray *)order;
        [Static]
        [Export("model:order:")]
        void Model(ModelDelegate @delegate, NSObject[] order);
    }

Code generator creates :

    public unsafe static partial class SomeClass_Model : IModelDelegate 
    { 
        [Export ("model:order:")]
        [CompilerGenerated]
        public static void Model (this SomeClass This, ModelDelegate @delegate, NSObject[] order)
        { ... }
    }

Which lead to obvious problem - this is instance method, not a static method :smile:

So far, I ended up implementing this methods as part of the class. Problem is in a library I'm binding God-object pattern used with 10+ static extensions.

Any ideas ?

Sign In or Register to comment.