I know how it works, I already do that with other structures
But CSFML is a binding too, so there's no Transform structure in it, only a wrapper around a C++ sf::Transform pointer. So I would have to do the same modification in CSFML, which means duplicating the Transform functions three times. Definitely not the best thing to maintain.
Well, part of the problem seems to be that you have this C binding in-between C# and C++ and I don't know what exactly it's doing which is making things difficult to brainstorm about.
My main ports are that:
1. Transform needs to be a struct.
2. Transform methods should be defined in C# and modify transforms by reference.
3. Transform instances should be sent to C++ by pointer to the C# struct which matches the layout of the C++ struct.
4. Transform instances retrieved from C++ should be copied into a C# struct, not wrapped.
Perhaps you should simply eliminate the C binding in-between and import the functions from the C++ modules directly. You can avoid use of extern "C" too by importing the decorated function names. Making sure that the decorated function names are up to date in the C# binding seems simpler than what we're going through now.
Edit: I just reread your post, and I'm wondering why you think you'd need to do the same modification in CSFML. If the C# struct has the same layout you need only cast that to the wrapper you're using in CSFML and pass that to wherever it needs to be. CSFML shouldn't be able to tell the difference.
Looking at your code, you have:
struct sfTransform
{
sf::Transform This;
};
You just need to pass a C# struct to whatever CSFML functions take a sfTransform* and it should work fine, no? Marshal.PtrToStructure() should help here for copying pointers you get from C/C++ into a new C# struct.