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

[C#] Make the source generator an optional optimization #22

Open
2 tasks
chkn opened this issue Jun 6, 2020 · 1 comment
Open
2 tasks

[C#] Make the source generator an optional optimization #22

chkn opened this issue Jun 6, 2020 · 1 comment
Labels
lang: C# Specific to the C# API

Comments

@chkn
Copy link
Owner

chkn commented Jun 6, 2020

Currently, you can define the Body property on a custom view in a couple ways:

  1. Using the exact return type, e.g:
    public ModifiedBackground<Text,Color> Body => Text("hello").Background(Color.Red)

  2. Using the View return 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 CustomViewType to expose View-typed Body property as AnyView (see first comment)
@chkn chkn added the lang: C# Specific to the C# API label Sep 26, 2020
@chkn
Copy link
Owner Author

chkn commented Nov 30, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang: C# Specific to the C# API
Projects
None yet
Development

No branches or pull requests

1 participant