Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

NoWrap questions

未关闭
#37 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
cpp, csharp
领域
tooling

调研方向

Start by reproducing the two NoWrap examples in the issue: the opaque-pointer typedef and the function-pointer typedef, then inspect the corresponding code-generation path. Separately trace how generated function, type, and constant names are chosen. Done means the intended NoWrap behavior and prefix-removal options are agreed and covered by focused generation tests.

由索引模型根据 Issue 内容生成。

描述

question

First off thanks for this incredible library it's mostly easy to use and works well. I do have some questions though regarding the NoWrap option.

  1. When using nowrap for an opaque ptr typedef it still wraps for example:
    typedef struct Test Test;
    Will result in
[global::System.Runtime.InteropServices.StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public readonly partial struct Test : IEquatable<native.Test >
{
    public Test(nint handle) => Handle = handle;
    
    public nint Handle { get; }
    
    public bool Equals(Test other) => Handle.Equals(other.Handle);
    
    public override bool Equals(object obj) => obj is Test other && Equals(other);
    
    public override int GetHashCode() => Handle.GetHashCode();
    
    public override string ToString() => "0x" + (nint.Size == 8 ? Handle.ToString("X16") : Handle.ToString("X8"));
    
    public static bool operator ==(Test left, Test right) => left.Equals(right);
    
    public static bool operator !=(Testleft, Testright) => !left.Equals(right);
}

Is it possible to just ignore the typedef if it is an opaque ptr and just use nint whenever it is used as a parameter or member?

  1. When using nowrap for an function pointer typedef. it does not generate a type at all, for example:
typedef void (*Testfun)(int arg1, const char* arg2);

gets ignored and functions using it as param get the following signature

public static partial delegate*unmanaged[Cdecl]<int, byte*, void> setTestCallback(delegate*unmanaged[Cdecl]<int, byte*, void> callback);

Would it be possible to just not wrap it and add the delegate to the main class directly like so:

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void Testfun(int arg1, const char* arg2);

And lastly maybe a bit unrelated question but what would be the easiest way to change the names of functions, types and constants?Within a c library they often prefix a library name as a sort of namespace, In c# this would be unnecessary as you already have both the namespace and the class. Is there a built-in way to remove such a suffix? for example testInit() to just Init() where test is the prefix?

主要语言
C#
星标
142
派生
16
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

xoofx/CppAst.CodeGen 的其他 Issue

查看 xoofx/CppAst.CodeGen 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。