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

Option to generate an attribute with alternative names for a typedef struct #499

Open
dpaoliello opened this issue Nov 22, 2023 · 1 comment

Comments

@dpaoliello
Copy link
Contributor

It would be useful for downstream projects (like Win32Metadata) for ClangSharp to mark types generated from typedef struct with an attribute to indicate what the alternative names for that struct were. This would allow downstream code generators for languages which support aliasing types to generate aliases with those names.

For example, given the C++ code:

typedef struct _MYSTRUCT {
  ...
} MYSTRUCT;

To generate C#:

[AlternativeName("MYSTRUCT")]
public partial struct _MYSTRUCT {
   ...
}
@tannergooding
Copy link
Member

I don't think this is a scalable or a workable solution.

Structs are typically defined in one header. Typedefs can be defined in any number of headers, including arbitrary other headers (and frequently are).

So I don't think its feasible to attach such attributes to the struct definition itself. The metadata could be exposed in a different way, and I've considered providing a switch to allow global using aliases, but those aren't embedded themselves either; they are purely a source code concept.

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