I want to generate a C# interface using SWIG 3.0.12. For public functions this works as expected. However if I try to add properties to the interface they are not part of the generated interface.
Is it possible to tell SWIG to add properties to the public interface?
Here is a minimal example:
My C++ class looks like:
class IA
{
public:
virtual std::string GetX() = 0;
virtual void SetX(const std::string& x) = 0;
virtual void MyFunction() = 0;
};
Using the following interface file:
%module example
%{
#include "IA.h"
%}
%include <std_string.i>
%include <attribute.i>
%include <swiginterface.i>
%attribute(IA, std::string, X, GetX, SetX);
%interface(IA);
%include "IA.h"
The generated IA.cs looks like:
public virtual void MyFunction() {
examplePINVOKE.IA_MyFunction(swigCPtr);
}
public string X {
set {
examplePINVOKE.IA_X_set(swigCPtr, value);
if (examplePINVOKE.SWIGPendingException.Pending) throw examplePINVOKE.SWIGPendingException.Retrieve();
}
get {
string ret = examplePINVOKE.IA_X_get(swigCPtr);
if (examplePINVOKE.SWIGPendingException.Pending) throw examplePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
The generated IASwigInterface.cs looks like:
public interface IASwigInterface {
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
global::System.Runtime.InteropServices.HandleRef GetInterfaceCPtr();
void MyFunction();
}
What I would expect SWIG to generate for the IASwigInterface.cs is something like:
public interface IASwigInterface {
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
global::System.Runtime.InteropServices.HandleRef GetInterfaceCPtr();
void MyFunction();
string X { get; set; } //<- I want the property to be part of the interface
}
Does anyone know how this can be achieved?