[C#] Make the source generator an optional optimization
Currently, you can define the Body property on a custom view in a couple ways:
-
Using the exact return type, e.g:
public ModifiedBackground<Text,Color> Body => Text("hello").Background(Color.Red) -
Using the
Viewreturn type and the source generator:public View Body => Text("hello").Background(Color.Red)
The second form is clearly more readable and the first form can get out of hand quickly for even a trivial view hierarchy. However, the second form requires the source generator, and the source generator must be able to staticly determine the return type so it can emit the first form under the hood. When these requirements can't be satisfied, we should still enable the second form and expose this to Swift as AnyView
- [ ] Bind
AnyView - [ ] ~~Modify
CustomViewTypeto exposeView-typed Body property asAnyView~~ (see first comment)
Modify CustomViewType to expose View-typed Body property as AnyView
On second thought, I think we should make it explicit and require people to declare the return type as AnyView. That way, it will be clear what's happening and force people to acknowledge the performance implications.