reflaxe.CSharp
reflaxe.CSharp copied to clipboard
Enhancement: Support Various Meta for Class Access Modifiers
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