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

Enhancement: Support Various Meta for Class Access Modifiers #12

Open
AndrewDRX opened this issue Feb 18, 2024 · 2 comments
Open

Enhancement: Support Various Meta for Class Access Modifiers #12

AndrewDRX opened this issue Feb 18, 2024 · 2 comments

Comments

@AndrewDRX
Copy link
Contributor

AndrewDRX commented Feb 18, 2024

Request

Add support for the following meta for class access modifiers:
@:file for file
@:internal for internal
@:public for public

Suggested Syntax

The syntax could be as follows:

@:public
class MyClass { }

To generate C# as follows:

public class MyClass { }

Details

Currently, classes are generated with no access modifiers. C# has the default modifier of internal when not specified, so all generated classes effectively have that modifier. This makes it impossible to develop a library package since all generated classes would be inaccessible when references by other projects.

Suggested Code Change

I can submit a pull request to show a rough idea of what this would look like.

Other Notes

There are also other class access modifiers (and accessibility levels) that would be applicable to nested classes, but I am not sure about the feasibility of generating nested classes, so those are excluded from this request.

References

Microsoft-documented C# access modifiers and accessibility levels:
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/access-modifiers

@jeremyfa
Copy link
Collaborator

I think this is a good thing to add, but better wait for my current ongoing changes before submitting a PR

@AndrewDRX
Copy link
Contributor Author

Okay. I noticed this logic in CSClass.hx:

// Compile metadata (built-in Reflaxe function)
var clsMeta = compiler.compileMetadata(classType.meta, MetadataTarget.Class) ?? "";
declaration += clsMeta;

// Basic declaration
declaration += "class " + csClassName;

So I was wondering if there was some existing process for adding/updating a metadata template where that would be able to handle it.

But I'll wait on investigating any changes for pull request until you are all set.

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