You can create the code you are looking for using %typemap(csout) . This is a bit of a hack, and you will need to copy some existing sample maps for SWIGTYPE (which is the common owner of the place), which can be found in csharp.swg
So, for example, given the header file example.h:
struct SomeObject {}; struct MyClass { static SomeObject test(); };
Then you can write the following SWIG interface file:
%module Test %{ #include "example.h" %} %typemap(csout,excode=SWIGEXCODE) SomeObject {
What produces:
public static SomeObject test() {
If you want to generate this for all types of return values, and not just for the things that SomeObject returns, you will have a little more work for all csout options.
source share