CppSharp.Runtime.UTF8Marshaller Included in generated source

Open
#1,833 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp, csharp
Domain
tooling

Research direction

Start with docs/GeneratingBindings.md and the generated Std.cs output described in the report. Trace why UTF8Marshaller is emitted and compare the generated source's runtime dependencies with the documented example; done means the reported generated code has a clear, compilable dependency path without an unresolved CppSharp reference.

Written by the indexing model from the issue text.

Description

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.

Dominant language
C#
Stars
3.4k
Forks
541
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mono/CppSharp

All issues in mono/CppSharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.