- 
                Notifications
    You must be signed in to change notification settings 
- Fork 561
Closed
Labels
Area: BindingsIssues in Java Library Binding projects.Issues in Java Library Binding projects.
Description
Android application type
Classic Xamarin.Android (MonoAndroid12.0, etc.)
Affected platform version
VS 2022 17.2.4
Description
The binding tools seem to ignore default instance interface methods when generating the C# interface.
For example, for the following Java interface:
package com.example.calculator;
public interface Calculator {
    default int Add(int a, int b) {
        return a + b;
    }
    
    int Subtract(int a, int b);
}
This is the C# interface that is generated:
public interface ICalculator {
    int Subtract(int a, int b);
}
Steps to Reproduce
- Create a new file: Calculator.java
- Paste the Java interface code written in the description into the file.
- Open a terminal in the folder containing Calculator.java
- Run javac Calculator.java && jar -cf Calculator.jar Calculator.class. You should see a Calculator.jar file afterwards.
- Create a new Android Binding Project and add Calculator.jar to it.
- Build the project.
- Open the Object Browser (View > Object Browser), click the dropdown at the top of the window, and clickMy Solution.
- Find the binding project in the list and find the ICalculator interface in the Com.Example.Calculator namespace, right-click on it and click Go To Definition.
- The interface code will show up, and you'll see that even though there's a Subtract method, no Add method was generated.
Did you find any workaround?
I encountered the issue while creating a binding for the Twilio Conversations Android SDK. The only workaround I could come up with was to manually write the interface method & its invoker implementation.
Relevant log output
No response
Metadata
Metadata
Assignees
Labels
Area: BindingsIssues in Java Library Binding projects.Issues in Java Library Binding projects.