Re: Assignment of native container types to generated types in C#
William S Fulton <[email protected]> Mon, 19 Sep 2022 17:35:17 +0100
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <CANGqftAn3MVe_z27bnwxexKscpEXzG2FkmWz8-B4ngHwqTJ3Cg@mail.gmail.com> |
Let's track this in https://github.com/swig/swig/issues/2367. William On Mon, 12 Sept 2022 at 16:46, Mario Emmenlauer <[email protected]> wrote: > > Dear All, > > I've just started with SWIG and followed the documentation to build > a few first examples. Everything works great! > > Now I have a question: I can not use directly the native C# type in > a method signature that expects the generated type. Am I doing some- > thing wrong, or is that expected? I'm not too knowledgeable with C# > so I have a hard time understanding what is even missing - the > assignment operator maybe? > > The native method expects a `const std::vector<std::string>&`. I name > this `StringVector` in the interface. > > This code illustrates the problem in C#: > string[] cData = { "Hello", "World", "äöü", "ß 是" }; > IList<string> vStringList = new List<string>(cData); > > var vInteropTestNativeWrapper = new InteropTestNativeWrapper(); > > // This does not compile, with error: > // Argument 1: cannot convert from > 'System.Collections.Generic.IList<string>' to 'StringVector' > [InteropTestManaged] > //vInteropTestNativeWrapper.setStringVector(vStringList); > > // This compiles and works, but is a bit more cumbersome: > vInteropTestNativeWrapper.setStringVector(new > StringVector(vStringList)); > > > Is that to be expected, or is there some way in SWIG to use native > types and generated types interchangeable? > > All the best, > > Mario Emmenlauer > > > _______________________________________________ > Swig-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/swig-user > _______________________________________________ Swig-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/swig-user