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

Passing metadata to -- or simulating -- child nodes #45

Open
zspitz opened this issue Sep 16, 2020 · 0 comments
Open

Passing metadata to -- or simulating -- child nodes #45

zspitz opened this issue Sep 16, 2020 · 0 comments
Labels
extensibility Related to extending renderers and using custom types
Milestone

Comments

@zspitz
Copy link
Owner

zspitz commented Sep 16, 2020

Currently there is no general mechanism for a parent node to pass information to the child node's WriteNode call. We're already running into this:

  • Distinguishing between parameter declarations and parameter usage: the node itself in both cases is a ParameterExpression
  • Distinguishing between different block types: is this the block of a function, which (for the C# renderer) means we need to insert the return keyword before the last rendered subexpression? Or is it within the test of an if, and the subexpressions in the block have to be separated with , instead of ;?

We could resolve this in one of two ways. Either:

  • Every method should take an additional metadata object parameter. Since the base class doesn't know anything about the type of the metadata object, the type of the parameter should be object, or
  • Every method's parameter should be OneOf<T, IWrapper<T>>, where IWrapper<T> can produce a T.

The second way is appealing because it would also allow creating pseudo-TExpressions and passing them around as if they were the real thing. This would be a great benefit when extending an expression tree with custom types, much like SwitchExpression uses SwitchCase instances.

@zspitz zspitz added the extensibility Related to extending renderers and using custom types label Sep 16, 2020
@zspitz zspitz added this to the 4.0 milestone Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extensibility Related to extending renderers and using custom types
Projects
None yet
Development

No branches or pull requests

1 participant