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

RFC: Reflection #27

Open
mrpmorris opened this issue May 25, 2023 · 1 comment
Open

RFC: Reflection #27

mrpmorris opened this issue May 25, 2023 · 1 comment

Comments

@mrpmorris
Copy link
Owner

At the moment, Moxy will only re-generate source for a mix-in decorated class if

  1. The class's signature changes
  2. The contents of the .mixin file changes

Adding/removing members does inside a C# class does not trigger a regeneration of its mix-ins, this is to enhance performance.

I want to be able to provide additional information to a mix-in about the class that it is working on. For example, it would be nice to be able to see the names of the class's properties, or only properties that are decorated with [Required] - but I don't want to start triggering source regeneration every time the coder alters their code on a property / method / field if there are no mix-ins that care.

So, I'm considering supporting some kind of query definition in the header of a .mixin

@moxy
@reflect someData = ( want the names of all properties decorated with MinLength, and the Length value of that attribute)
@moxy

{{ for datum in someData }}
Property {{ datum.Name }} has a min length of {{ datum.Length }}
{{ end }}

This will allow me to convert the reflect selection to json which gives two benefits

  1. The values can be made available inside the Scriban template
  2. I will only need to regenerate the source code for the mix-in whenever the json changes

RFC

I'd like suggestions for what the query text format might look like.

Any ideas appreciated!

@mrpmorris
Copy link
Owner Author

mrpmorris commented May 26, 2023

I think I might just make it simple

@moxy
@reflect properties, methods, fields
@moxy

Where options would be

(public | non-public)? (static | instance)? (properties | methods | fields)

e.g.

properties = public instance properties
non-public properties = instance properties that are not public
public static methods = methods that are static and public

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

1 participant