Replies: 2 comments
-
The feature would be very useful. I miss it |
Beta Was this translation helpful? Give feedback.
0 replies
-
This is included as part of #555. Closing as duplicate of #291. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm currently converting some ViewModels and their properties of a Xamarin.Forms app to use the Source Generators of the MVVM Toolkit.
I've noticed that there is currently no way to modify the visibility of the property setter of a generated property. There are sometimes situations where you would mark a setter as
internal
,private
orprotected
(or eveninternal protected
), so that a property can only be set by certain actors, while the getter should always bepublic
, so that it can be used in binding expressions.For example, I would like to be able to use the
[ObservableProperty]
Source Generator to be able to generate the equivalent of the following:The
Identifier
property could then still be used in a binding expression:The value can only be set from inside the class, e.g. in a method or command that calls some API:
This is useful, for example, if the value of the
Identifier
comes from an API call and shouldn't be publicly settable, or when it should not participate in Two-Way bindings. Therefore there should be a way to modify the visibility.My proposal is to add an optional visibility modifier to the
[ObservableProperty]
Source Generator calledSetterVisibility
which takes a single argument, e.g. an enum value or some other limited form of identifier:The resulting properties should then be equivalent to the following:
The default must, of course, be
Visibility.Public
ornull
in order to not break existing behavior.This would be highly useful and would allow the MVVM Source Generators to cover more scenarios that already were possible before.
Beta Was this translation helpful? Give feedback.
All reactions