chkn / Xamarin.SwiftUI

.NET bindings for SwiftUI
MIT License
98 stars 7 forks source link

[C#] Leverage source generator to eliminate reflection in CustomViewType #41

Open chkn opened 3 years ago

chkn commented 3 years ago

Since we have the source generator, we can use it to eliminate the reflection in CustomViewType.

One possible approach is:

  1. Expose CustomViewType as public API, and refactor it to allow subclassing.
  2. For each custom view, the source generator can implement a subclass of CustomViewType into the user assembly that staticly calls the Body property.
  3. The source generator adds a CustomViewAttribute to the View that points at (2).