Xamarin: Interface and Protocol inheritance issue.

(BMS) Jack 1 Reputation point
  • Background:
    • I'm using Xamarin: Forms using Visual Studio for Mac.
    • I'm integrating the Brother Print SDK v4.
    • I have successfully used Objective Sharpie and adjusted the ApiDefinitions.cs and Structs.cs files to work with v3 SDK.
    • v4 SDK uses Protocols and Interfaces slightly differently than its predecessor.
  • Problem:
    • I have an interface:
    // @ENA IBRLMPrintSettingsProtocol <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, Model]
    interface IBRLMPrintSettingsProtocol
    // @required -(instancetype _Nullable)initDefaultPrintSettingsWithPrinterModel:(BRLMPrinterModel)model;
    [return: NullAllowed]
    IntPtr initDefaultPrintSettingsWithPrinterModel(BRLMPrinterModel model);
  • I have some code:
    interface BRLMRJPrintSettings : INSCoding, IBRLMPrintSettingsProtocol, IBRLMPrintImageSettings
    { // stuff }
     BRLMRJPrintSettings rjPrintSettings;  
     BRLMChannel brlmChannel;  
     BRLMPrinterDriver printerDriver;  
     BRLMPrinterDriverGenerateResult printerDriverGenerateResult = BRLMPrinterDriverGenerator.OpenChannel(brlmChannel);  
     printerDriver = printerDriverGenerateResult.Driver;  
  • The Problem Code:
    var brlmPrintError = printerDriver.PrintPDFWithURL(fileUri,rjPrintSettings);
  • Definition:
    BRLMPrintError PrintPDFWithURL(NSUrl url, IBRLMPrintSettingsProtocol settings);

My understanding is that the RJPrintSettings object should be "interchangeable" with the IBRLMPrintSettingsProtocol.
However, I get the following:
CS1503: Argument 2: cannot convert from 'iosBinding.BRLMRJPrintSettings' to 'iosBinding.IBRLMPrintSettingsProtocol'

I've done everything I can think of, but have been unable to resolve this issue. Any suggestions?

A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
4,818 questions
No comments
{count} votes