Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CppSharp.Runtime.UTF8Marshaller Included in generated source #1833

Open
parksj10 opened this issue Feb 21, 2024 · 1 comment
Open

CppSharp.Runtime.UTF8Marshaller Included in generated source #1833

parksj10 opened this issue Feb 21, 2024 · 1 comment

Comments

@parksj10
Copy link

parksj10 commented Feb 21, 2024

Brief Description

I'm trying to following the only example I could find here and I'm getting generated output. However, the generated source is depending on CppSharp the Std.cs file

OS: Windows / OS X / Linux (include version and/or distro)

Linux, Ubuntu 22.04

Used headers

#include <array>
#include <filesystem>
#include <memory>
#include <tuple>

Used settings

options.GeneratorKind = GeneratorKind.CSharp;
parserOptions.AddArguments("-fcxx-exceptions");
options.OutputDir = Path.Combine(Directory.GetCurrentDirectory(), "src", "Interop", "XXXX");

Compiler

Target: gcc

Language

C++11

Stack trace or incompilable generated code

error CS0246: The type or namespace name 'CppSharp' could not be found (are you missing a using directive or an assembly reference?)

from generated code:

    public unsafe static partial class BasicStringExtensions
    {
        public partial struct __Internal
        {

            [SuppressUnmanagedCodeSecurity, DllImport("Std-symbols", EntryPoint = "_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6assignEPKc", CallingConvention = __CallingConvention.Cdecl)]
            internal static extern __IntPtr Assign(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string __s);

        }

################################################################################

Not seeing why any reference to CppSharp should be included in codegen output, but I'm guessing it's some dumb error I'm making. Any help much appreciated!!!! Also, if you know of a solid example repo I can adapt, I'd be more than happy to try and reproduce off of that.

@vicobill
Copy link

vicobill commented Mar 28, 2024

Any update?? Same question, why CppSharp.Runtime.UTF8Marshaller in generated code? like:

 [SuppressUnmanagedCodeSecurity, DllImport("gif", EntryPoint = "EGifOpenFileName", CallingConvention = __CallingConvention.Cdecl)]
 internal static extern __IntPtr EGifOpenFileName([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string GifFileName, bool GifTestExistence, int* Error);

Can I only use StringBuilder?

@see https://learn.microsoft.com/en-us/dotnet/framework/interop/default-marshalling-for-strings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants