Open dr1rrb opened 5 months ago
The most appropriate solution would be to generate types for the "second generation kind" (cf. https://github.com/unoplatform/uno.extensions/discussions/2307#discussioncomment-9573080) into a different namespace (and into another file name).
Note: Currently even if we add the [Value]
attribute on the State<MachineModel> Machine
property, the "second generation kind" will still generate its BindableMachineModel
but it will not been used ... we should also prevent that!
For reference, this is what we're thinking in terms of updating naming conventions:
Given:
record Person;
record PersonModel() { IState
For each model XYZModel, instead of generating BindableXYZModel, we would generate XYZViewModel.
For each unique IState
So you would end up here with 3 classes generated: PersonViewModel, OtherViewModel, PersonState
Conventions are great... Custom Conventions are better and Configurability should always be possible.
[MvuxSkip]
public record MyModel { }
[MvuxModel]
public record MyRecord { }
[assembly: MvuxConvention(Suffix = "Modelo")]
What we see in the above example is something where we can: 1) Opt out of Generation 2) Opt into Generation even though the record doesn't actually meet the convention 3) We are actually changing the convention to be localized for Spanish
Sure, we could eventually add some configurability like for new Suffixes.
I'd be curious to see a case where you want to skip a class suffixed Model containing IFeed/IState public properties.
I could be mistaken... but I thought the whole point is that we have a convention for the Generation on Type name rather than looking for Records that have IFeed/IState. With any such convention then we're already ignoring types that may have IFeed/IState.
@dansiegel You can use the [ReactiveBindable(false)]
attribute on your types. You can also enable/disable/configure the "convention" using the [ImplicitBindables("MyApp\.Presentation\.\.*Model$")]
attribute on your assembly. (It was suggested as workaround in the original bug report https://github.com/unoplatform/uno.extensions/discussions/2307#discussioncomment-9573080)
The issue is that there is still a bug in the handling of those attributes (even if we disable the generation for a model, we are generating the sub-bindable that would have been used by that model) + naming clash of generated types.
I agree with @dansiegel , by default my models are basicaly a bunch of properties with no other functionality, maybe some calculated values. Even if you don't generate the Bindable (Reactive) part, I still need to notify property changes.
Besides:
[MvuxSkip]
[MvuxModel]
public record MyModel { }
you could add:
[MvuxObservable]
public record MyRecord{ }
In MVUX, a Model is the record containing State.
State gets exposed as IState
If you need INPC, that's because values can change, either when they're being loaded (thats what IFeed does) or because user made an action (that's what IState does).
So the convention is that your model is suffixed by Model and contains either IFeed and/or IState.
There's nothing less or more to it.
Discussed in https://github.com/unoplatform/uno.extensions/discussions/2307
Result of investigation (with more details) can be found here : https://github.com/unoplatform/uno.extensions/discussions/2307#discussioncomment-9573080